mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[ML] Adds a check if the current user can access the indexpattern required to clone a job. (#27496)
Adds a check if all index patterns necessary to clone a job are available for the current user. The check will only allow cloning of a job if the user has the right permissions and can still access the indexPattern the job was created for. An indexPattern could either have been deleted since the the job was created or the current user doesn't have the required permissions to access the indexPattern. The "Clone Job" action in the jobs list action menu will be greyed out and unavailable for that job.
This commit is contained in:
parent
998afde6e4
commit
5a7ab185f9
3 changed files with 18 additions and 3 deletions
|
@ -4,8 +4,9 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { checkPermission } from 'plugins/ml/privilege/check_privilege';
|
||||
import { mlNodesAvailable } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
|
||||
import { checkPermission } from '../../../../privilege/check_privilege';
|
||||
import { mlNodesAvailable } from '../../../../ml_nodes_check/check_ml_nodes';
|
||||
import { getIndexPatternNames } from '../../../../util/index_utils';
|
||||
|
||||
import {
|
||||
stopDatafeeds,
|
||||
|
@ -76,7 +77,18 @@ export function actionsMenuContent(showEditJobFlyout, showDeleteJobModal, showSt
|
|||
defaultMessage: 'Clone job'
|
||||
}),
|
||||
icon: 'copy',
|
||||
enabled: () => (canCreateJob),
|
||||
enabled: (item) => {
|
||||
// We only allow cloning of a job if the user has the right permissions and can still access
|
||||
// the indexPattern the job was created for. An indexPattern could either have been deleted
|
||||
// since the the job was created or the current user doesn't have the required permissions to
|
||||
// access the indexPattern.
|
||||
const indexPatternNames = getIndexPatternNames();
|
||||
const jobIndicesAvailable = item.datafeedIndices.every((dfiName) => {
|
||||
return indexPatternNames.some(ipName => ipName === dfiName);
|
||||
});
|
||||
|
||||
return canCreateJob && jobIndicesAvailable;
|
||||
},
|
||||
onClick: (item) => {
|
||||
cloneJob(item.id);
|
||||
closeMenu(true);
|
||||
|
|
|
@ -11,6 +11,7 @@ import React from 'react';
|
|||
import { uiModules } from 'ui/modules';
|
||||
const module = uiModules.get('apps/ml', ['react']);
|
||||
|
||||
import { loadIndexPatterns } from 'plugins/ml/util/index_utils';
|
||||
import { checkFullLicense } from 'plugins/ml/license/check_license';
|
||||
import { checkGetJobsPrivilege } from 'plugins/ml/privilege/check_privilege';
|
||||
import { getMlNodeCount } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
|
||||
|
@ -28,6 +29,7 @@ uiRoutes
|
|||
k7Breadcrumbs: getJobManagementBreadcrumbs,
|
||||
resolve: {
|
||||
CheckLicense: checkFullLicense,
|
||||
indexPatterns: loadIndexPatterns,
|
||||
privileges: checkGetJobsPrivilege,
|
||||
mlNodeCount: getMlNodeCount,
|
||||
loadNewJobDefaults,
|
||||
|
|
|
@ -110,6 +110,7 @@ export function jobsProvider(callWithRequest) {
|
|||
jobState: job.state,
|
||||
hasDatafeed,
|
||||
datafeedId: (hasDatafeed && job.datafeed_config.datafeed_id) ? job.datafeed_config.datafeed_id : '',
|
||||
datafeedIndices: (hasDatafeed && job.datafeed_config.indices) ? job.datafeed_config.indices : [],
|
||||
datafeedState: (hasDatafeed && job.datafeed_config.state) ? job.datafeed_config.state : '',
|
||||
latestTimestampMs,
|
||||
earliestTimestampMs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue