Skip to content

Commit

Permalink
Hide privileges controls if no spaces are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Nov 1, 2024
1 parent ce94a6c commit 16206f2
Showing 1 changed file with 82 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,84 +195,88 @@ export class PrivilegeSpaceForm extends Component<Props, State> {
/>
</EuiFormRow>

<EuiFormRow fullWidth>
<EuiCallOut
color="primary"
iconType="iInCircle"
size="s"
title={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.featurePrivilegeSummaryDescription',
{
defaultMessage:
'Some features might be hidden by the space or affected by a global space privilege.',
}
)}
/>
</EuiFormRow>

{this.getPrivilegeCallout()}

<EuiFormRow
fullWidth
label={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.privilegeSelectorFormLabel',
{
defaultMessage: 'Define privileges',
}
)}
helpText={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.privilegeSelectorFormHelpText',
{
defaultMessage:
'Assign the privilege level you wish to grant to all present and future features across this space.',
}
)}
>
<EuiButtonGroup
name={`basePrivilegeButtonGroup`}
data-test-subj={`basePrivilegeButtonGroup`}
isFullWidth={true}
color={'primary'}
options={[
{
id: 'basePrivilege_all',
label: 'All',
['data-test-subj']: 'basePrivilege_all',
},
{
id: 'basePrivilege_read',
label: 'Read',
['data-test-subj']: 'basePrivilege_read',
},
{
id: 'basePrivilege_custom',
label: 'Customize',
['data-test-subj']: 'basePrivilege_custom',
},
]}
idSelected={this.getDisplayedBasePrivilege()}
isDisabled={!hasSelectedSpaces}
onChange={this.onSpaceBasePrivilegeChange}
legend={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.basePrivilegeControlLegend',
{
defaultMessage: 'Privileges for all features',
}
)}
/>
</EuiFormRow>

<KibanaPrivilegeTable
role={this.state.role}
privilegeCalculator={this.state.privilegeCalculator}
onChange={this.onFeaturePrivilegesChange}
onChangeAll={this.onChangeAllFeaturePrivileges}
kibanaPrivileges={this.props.kibanaPrivileges}
privilegeIndex={this.state.privilegeIndex}
canCustomizeSubFeaturePrivileges={this.props.canCustomizeSubFeaturePrivileges}
disabled={this.state.selectedBasePrivilege.length > 0 || !hasSelectedSpaces}
allSpacesSelected={this.state.selectedSpaceIds.includes(ALL_SPACES_ID)}
/>
{Boolean(this.state.selectedSpaceIds.length) && (
<>
<EuiFormRow fullWidth>
<EuiCallOut
color="primary"
iconType="iInCircle"
size="s"
title={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.featurePrivilegeSummaryDescription',
{
defaultMessage:
'Some features might be hidden by the space or affected by a global space privilege.',
}
)}
/>
</EuiFormRow>

{this.getPrivilegeCallout()}

<EuiFormRow
fullWidth
label={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.privilegeSelectorFormLabel',
{
defaultMessage: 'Define privileges',
}
)}
helpText={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.privilegeSelectorFormHelpText',
{
defaultMessage:
'Assign the privilege level you wish to grant to all present and future features across this space.',
}
)}
>
<EuiButtonGroup
name={`basePrivilegeButtonGroup`}
data-test-subj={`basePrivilegeButtonGroup`}
isFullWidth={true}
color={'primary'}
options={[
{
id: 'basePrivilege_all',
label: 'All',
['data-test-subj']: 'basePrivilege_all',
},
{
id: 'basePrivilege_read',
label: 'Read',
['data-test-subj']: 'basePrivilege_read',
},
{
id: 'basePrivilege_custom',
label: 'Customize',
['data-test-subj']: 'basePrivilege_custom',
},
]}
idSelected={this.getDisplayedBasePrivilege()}
isDisabled={!hasSelectedSpaces}
onChange={this.onSpaceBasePrivilegeChange}
legend={i18n.translate(
'xpack.security.management.editRole.spacePrivilegeForm.basePrivilegeControlLegend',
{
defaultMessage: 'Privileges for all features',
}
)}
/>
</EuiFormRow>

<KibanaPrivilegeTable
role={this.state.role}
privilegeCalculator={this.state.privilegeCalculator}
onChange={this.onFeaturePrivilegesChange}
onChangeAll={this.onChangeAllFeaturePrivileges}
kibanaPrivileges={this.props.kibanaPrivileges}
privilegeIndex={this.state.privilegeIndex}
canCustomizeSubFeaturePrivileges={this.props.canCustomizeSubFeaturePrivileges}
disabled={this.state.selectedBasePrivilege.length > 0 || !hasSelectedSpaces}
allSpacesSelected={this.state.selectedSpaceIds.includes(ALL_SPACES_ID)}
/>
</>
)}

{this.requiresGlobalPrivilegeWarning() && (
<Fragment>
Expand Down

0 comments on commit 16206f2

Please sign in to comment.