-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Adding job sychronization warning to job list pages (#85794)
* [ML] Adding job sychronization warning to job list pages * fixing overview page callout * improving check logic * adding render lock Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
800f79e
commit 168782d
Showing
7 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/ml/public/application/components/saved_objects_warning/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { SavedObjectsWarning } from './saved_objects_warning'; |
82 changes: 82 additions & 0 deletions
82
.../plugins/ml/public/application/components/saved_objects_warning/saved_objects_warning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* 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 React, { FC, useEffect, useState } from 'react'; | ||
|
||
import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { JobType } from '../../../../common/types/saved_objects'; | ||
import { useMlApiContext, useMlKibana } from '../../contexts/kibana'; | ||
|
||
interface Props { | ||
jobType?: JobType; | ||
} | ||
|
||
export const SavedObjectsWarning: FC<Props> = ({ jobType }) => { | ||
const { | ||
savedObjects: { initSavedObjects }, | ||
} = useMlApiContext(); | ||
const { | ||
services: { | ||
http: { basePath }, | ||
}, | ||
} = useMlKibana(); | ||
|
||
const [showWarning, setShowWarning] = useState(false); | ||
|
||
useEffect(() => { | ||
let unmounted = false; | ||
initSavedObjects(true) | ||
.then(({ jobs }) => { | ||
if (unmounted === true) { | ||
return; | ||
} | ||
|
||
const missingJobs = | ||
jobs.length > 0 && (jobType === undefined || jobs.some(({ type }) => type === jobType)); | ||
setShowWarning(missingJobs); | ||
}) | ||
.catch(() => { | ||
console.log('Saved object synchronization check could not be performed.'); // eslint-disable-line no-console | ||
}); | ||
return () => { | ||
unmounted = true; | ||
}; | ||
}, []); | ||
|
||
return showWarning === false ? null : ( | ||
<> | ||
<EuiCallOut | ||
title={ | ||
<FormattedMessage | ||
id="xpack.ml.jobsList.missingSavedObjectWarning.title" | ||
defaultMessage="ML job synchronization needed" | ||
/> | ||
} | ||
color="warning" | ||
iconType="alert" | ||
> | ||
<div> | ||
<FormattedMessage | ||
id="xpack.ml.jobsList.missingSavedObjectWarning.description" | ||
defaultMessage="All jobs require an accompanying saved object. Some jobs are missing their saved object and require synchronization in the {link}." | ||
values={{ | ||
link: ( | ||
<EuiLink href={`${basePath.get()}/app/management/insightsAndAlerting/jobsListLink`}> | ||
<FormattedMessage | ||
id="xpack.ml.jobsList.missingSavedObjectWarning.linkToManagement.link" | ||
defaultMessage="stack management page" | ||
/> | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
</div> | ||
</EuiCallOut> | ||
<EuiSpacer size="m" /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters