From bde38be7207dfd5dc56057b22efa3718a545a4e7 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Tue, 21 Jan 2020 16:46:07 +0000 Subject: [PATCH 1/3] [ML] Fixes permissions checks for data visualizer create job links --- .../application/datavisualizer/index_based/page.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx index 68856eb42973bd..4f0a8709a0dee3 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx @@ -33,6 +33,8 @@ import { NavigationMenu } from '../../components/navigation_menu'; import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search'; import { isFullLicense } from '../../license/check_license'; +import { checkPermission } from '../../privilege/check_privilege'; +import { mlNodesAvailable } from '../../ml_nodes_check/check_ml_nodes'; import { FullTimeRangeSelector } from '../../components/full_time_range_selector'; import { mlTimefilterRefresh$ } from '../../services/timefilter_refresh_service'; import { useKibanaContext, SavedSearchQuery } from '../../contexts/kibana'; @@ -131,7 +133,10 @@ export const Page: FC = () => { const defaults = getDefaultPageState(); const [showActionsPanel] = useState( - isFullLicense() && currentIndexPattern.timeFieldName !== undefined + isFullLicense() && + checkPermission('canCreateJob') && + mlNodesAvailable() && + currentIndexPattern.timeFieldName !== undefined ); const [searchString, setSearchString] = useState(defaults.searchString); @@ -613,7 +618,9 @@ export const Page: FC = () => { )} - + {showActionsPanel === true && ( + + )} From 901a1666c8250090e8c83f3565eaa85bf58d82f2 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Wed, 22 Jan 2020 10:03:19 +0000 Subject: [PATCH 2/3] [ML] Edits to permissions check following review --- .../application/datavisualizer/index_based/page.tsx | 9 ++++----- .../ml/public/application/explorer/explorer.js | 12 +++++++++++- .../ml/public/application/jobs/jobs_list/jobs.tsx | 7 ++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx index 4f0a8709a0dee3..721b8a458efc19 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx @@ -132,12 +132,11 @@ export const Page: FC = () => { const defaults = getDefaultPageState(); - const [showActionsPanel] = useState( + const showActionsPanel = isFullLicense() && - checkPermission('canCreateJob') && - mlNodesAvailable() && - currentIndexPattern.timeFieldName !== undefined - ); + checkPermission('canCreateJob') && + mlNodesAvailable() && + currentIndexPattern.timeFieldName !== undefined; const [searchString, setSearchString] = useState(defaults.searchString); const [searchQuery, setSearchQuery] = useState(defaults.searchQuery); diff --git a/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js b/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js index 6a1c5339de1f56..b3546423316373 100644 --- a/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js +++ b/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js @@ -21,8 +21,11 @@ import { EuiFlexItem, EuiFormRow, EuiIconTip, + EuiPage, + EuiPageBody, EuiSelect, EuiSpacer, + EuiTitle, } from '@elastic/eui'; import { AnnotationFlyout } from '../components/annotations/annotation_flyout'; @@ -87,8 +90,15 @@ function mapSwimlaneOptionsToEuiOptions(options) { const ExplorerPage = ({ children, jobSelectorProps, resizeRef }) => (
+ +

+ +

+
- {children} + + {children} +
); diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx b/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx index f820372e20c09a..7059e1e253b416 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx +++ b/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx @@ -6,6 +6,7 @@ import React, { FC } from 'react'; +import { EuiPage, EuiPageBody } from '@elastic/eui'; import { NavigationMenu } from '../../components/navigation_menu'; // @ts-ignore @@ -15,7 +16,11 @@ export const JobsPage: FC<{ props?: any }> = props => { return (
- + + + + +
); }; From 1fd3420e15793690aa29f28aefe4d9936eda0387 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Wed, 22 Jan 2020 11:11:50 +0000 Subject: [PATCH 3/3] [ML] Revert unintentional additions --- .../ml/public/application/explorer/explorer.js | 12 +----------- .../ml/public/application/jobs/jobs_list/jobs.tsx | 7 +------ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js b/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js index b3546423316373..6a1c5339de1f56 100644 --- a/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js +++ b/x-pack/legacy/plugins/ml/public/application/explorer/explorer.js @@ -21,11 +21,8 @@ import { EuiFlexItem, EuiFormRow, EuiIconTip, - EuiPage, - EuiPageBody, EuiSelect, EuiSpacer, - EuiTitle, } from '@elastic/eui'; import { AnnotationFlyout } from '../components/annotations/annotation_flyout'; @@ -90,15 +87,8 @@ function mapSwimlaneOptionsToEuiOptions(options) { const ExplorerPage = ({ children, jobSelectorProps, resizeRef }) => (
- -

- -

-
- - {children} - + {children}
); diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx b/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx index 7059e1e253b416..f820372e20c09a 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx +++ b/x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/jobs.tsx @@ -6,7 +6,6 @@ import React, { FC } from 'react'; -import { EuiPage, EuiPageBody } from '@elastic/eui'; import { NavigationMenu } from '../../components/navigation_menu'; // @ts-ignore @@ -16,11 +15,7 @@ export const JobsPage: FC<{ props?: any }> = props => { return (
- - - - - +
); };