Skip to content

Commit

Permalink
[Spaces Mgmt] Ensure space ID is used for comparison logic (#196930)
Browse files Browse the repository at this point in the history
Closes #192811

## Summary

When creating a space, if it's not the current, you should be able to
use the switch icon from the table. This PR fixes a bug that disabled
the switch icon for spaces that aren't the current, if they have the
same name as the current.


### Checklist

Delete any items that are not applicable to this PR.

- [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
  • Loading branch information
tsullivan authored Oct 21, 2024
1 parent e6e4e34 commit a3d216f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe('SpacesGridPage', () => {
wrapper.update();

const activeRow = wrapper.find('[data-test-subj="spacesListTableRow-custom-2"]');
const switchAction = activeRow.find('EuiButtonIcon[data-test-subj="Custom 2-switchSpace"]');
const switchAction = activeRow.find('EuiButtonIcon[data-test-subj="custom-2-switchSpace"]');
expect(switchAction.prop('isDisabled')).toBe(true);
});

Expand Down Expand Up @@ -273,7 +273,7 @@ describe('SpacesGridPage', () => {
wrapper.update();

const nonActiveRow = wrapper.find('[data-test-subj="spacesListTableRow-default"]');
const switchAction = nonActiveRow.find('EuiButtonIcon[data-test-subj="Default-switchSpace"]');
const switchAction = nonActiveRow.find('EuiButtonIcon[data-test-subj="default-switchSpace"]');
expect(switchAction.prop('isDisabled')).toBe(false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ export class SpacesGridPage extends Component<Props, State> {
reactRouterNavigate(this.props.history, this.getEditSpacePath(rowRecord)).href,
onClick: (rowRecord) =>
reactRouterNavigate(this.props.history, this.getEditSpacePath(rowRecord)).onClick,
'data-test-subj': (rowRecord) => `${rowRecord.name}-editSpace`,
'data-test-subj': (rowRecord) => `${rowRecord.id}-editSpace`,
},
{
isPrimary: true,
name: i18n.translate('xpack.spaces.management.spacesGridPage.switchSpaceActionName', {
defaultMessage: 'Switch',
}),
description: (rowRecord) =>
activeSpace?.name !== rowRecord.name
activeSpace?.id !== rowRecord.id
? i18n.translate(
'xpack.spaces.management.spacesGridPage.switchSpaceActionDescription',
{
Expand All @@ -462,8 +462,8 @@ export class SpacesGridPage extends Component<Props, State> {
rowRecord.id,
`${ENTER_SPACE_PATH}?next=/app/management/kibana/spaces/`
),
enabled: (rowRecord) => activeSpace?.name !== rowRecord.name,
'data-test-subj': (rowRecord) => `${rowRecord.name}-switchSpace`,
enabled: (rowRecord) => activeSpace?.id !== rowRecord.id,
'data-test-subj': (rowRecord) => `${rowRecord.id}-switchSpace`,
},
{
name: i18n.translate('xpack.spaces.management.spacesGridPage.deleteActionName', {
Expand All @@ -487,7 +487,7 @@ export class SpacesGridPage extends Component<Props, State> {
color: 'danger',
onClick: (rowRecord: Space) => this.onDeleteSpaceClick(rowRecord),
enabled: (rowRecord: Space) => !isReservedSpace(rowRecord),
'data-test-subj': (rowRecord) => `${rowRecord.name}-deleteSpace`,
'data-test-subj': (rowRecord) => `${rowRecord.id}-deleteSpace`,
},
],
});
Expand Down

0 comments on commit a3d216f

Please sign in to comment.