Skip to content

Commit

Permalink
don't show form unless user has read permissions for actions, display…
Browse files Browse the repository at this point in the history
… text saying user is missing required privileges
  • Loading branch information
dhurley14 committed Oct 1, 2020
1 parent 87c194d commit 0f06a39
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EuiFlexItem,
EuiButton,
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { findIndex } from 'lodash/fp';
import React, { FC, memo, useCallback, useEffect, useMemo } from 'react';
Expand Down Expand Up @@ -125,11 +126,8 @@ const StepRuleActionsComponent: FC<StepRuleActionsProps> = ({
}, [getData, setForm]);

const throttleOptions = useMemo(() => {
if (application.capabilities.actions.show) {
return getThrottleOptions(throttle);
}
return [{ value: DEFAULT_THROTTLE_OPTION.value, text: I18n.NO_ACTIONS_READ_PERMISSIONS }];
}, [throttle, application.capabilities.actions.show]);
return getThrottleOptions(throttle);
}, [throttle]);

const throttleFieldComponentProps = useMemo(
() => ({
Expand All @@ -151,7 +149,11 @@ const StepRuleActionsComponent: FC<StepRuleActionsProps> = ({
) : (
<>
<StepContentWrapper addPadding={!isUpdateView}>
<Form form={form} data-test-subj="stepRuleActions">
<Form
form={form}
style={{ display: application.capabilities.actions.show ? 'block' : 'none' }}
data-test-subj="stepRuleActions"
>
<EuiForm>
<UseField
path="throttle"
Expand All @@ -170,12 +172,19 @@ const StepRuleActionsComponent: FC<StepRuleActionsProps> = ({
/>
</>
) : (
<UseField path="actions" component={GhostFormField} />
<UseField
visibility={application.capabilities.actions.show}
path="actions"
component={GhostFormField}
/>
)}
<UseField path="kibanaSiemAppUrl" component={GhostFormField} />
<UseField path="enabled" component={GhostFormField} />
</EuiForm>
</Form>
{!application.capabilities.actions.show && (
<EuiText>{I18n.NO_ACTIONS_READ_PERMISSIONS}</EuiText>
)}
</StepContentWrapper>

{!isUpdateView && (
Expand Down

0 comments on commit 0f06a39

Please sign in to comment.