Skip to content

Commit

Permalink
Use EuiIconTip for lock icon in privileges table action (#205436) (#2…
Browse files Browse the repository at this point in the history
…05528)

This is a manual backport to 8.x for
#205436
  • Loading branch information
tsullivan authored Jan 3, 2025
1 parent f2e63da commit e074de7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ describe('SpaceAssignedRolesTable', () => {
expect(screen.getByTestId('checkboxSelectAll')).toBeInTheDocument();
});

// it('will not render the bulk actions context menu when the table is in readOnly mode', () => {})

it('prevents modification of reserved roles', () => {
renderTestComponent({
assignedRoles: spaceAssignedRoles,
Expand All @@ -134,8 +132,7 @@ describe('SpaceAssignedRolesTable', () => {

expect(trisolarisRow).toBeInTheDocument();

// We expect a length of 2 because EUI also adds a second node for screen readers
expect(within(trisolarisRow).getAllByText('Reserved')).toHaveLength(2);
expect(within(trisolarisRow).getAllByText('Reserved')).toHaveLength(1);
expect(within(trisolarisRow).getByTestId('spaceRoleCellActionLocked')).toBeInTheDocument();
expect(within(trisolarisRow).getByTestId('spaceRoleCellActionLocked')).toBeDisabled();
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EuiBadge,
EuiButton,
EuiButtonEmpty,
EuiButtonIcon,
EuiContextMenu,
EuiFlexGroup,
EuiFlexItem,
Expand All @@ -18,6 +19,7 @@ import {
EuiPopover,
EuiText,
EuiTextColor,
EuiToolTip,
} from '@elastic/eui';
import type {
CriteriaWithPagination,
Expand Down Expand Up @@ -140,33 +142,43 @@ const getTableColumns = ({
),
actions: [
{
type: 'icon',
icon: 'lock',
href: '#',
target: '_self',
'data-test-subj': 'spaceRoleCellActionLocked',
name: (role) =>
isRoleReserved(role)
? i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableTitle.isReserved',
{ defaultMessage: 'Reserved' }
)
: i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableTitle.isAssignedToAll',
{ defaultMessage: 'Assigned to all spaces' }
),
description: (role) =>
isRoleReserved(role)
? i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableDescription.isReserved',
{ defaultMessage: `You can’t edit the access of reserved roles to this space.` }
)
: i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableDescription.isAssignedToAll',
{
defaultMessage: `You can't edit the access of a role that is assigned to all spaces.`,
render: (role) => {
return (
<EuiToolTip
content={
isRoleReserved(role)
? i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableDescription.isReserved',
{ defaultMessage: 'This role is reserved.' }
)
: i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableDescription.isAssignedToAll',
{
defaultMessage:
'This role is assigned to all spaces. To change this, go to Roles.',
}
)
}
>
<EuiButtonIcon
iconType="lock"
disabled={true}
data-test-subj="spaceRoleCellActionLocked"
aria-label={
isRoleReserved(role)
? i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableTitle.isReserved',
{ defaultMessage: 'Reserved' }
)
: i18n.translate(
'xpack.spaces.management.spaceDetails.rolesTable.column.actions.notEditableTitle.isAssignedToAll',
{ defaultMessage: 'Assigned to all spaces' }
)
}
),
/>
</EuiToolTip>
);
},
showOnHover: true,
enabled: () => false,
available: (rowRecord) => !isEditableRole(rowRecord),
Expand Down

0 comments on commit e074de7

Please sign in to comment.