Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Data Frames: Cards as links #45254

Merged
merged 6 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/ml/public/data_frame/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export {
DATA_FRAME_MODE,
DATA_FRAME_TRANSFORM_STATE,
} from './transform_stats';
export { moveToDataFrameTransformList, moveToDataFrameWizard, moveToDiscover } from './navigation';
export { moveToDataFrameWizard, getDiscoverUrl } from './navigation';
export {
getEsAggFromAggConfig,
isPivotAggsConfigWithUiSupport,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { getDiscoverUrl } from './navigation';

describe('navigation', () => {
test('getDiscoverUrl should provide encoded url to Discover page', () => {
expect(getDiscoverUrl('farequote-airline', 'http://example.com')).toBe(
"http://example.com#/discover?_g=()&_a=(index:'farequote-airline')"
);
});
});
13 changes: 7 additions & 6 deletions x-pack/legacy/plugins/ml/public/data_frame/common/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ export function moveToDataFrameWizard() {
window.location.href = '#/data_frames/new_transform';
}

export function moveToDataFrameTransformList() {
window.location.href = '#/data_frames';
}

export function moveToDiscover(indexPatternId: string, baseUrl: string) {
/**
* Gets a url for navigating to Discover page.
* @param indexPatternId Index pattern id.
* @param baseUrl Base url.
*/
export function getDiscoverUrl(indexPatternId: string, baseUrl: string): string {
const _g = rison.encode({});

// Add the index pattern ID to the appState part of the URL.
Expand All @@ -24,5 +25,5 @@ export function moveToDiscover(indexPatternId: string, baseUrl: string) {

const hash = `#/discover?_g=${_g}&_a=${_a}`;

window.location.href = `${baseUrl}${hash}`;
return `${baseUrl}${hash}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ import { useKibanaContext } from '../../../../../contexts/kibana/use_kibana_cont
import { useUiChromeContext } from '../../../../../contexts/ui/use_ui_chrome_context';
import { PROGRESS_JOBS_REFRESH_INTERVAL_MS } from '../../../../../../common/constants/jobs_list';

import {
getTransformProgress,
moveToDataFrameTransformList,
moveToDiscover,
} from '../../../../common';
import { getTransformProgress, getDiscoverUrl } from '../../../../common';

export interface StepDetailsExposedState {
created: boolean;
Expand Down Expand Up @@ -367,7 +363,7 @@ export const StepCreateForm: SFC<Props> = React.memo(
defaultMessage: 'Return to the data frame transform management page.',
}
)}
onClick={moveToDataFrameTransformList}
href="#/data_frames"
/>
</EuiFlexItem>
{started === true && createIndexPattern === true && indexPatternId === undefined && (
Expand Down Expand Up @@ -400,7 +396,7 @@ export const StepCreateForm: SFC<Props> = React.memo(
defaultMessage: 'Use Discover to explore the data frame pivot.',
}
)}
onClick={() => moveToDiscover(indexPatternId, baseUrl)}
href={getDiscoverUrl(indexPatternId, baseUrl)}
/>
</EuiFlexItem>
)}
Expand Down