Skip to content

Commit

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

Closes elastic/kibana-team#1323

## Screenshots

**Before**


https://github.com/user-attachments/assets/a7eed859-7e81-44b2-86ec-6fa542983960

**After**


https://github.com/user-attachments/assets/58c2b576-4d4a-4869-8252-edd327ae7062

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
tsullivan committed Jan 3, 2025
1 parent f2cf02b commit 0b2069b
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 0b2069b

Please sign in to comment.