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] DF Analytics: improve navigation related to creation wizard #69167

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,38 @@
import React, { FC, Fragment } from 'react';
import { EuiCard, EuiHorizontalRule, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useMlKibana } from '../../../../../contexts/kibana';

function redirectToAnalyticsManagementPage() {
window.location.href = '#/data_frame_analytics?';
}
export const BackToListPanel: FC = () => {
const {
services: {
application: { navigateToUrl },
},
} = useMlKibana();

export const BackToListPanel: FC = () => (
<Fragment>
<EuiHorizontalRule />
<EuiCard
// @ts-ignore
style={{ width: '300px' }}
icon={<EuiIcon size="xxl" type="list" />}
title={i18n.translate('xpack.ml.dataframe.analytics.create.analyticsListCardTitle', {
defaultMessage: 'Data Frame Analytics',
})}
description={i18n.translate(
'xpack.ml.dataframe.analytics.create.analyticsListCardDescription',
{
defaultMessage: 'Return to the analytics management page.',
}
)}
onClick={redirectToAnalyticsManagementPage}
data-test-subj="analyticsWizardCardManagement"
/>
</Fragment>
);
const redirectToAnalyticsManagementPage = async () => {
await navigateToUrl('#/data_frame_analytics?');
};

return (
<Fragment>
<EuiHorizontalRule />
<EuiCard
// @ts-ignore
style={{ width: '300px' }}
icon={<EuiIcon size="xxl" type="list" />}
title={i18n.translate('xpack.ml.dataframe.analytics.create.analyticsListCardTitle', {
defaultMessage: 'Data Frame Analytics',
})}
description={i18n.translate(
'xpack.ml.dataframe.analytics.create.analyticsListCardDescription',
{
defaultMessage: 'Return to the analytics management page.',
}
)}
onClick={redirectToAnalyticsManagementPage}
data-test-subj="analyticsWizardCardManagement"
/>
</Fragment>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,14 @@ export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item })
defaultMessage: 'Clone job',
});

const { notifications, savedObjects } = useMlKibana().services;
const {
services: {
application: { navigateToUrl },
notifications: { toasts },
savedObjects,
},
} = useMlKibana();

const savedObjectsClient = savedObjects.client;

const onClick = async () => {
Expand All @@ -385,7 +392,6 @@ export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item })
sourceIndexId = ip.id;
}
} catch (e) {
const { toasts } = notifications;
const error = extractErrorMessage(e);

toasts.addDanger(
Expand All @@ -401,9 +407,11 @@ export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item })
}

if (sourceIndexId) {
window.location.href = `ml#/data_frame_analytics/new_job?index=${encodeURIComponent(
sourceIndexId
)}&jobId=${item.config.id}`;
await navigateToUrl(
`ml#/data_frame_analytics/new_job?index=${encodeURIComponent(sourceIndexId)}&jobId=${
item.config.id
}`
);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ interface Props {
}

export const SourceSelection: FC<Props> = ({ onClose }) => {
const { uiSettings, savedObjects } = useMlKibana().services;
const {
services: {
application: { navigateToUrl },
savedObjects,
uiSettings,
},
} = useMlKibana();

const onSearchSelected = (id: string, type: string) => {
window.location.href = `ml#/data_frame_analytics/new_job?${
type === 'index-pattern' ? 'index' : 'savedSearchId'
}=${encodeURIComponent(id)}`;
const onSearchSelected = async (id: string, type: string) => {
await navigateToUrl(
`ml#/data_frame_analytics/new_job?${
type === 'index-pattern' ? 'index' : 'savedSearchId'
}=${encodeURIComponent(id)}`
);
};

return (
Expand Down