From 7e834e985482783f12a390f142a6c0452b7b555c Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Sat, 10 Aug 2019 17:07:48 -0400 Subject: [PATCH 1/8] disable job link if ml not enabled in space --- .../components/jobs_list/jobs_list.js | 20 ++++++++++++- .../jobs_list_view/jobs_list_view.js | 11 +++---- .../jobs_list_page/_expanded_row.scss | 5 ++++ .../jobs_list_page/jobs_list_page.tsx | 30 +++++++++++-------- .../ml/public/management/jobs_list/index.ts | 6 ++-- .../ml/public/privilege/check_privilege.ts | 22 +++++++------- .../lib/check_privileges/check_privileges.ts | 5 ++-- .../legacy/plugins/ml/server/routes/system.js | 6 ++-- 8 files changed, 69 insertions(+), 36 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js index d3145cb797864..7b0ede3e71e02 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js +++ b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js @@ -80,11 +80,21 @@ class JobsListUI extends Component { }; getJobIdLink(id) { - return ( + let link = ( {id} ); + // Disable link to job if ML is not enabled in current space + if (this.props.isMlEnabledInSpace === false) { + link = ( + {}} color="subdued"> + {id} + + ); + } + + return link; } getPageOfJobs(index, size, sortField, sortDirection) { @@ -253,6 +263,10 @@ class JobsListUI extends Component { {'all'} ) }); + // Remove actions if Ml not enabled in current space + if (this.props.isMlEnabledInSpace === false) { + columns.pop(); + } } else { // insert before last column columns.splice(columns.length - 1, 0, { @@ -344,6 +358,8 @@ class JobsListUI extends Component { JobsListUI.propTypes = { jobsSummaryList: PropTypes.array.isRequired, fullJobsList: PropTypes.object.isRequired, + isManagementTable: PropTypes.boolean, + isMlEnabledInSpace: PropTypes.boolean, itemIdToExpandedRowMap: PropTypes.object.isRequired, toggleRow: PropTypes.func.isRequired, selectJobChange: PropTypes.func.isRequired, @@ -355,6 +371,8 @@ JobsListUI.propTypes = { loading: PropTypes.bool, }; JobsListUI.defaultProps = { + isManagementTable: false, + isMlEnabledInSpace: true, loading: false, }; diff --git a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js index 337bb5a12f61c..dc7ae279ee8ba 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js +++ b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js @@ -362,21 +362,22 @@ export class JobsListView extends Component { } renderManagementJobsListComponents() { - const { loading } = this.state; + const { loading, itemIdToExpandedRowMap, filteredJobsSummaryList, fullJobsList, selectedJobs } = this.state; return (
); diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss index 3c2259629a7a6..a4606de146f98 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss @@ -1,3 +1,8 @@ +.disabledLink { + pointer-events: none; + cursor: default; +} + // Expanded row content styles .tab-contents { margin: -$euiSizeS; diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx index 852e33d92e5a8..141bf5a53c300 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment } from 'react'; +import React, { Fragment, FC } from 'react'; import { i18n } from '@kbn/i18n'; import { I18nContext } from 'ui/i18n'; import { @@ -20,7 +20,11 @@ import { // @ts-ignore undeclared module import { JobsListView } from '../../../../jobs/jobs_list/components/jobs_list_view'; -export const JobsListPage = () => { +interface Props { + isMlEnabledInSpace: boolean; +} + +export const JobsListPage: FC = ({ isMlEnabledInSpace }) => { const tabs = [ { id: 'anomaly_detection_jobs', @@ -30,22 +34,22 @@ export const JobsListPage = () => { content: ( - + ), }, - // { - // id: 'analytics_jobs', - // name: i18n.translate('xpack.ml.management.jobsList.analyticsTab', { - // defaultMessage: 'Analytics', - // }), - // content: renderAnalyticsJobs(), - // }, + { + id: 'analytics_jobs', + name: i18n.translate('xpack.ml.management.jobsList.analyticsTab', { + defaultMessage: 'Analytics', + }), + content: renderAnalyticsJobs(), + }, ]; - // function renderAnalyticsJobs() { - // return
Analytics job placeholder
; - // } + function renderAnalyticsJobs() { + return
Analytics job placeholder
; + } function renderTabs() { return ; diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts b/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts index 071d5ab6c6dfa..b22b7f3b234c7 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts @@ -22,14 +22,16 @@ routes.when(JOBS_LIST_PATH, { resolve: { checkPrivilege: canGetManagementMlJobs, }, - controller($scope) { + controller($scope, checkPrivilege) { + const { mlFeatureEnabledInSpace } = checkPrivilege; + $scope.$on('$destroy', () => { const elem = document.getElementById('kibanaManagementMLSection'); if (elem) unmountComponentAtNode(elem); }); $scope.$$postDigest(() => { const element = document.getElementById('kibanaManagementMLSection'); - render(JobsListPage(), element); + render(JobsListPage({ isMlEnabledInSpace: mlFeatureEnabledInSpace }), element); }); }, }); diff --git a/x-pack/legacy/plugins/ml/public/privilege/check_privilege.ts b/x-pack/legacy/plugins/ml/public/privilege/check_privilege.ts index 8ea4b39ffe2f6..7f2985eda9da8 100644 --- a/x-pack/legacy/plugins/ml/public/privilege/check_privilege.ts +++ b/x-pack/legacy/plugins/ml/public/privilege/check_privilege.ts @@ -17,18 +17,20 @@ let privileges: Privileges = getDefaultPrivileges(); // manage_ml requires all monitor and admin cluster privileges: https://github.com/elastic/elasticsearch/blob/664a29c8905d8ce9ba8c18aa1ed5c5de93a0eabc/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java#L53 export function canGetManagementMlJobs(kbnUrl: any) { return new Promise((resolve, reject) => { - getManageMlPrivileges().then(({ capabilities, isPlatinumOrTrialLicense }) => { - privileges = capabilities; - // Loop through all privilages to ensure they are all set to true. - const isManageML = Object.values(privileges).every(p => p === true); + getManageMlPrivileges().then( + ({ capabilities, isPlatinumOrTrialLicense, mlFeatureEnabledInSpace }) => { + privileges = capabilities; + // Loop through all privilages to ensure they are all set to true. + const isManageML = Object.values(privileges).every(p => p === true); - if (isManageML === true && isPlatinumOrTrialLicense === true) { - return resolve(); - } else { - kbnUrl.redirect(ACCESS_DENIED_PATH); - return reject(); + if (isManageML === true && isPlatinumOrTrialLicense === true) { + return resolve({ mlFeatureEnabledInSpace }); + } else { + kbnUrl.redirect(ACCESS_DENIED_PATH); + return reject(); + } } - }); + ); }); } diff --git a/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts b/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts index ae73ba5be22bb..0ce60fffd836d 100644 --- a/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts +++ b/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts @@ -26,7 +26,8 @@ interface Response { export function privilegesProvider( callWithRequest: callWithRequestType, xpackMainPlugin: XPackMainPlugin, - isMlEnabledInSpace: () => Promise + isMlEnabledInSpace: () => Promise, + ignoreSpaces: boolean = false ) { const { isUpgradeInProgress } = upgradeCheckProvider(callWithRequest); async function getPrivileges(): Promise { @@ -47,7 +48,7 @@ export function privilegesProvider( ? setFullActionPrivileges : setBasicActionPrivileges; - if (mlFeatureEnabledInSpace === false) { + if (mlFeatureEnabledInSpace === false && ignoreSpaces === false) { // if ML isn't enabled in the current space, // return with the default privileges (all false) return { diff --git a/x-pack/legacy/plugins/ml/server/routes/system.js b/x-pack/legacy/plugins/ml/server/routes/system.js index 685117826c2dd..787fb87404581 100644 --- a/x-pack/legacy/plugins/ml/server/routes/system.js +++ b/x-pack/legacy/plugins/ml/server/routes/system.js @@ -99,12 +99,12 @@ export function systemRoutes({ const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request); try { const ignoreSpaces = request.query && request.query.ignoreSpaces === 'true'; - // if spaces is disabled or ignoreSpace is true force isMlEnabledInSpace to be true - const { isMlEnabledInSpace } = (spacesPlugin !== undefined && ignoreSpaces === false) ? + // if spaces is disabled force isMlEnabledInSpace to be true + const { isMlEnabledInSpace } = spacesPlugin !== undefined ? spacesUtilsProvider(spacesPlugin, request, config) : { isMlEnabledInSpace: async () => true }; - const { getPrivileges } = privilegesProvider(callWithRequest, xpackMainPlugin, isMlEnabledInSpace); + const { getPrivileges } = privilegesProvider(callWithRequest, xpackMainPlugin, isMlEnabledInSpace, ignoreSpaces); return await getPrivileges(); } catch (error) { return wrapError(error); From c2df266bbfdd371858bc8dff527815c722bdc575 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Mon, 12 Aug 2019 13:16:28 -0400 Subject: [PATCH 2/8] add analytics table in managment page --- .../jobs/jobs_list/components/jobs_list/jobs_list.js | 4 ++-- .../ml/public/jobs/jobs_list/components/utils.js | 2 +- .../management/jobs_list/components/_index.scss | 1 + .../components/jobs_list_page/_analytics_table.scss | 7 +++++++ .../components/jobs_list_page/jobs_list_page.tsx | 12 +++++++----- 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss diff --git a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js index 7b0ede3e71e02..d807a3b1fb638 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js +++ b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js @@ -358,8 +358,8 @@ class JobsListUI extends Component { JobsListUI.propTypes = { jobsSummaryList: PropTypes.array.isRequired, fullJobsList: PropTypes.object.isRequired, - isManagementTable: PropTypes.boolean, - isMlEnabledInSpace: PropTypes.boolean, + isManagementTable: PropTypes.bool, + isMlEnabledInSpace: PropTypes.bool, itemIdToExpandedRowMap: PropTypes.object.isRequired, toggleRow: PropTypes.func.isRequired, selectJobChange: PropTypes.func.isRequired, diff --git a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/utils.js b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/utils.js index d0a44549c5333..e149261b7971d 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/utils.js +++ b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/utils.js @@ -8,7 +8,7 @@ import { each } from 'lodash'; import { toastNotifications } from 'ui/notify'; import { mlMessageBarService } from 'plugins/ml/components/messagebar/messagebar_service'; import rison from 'rison-node'; -import chrome from 'ui/chrome'; // TODO: get from context once walter's PR is merged +import chrome from 'ui/chrome'; import { mlJobService } from 'plugins/ml/services/job_service'; import { ml } from 'plugins/ml/services/ml_api_service'; diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/_index.scss b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/_index.scss index 9fdce0d98e5c4..883ecd96745b4 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/_index.scss +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/_index.scss @@ -1,3 +1,4 @@ @import './jobs_list_page/stats_bar'; @import './jobs_list_page/buttons'; @import './jobs_list_page/expanded_row'; +@import './jobs_list_page/analytics_table'; diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss new file mode 100644 index 0000000000000..3cb0d59ccec2d --- /dev/null +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss @@ -0,0 +1,7 @@ +.mlAnalyticsProgressBar { + margin-bottom: $euiSizeM; +} + +.mlTaskStateBadge { + max-width: 100px; +} diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx index 141bf5a53c300..1b8d7b8855197 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx @@ -19,6 +19,7 @@ import { // @ts-ignore undeclared module import { JobsListView } from '../../../../jobs/jobs_list/components/jobs_list_view'; +import { DataFrameAnalyticsList } from '../../../../data_frame_analytics/pages/analytics_management/components/analytics_list'; interface Props { isMlEnabledInSpace: boolean; @@ -43,14 +44,15 @@ export const JobsListPage: FC = ({ isMlEnabledInSpace }) => { name: i18n.translate('xpack.ml.management.jobsList.analyticsTab', { defaultMessage: 'Analytics', }), - content: renderAnalyticsJobs(), + content: ( + + + + + ), }, ]; - function renderAnalyticsJobs() { - return
Analytics job placeholder
; - } - function renderTabs() { return ; } From edd9ca9b0822346147faa776564fb1efc708b632 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Mon, 12 Aug 2019 17:29:12 -0400 Subject: [PATCH 3/8] update css for analytics table --- .../jobs_list_page/_analytics_table.scss | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss index 3cb0d59ccec2d..ce53c33ca9ece 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_analytics_table.scss @@ -1,3 +1,24 @@ + +.mlAnalyticsTable { + // Using an override as a last resort because we cannot set custom classes on + // nested upstream components. The opening animation limits the height + // of the expanded row to 1000px which turned out to be not predictable. + // The animation could also result in flickering with expanded rows + // where the inner content would result in the DOM changing the height. + .euiTableRow-isExpandedRow .euiTableCellContent { + animation: none !important; + .euiTableCellContent__text { + width: 100%; + } + } + // Another override: Because an update to the table replaces the DOM, the same + // icon would still again fade in with an animation. If the table refreshes with + // e.g. 1s this would result in a blinking icon effect. + .euiIcon-isLoaded { + animation: none !important; + } +} + .mlAnalyticsProgressBar { margin-bottom: $euiSizeM; } From 747344cc7c5b0eb8a4beb2b51abf084479c78aff Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 13 Aug 2019 10:41:19 -0400 Subject: [PATCH 4/8] only show ML section if license if trial/platinum --- x-pack/legacy/plugins/ml/public/management/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/ml/public/management/index.ts b/x-pack/legacy/plugins/ml/public/management/index.ts index 08e17a2a44f73..744b03c3d592b 100644 --- a/x-pack/legacy/plugins/ml/public/management/index.ts +++ b/x-pack/legacy/plugins/ml/public/management/index.ts @@ -15,9 +15,13 @@ import { management } from 'ui/management'; import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; import { i18n } from '@kbn/i18n'; import { JOBS_LIST_PATH } from './management_urls'; +import { LICENSE_TYPE } from '../../common/constants/license'; import 'plugins/ml/management/jobs_list'; -if (xpackInfo.get('features.ml.showLinks', false) === true) { +if ( + xpackInfo.get('features.ml.showLinks', false) === true && + xpackInfo.get('features.ml.licenseType') === LICENSE_TYPE.FULL +) { management.register('ml', { display: i18n.translate('xpack.ml.management.mlTitle', { defaultMessage: 'Machine Learning', From 6a2bdd17265c609e7bf6fe082e3bcedb3098f15f Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 13 Aug 2019 11:37:29 -0400 Subject: [PATCH 5/8] remove actions column for analytics list in KM --- .../components/analytics_list/analytics_list.tsx | 8 ++++++-- .../components/analytics_list/columns.tsx | 16 +++++++++++----- .../components/jobs_list_page/jobs_list_page.tsx | 2 +- .../ml/public/management/jobs_list/index.ts | 9 ++++++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx index 95c81e20e6ccb..e58b3ff597c22 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx @@ -63,7 +63,11 @@ function stringMatch(str: string | undefined, substr: string) { ); } -export const DataFrameAnalyticsList: FC = () => { +interface Props { + isManagementTable: boolean; +} +// isManagementTable - for use in Kibana managagement ML section +export const DataFrameAnalyticsList: FC = ({ isManagementTable }) => { const [isInitialized, setIsInitialized] = useState(false); const [isLoading, setIsLoading] = useState(false); const [blockRefresh, setBlockRefresh] = useState(false); @@ -225,7 +229,7 @@ export const DataFrameAnalyticsList: FC = () => { ); } - const columns = getColumns(expandedRowItemIds, setExpandedRowItemIds); + const columns = getColumns(expandedRowItemIds, setExpandedRowItemIds, isManagementTable); const sorting = { sort: { diff --git a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx index 3549732b0edc6..541a083c3d0fb 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx @@ -59,7 +59,8 @@ export const getTaskStateBadge = ( export const getColumns = ( expandedRowItemIds: DataFrameAnalyticsId[], - setExpandedRowItemIds: React.Dispatch> + setExpandedRowItemIds: React.Dispatch>, + isManagementTable: boolean = false ) => { const actions = getActions(); @@ -76,7 +77,7 @@ export const getColumns = ( setExpandedRowItemIds([...expandedRowItemIds]); } - return [ + const columns = [ { align: RIGHT_ALIGNMENT, width: '40px', @@ -205,12 +206,17 @@ export const getColumns = ( }, width: '100px', }, - { + ]; + + if (isManagementTable === false) { + columns.push({ name: i18n.translate('xpack.ml.dataframe.analyticsList.tableActionLabel', { defaultMessage: 'Actions', }), actions, width: '200px', - }, - ]; + }); + } + + return columns; }; diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx index 1b8d7b8855197..6bdfa64833a39 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx @@ -47,7 +47,7 @@ export const JobsListPage: FC = ({ isMlEnabledInSpace }) => { content: ( - + ), }, diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts b/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts index b22b7f3b234c7..b88138d139f60 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -// @ts-ignore no declaration module -import { ReactDOM, render, unmountComponentAtNode } from 'react-dom'; +import ReactDOM, { render, unmountComponentAtNode } from 'react-dom'; +import React from 'react'; import routes from 'ui/routes'; import { canGetManagementMlJobs } from '../../privilege/check_privilege'; import { JOBS_LIST_PATH, ACCESS_DENIED_PATH } from '../management_urls'; @@ -31,7 +31,10 @@ routes.when(JOBS_LIST_PATH, { }); $scope.$$postDigest(() => { const element = document.getElementById('kibanaManagementMLSection'); - render(JobsListPage({ isMlEnabledInSpace: mlFeatureEnabledInSpace }), element); + ReactDOM.render( + React.createElement(JobsListPage, { isMlEnabledInSpace: mlFeatureEnabledInSpace }), + element + ); }); }, }); From a61bef76c9f19bf59760957fec732ed400248f0d Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 13 Aug 2019 12:04:52 -0400 Subject: [PATCH 6/8] fix typescript error on columns --- .../components/analytics_list/columns.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx index 541a083c3d0fb..4362a0f8d7106 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/columns.tsx @@ -76,8 +76,8 @@ export const getColumns = ( // spread to a new array otherwise the component wouldn't re-render setExpandedRowItemIds([...expandedRowItemIds]); } - - const columns = [ + // update possible column types to something like (FieldDataColumn | ComputedColumn | ActionsColumn)[] when they have been added to EUI + const columns: any[] = [ { align: RIGHT_ALIGNMENT, width: '40px', From 3ce1b2c984681d290fb5608702ee40daf13caff4 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 13 Aug 2019 14:04:48 -0400 Subject: [PATCH 7/8] update props interface for analytics table --- .../components/analytics_list/analytics_list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx index e58b3ff597c22..d3ddc5999e7d3 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx @@ -64,7 +64,7 @@ function stringMatch(str: string | undefined, substr: string) { } interface Props { - isManagementTable: boolean; + isManagementTable?: boolean; } // isManagementTable - for use in Kibana managagement ML section export const DataFrameAnalyticsList: FC = ({ isManagementTable }) => { From e8d66134bbd424cd3231493db8bb0f613af47525 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 14 Aug 2019 11:41:30 -0400 Subject: [PATCH 8/8] plain text instead of disabled link if not enabled in space --- .../jobs_list/components/jobs_list/jobs_list.js | 17 ++++++----------- .../jobs_list_page/_expanded_row.scss | 5 ----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js index d807a3b1fb638..1a6243413d614 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js +++ b/x-pack/legacy/plugins/ml/public/jobs/jobs_list/components/jobs_list/jobs_list.js @@ -80,21 +80,16 @@ class JobsListUI extends Component { }; getJobIdLink(id) { - let link = ( + // Don't allow link to job if ML is not enabled in current space + if (this.props.isMlEnabledInSpace === false) { + return id; + } + + return ( {id} ); - // Disable link to job if ML is not enabled in current space - if (this.props.isMlEnabledInSpace === false) { - link = ( - {}} color="subdued"> - {id} - - ); - } - - return link; } getPageOfJobs(index, size, sortField, sortDirection) { diff --git a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss index a4606de146f98..3c2259629a7a6 100644 --- a/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss +++ b/x-pack/legacy/plugins/ml/public/management/jobs_list/components/jobs_list_page/_expanded_row.scss @@ -1,8 +1,3 @@ -.disabledLink { - pointer-events: none; - cursor: default; -} - // Expanded row content styles .tab-contents { margin: -$euiSizeS;