-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Persisted URL state for the "Anomaly detection jobs" page #83149
Changes from all commits
0d20fb7
eef12d0
7dc9094
93f10ca
e18103e
2ca607b
55556e3
8eebf80
b48ab5b
593cd83
cfc7474
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -6,10 +6,11 @@ | |||
|
||||
import { EuiCard, EuiIcon, EuiButtonEmpty, EuiSpacer } from '@elastic/eui'; | ||||
import { FormattedMessage } from '@kbn/i18n/react'; | ||||
import React from 'react'; | ||||
import React, { useEffect, useState } from 'react'; | ||||
import { SetupStatus } from '../../../../../common/log_analysis'; | ||||
import { CreateJobButton, RecreateJobButton } from '../../log_analysis_setup/create_job_button'; | ||||
import { useLinkProps } from '../../../../hooks/use_link_props'; | ||||
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana'; | ||||
import { mountReactNode } from '../../../../../../../../src/core/public/utils'; | ||||
|
||||
export const LogAnalysisModuleListCard: React.FC<{ | ||||
jobId: string; | ||||
|
@@ -26,19 +27,46 @@ export const LogAnalysisModuleListCard: React.FC<{ | |||
moduleStatus, | ||||
onViewSetup, | ||||
}) => { | ||||
const { | ||||
services: { | ||||
ml, | ||||
application: { navigateToUrl }, | ||||
notifications: { toasts }, | ||||
}, | ||||
} = useKibanaContextForPlugin(); | ||||
|
||||
const [viewInMlLink, setViewInMlLink] = useState<string>(''); | ||||
|
||||
const getMlUrl = async () => { | ||||
if (!ml.urlGenerator) { | ||||
toasts.addWarning({ | ||||
title: mountReactNode( | ||||
<FormattedMessage | ||||
id="xpack.infra.logs.analysis.mlNotAvailable" | ||||
defaultMessage="ML plugin is not available" | ||||
/> | ||||
), | ||||
}); | ||||
return; | ||||
} | ||||
setViewInMlLink(await ml.urlGenerator.createUrl({ page: 'jobs', pageState: { jobId } })); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR but I'm curious: how come the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a question for the Kibana team. Check the exposed public contract of the URL generator
|
||||
}; | ||||
|
||||
useEffect(() => { | ||||
getMlUrl(); | ||||
}); | ||||
|
||||
const navigateToMlApp = async () => { | ||||
await navigateToUrl(viewInMlLink); | ||||
}; | ||||
|
||||
const moduleIcon = | ||||
moduleStatus.type === 'required' ? ( | ||||
<EuiIcon size="xxl" type="machineLearningApp" /> | ||||
) : ( | ||||
<EuiIcon color="secondary" size="xxl" type="check" /> | ||||
); | ||||
|
||||
const viewInMlLinkProps = useLinkProps({ | ||||
app: 'ml', | ||||
pathname: '/jobs', | ||||
search: { mlManagement: `(jobId:${jobId})` }, | ||||
}); | ||||
|
||||
const moduleSetupButton = | ||||
moduleStatus.type === 'required' ? ( | ||||
<CreateJobButton hasSetupCapabilities={hasSetupCapabilities} onClick={onViewSetup}> | ||||
|
@@ -50,13 +78,17 @@ export const LogAnalysisModuleListCard: React.FC<{ | |||
) : ( | ||||
<> | ||||
<RecreateJobButton hasSetupCapabilities={hasSetupCapabilities} onClick={onViewSetup} /> | ||||
<EuiSpacer size="xs" /> | ||||
<EuiButtonEmpty {...viewInMlLinkProps}> | ||||
<FormattedMessage | ||||
id="xpack.infra.logs.analysis.viewInMlButtonLabel" | ||||
defaultMessage="View in Machine Learning" | ||||
/> | ||||
</EuiButtonEmpty> | ||||
{viewInMlLink ? ( | ||||
<> | ||||
<EuiSpacer size="xs" /> | ||||
<EuiButtonEmpty onClick={navigateToMlApp}> | ||||
<FormattedMessage | ||||
id="xpack.infra.logs.analysis.viewInMlButtonLabel" | ||||
defaultMessage="View in Machine Learning" | ||||
/> | ||||
</EuiButtonEmpty> | ||||
</> | ||||
) : null} | ||||
</> | ||||
); | ||||
|
||||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can skip this check. If the ML module is not available I don't think the setup flyout will ever be mounted anyway.