Skip to content

Commit

Permalink
disable actions if no permissions (#88034) (#88087)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 authored Jan 12, 2021
1 parent 222a85a commit ab4b84a
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const Controls: FC<Props> = React.memo(
const [isPopoverOpen, setPopover] = useState<boolean>(false);
const [didUntag, setDidUntag] = useState<boolean>(false);

const canCreateDataFrameAnalytics: boolean = checkPermission('canCreateDataFrameAnalytics');
const canDeleteDataFrameAnalytics: boolean = checkPermission('canDeleteDataFrameAnalytics');
const deleteAction = useDeleteAction(canDeleteDataFrameAnalytics);
const {
Expand Down Expand Up @@ -201,6 +202,7 @@ export const Controls: FC<Props> = React.memo(
<EuiContextMenuItem
key={`${nodeId}-delete`}
icon="trash"
disabled={!canDeleteDataFrameAnalytics}
onClick={() => {
openDeleteJobCheckModal({ config: details[nodeId], stats: details[nodeId]?.stats });
}}
Expand All @@ -210,7 +212,12 @@ export const Controls: FC<Props> = React.memo(
defaultMessage="Delete job"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem key={`${nodeId}-clone`} icon="copy" onClick={onCloneJobClick}>
<EuiContextMenuItem
key={`${nodeId}-clone`}
icon="copy"
disabled={!canCreateDataFrameAnalytics}
onClick={onCloneJobClick}
>
<FormattedMessage
id="xpack.ml.dataframe.analyticsMap.flyout.cloneJobButton"
defaultMessage="Clone job"
Expand All @@ -221,6 +228,7 @@ export const Controls: FC<Props> = React.memo(
...(nodeType === JOB_MAP_NODE_TYPES.INDEX
? [
<EuiContextMenuItem
disabled={!canCreateDataFrameAnalytics}
key={`${nodeId}-create`}
icon="plusInCircle"
onClick={onCreateJobClick}
Expand Down

0 comments on commit ab4b84a

Please sign in to comment.