Skip to content

Commit

Permalink
[ML] Disable data frame anaylics clone button based on permission (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Apr 30, 2020
1 parent e5946ce commit 535cece
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '../../hooks/use_create_analytics_form';
import { State } from '../../hooks/use_create_analytics_form/state';
import { DataFrameAnalyticsListRow } from './common';
import { checkPermission } from '../../../../../capabilities/check_capabilities';

interface PropDefinition {
/**
Expand Down Expand Up @@ -322,6 +323,8 @@ interface CloneActionProps {
* to support EuiContext with a valid DOM structure without nested buttons.
*/
export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item }) => {
const canCreateDataFrameAnalytics: boolean = checkPermission('canCreateDataFrameAnalytics');

const buttonText = i18n.translate('xpack.ml.dataframe.analyticsList.cloneJobButtonLabel', {
defaultMessage: 'Clone job',
});
Expand All @@ -338,6 +341,7 @@ export const CloneAction: FC<CloneActionProps> = ({ createAnalyticsForm, item })
iconType="copy"
onClick={onClick}
aria-label={buttonText}
disabled={canCreateDataFrameAnalytics === false}
>
{buttonText}
</EuiButtonEmpty>
Expand Down

0 comments on commit 535cece

Please sign in to comment.