Skip to content

Commit

Permalink
[ML] Data Frames: Cards as links (elastic#45254)
Browse files Browse the repository at this point in the history
* [ML] Data Frames: Cards as links

* [ML] PR remarks
  • Loading branch information
darnautov committed Sep 11, 2019
1 parent cd933fd commit c17d42e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
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

0 comments on commit c17d42e

Please sign in to comment.