Skip to content

Commit

Permalink
update permissions check for manage_ml
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Aug 8, 2019
1 parent 995a0eb commit 9b1e564
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class JobDetailsUI extends Component {
content: <JobDetailsPane sections={[datafeed, datafeedTimingStats]} />,
});

tabs.push(...[ {
tabs.push({
id: 'datafeed-preview',
name: intl.formatMessage({
id: 'xpack.ml.jobsList.jobDetails.tabs.datafeedPreviewLabel',
Expand All @@ -137,7 +137,7 @@ class JobDetailsUI extends Component {
defaultMessage: 'Forecasts'
}),
content: <ForecastsTable job={job} />,
}]);
});
}

if (mlAnnotationsEnabled && fullDetails) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ class JobsListUI extends Component {
),
onSelectionChange: this.props.selectJobChange
};

// Adding 'width' props to columns for use in the Kibana management jobs list table
// The version of the table used in ML > Job Managment depends on many EUI class overrides that set the width explicitly.
// The ML > Job Managment table won't change as the overwritten class styles take precedence, though these values may need to
// be updated if we move to always using props for width.
const columns = [
{
name: '',
Expand Down
12 changes: 2 additions & 10 deletions x-pack/legacy/plugins/ml/public/management/jobs_list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

/*
* 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.
*/

// @ts-ignore no declaration module
import { ReactDOM, render, unmountComponentAtNode } from 'react-dom';
import routes from 'ui/routes';
import { canGetManagementMlJobs } from '../../privilege/check_privilege';
import { JOBS_LIST_PATH } from '../management_urls';
import { JobsListPage } from './components';
import { AccessDeniedPage } from './components';
import { JOBS_LIST_PATH, ACCESS_DENIED_PATH } from '../management_urls';
import { JobsListPage, AccessDeniedPage } from './components';
import { getJobsListBreadcrumbs } from '../breadcrumbs';
import { ACCESS_DENIED_PATH } from '../management_urls';

const template = `<kbn-management-app section="ml/jobs-list">
<div id="kibanaManagementMLSection" />
Expand Down
12 changes: 10 additions & 2 deletions x-pack/legacy/plugins/ml/public/privilege/check_privilege.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ import { ACCESS_DENIED_PATH } from '../management/management_urls';

let privileges: Privileges = getDefaultPrivileges();

// TODO: needs to resolve regardless of space
export function canGetManagementMlJobs(kbnUrl: any) {
return new Promise((resolve, reject) => {
getPrivileges().then(({ capabilities, isPlatinumOrTrialLicense }) => {
privileges = capabilities;
if (privileges.canGetJobs && isPlatinumOrTrialLicense === true) {
const isManageML =
privileges.canGetJobs &&
privileges.canCreateJob &&
privileges.canUpdateJob &&
privileges.canOpenJob &&
privileges.canCloseJob &&
privileges.canDeleteJob &&
privileges.canForecastJob;

if (isManageML === true && isPlatinumOrTrialLicense === true) {
return resolve();
} else {
kbnUrl.redirect(ACCESS_DENIED_PATH);
Expand Down

0 comments on commit 9b1e564

Please sign in to comment.