Skip to content

Commit bad3184

Browse files
committed
[Spaces Mgmt] Ensure space ID is used for comparison logic (#196930)
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 (cherry picked from commit a3d216f)
1 parent 18b517a commit bad3184

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ describe('SpacesGridPage', () => {
240240
wrapper.update();
241241

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

@@ -272,7 +272,7 @@ describe('SpacesGridPage', () => {
272272
wrapper.update();
273273

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

x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,15 @@ export class SpacesGridPage extends Component<Props, State> {
428428
reactRouterNavigate(this.props.history, this.getEditSpacePath(rowRecord)).href,
429429
onClick: (rowRecord) =>
430430
reactRouterNavigate(this.props.history, this.getEditSpacePath(rowRecord)).onClick,
431-
'data-test-subj': (rowRecord) => `${rowRecord.name}-editSpace`,
431+
'data-test-subj': (rowRecord) => `${rowRecord.id}-editSpace`,
432432
},
433433
{
434434
isPrimary: true,
435435
name: i18n.translate('xpack.spaces.management.spacesGridPage.switchSpaceActionName', {
436436
defaultMessage: 'Switch',
437437
}),
438438
description: (rowRecord) =>
439-
activeSpace?.name !== rowRecord.name
439+
activeSpace?.id !== rowRecord.id
440440
? i18n.translate(
441441
'xpack.spaces.management.spacesGridPage.switchSpaceActionDescription',
442442
{
@@ -460,8 +460,8 @@ export class SpacesGridPage extends Component<Props, State> {
460460
rowRecord.id,
461461
`${ENTER_SPACE_PATH}?next=/app/management/kibana/spaces/`
462462
),
463-
enabled: (rowRecord) => activeSpace?.name !== rowRecord.name,
464-
'data-test-subj': (rowRecord) => `${rowRecord.name}-switchSpace`,
463+
enabled: (rowRecord) => activeSpace?.id !== rowRecord.id,
464+
'data-test-subj': (rowRecord) => `${rowRecord.id}-switchSpace`,
465465
},
466466
{
467467
name: i18n.translate('xpack.spaces.management.spacesGridPage.deleteActionName', {
@@ -485,7 +485,7 @@ export class SpacesGridPage extends Component<Props, State> {
485485
color: 'danger',
486486
onClick: (rowRecord: Space) => this.onDeleteSpaceClick(rowRecord),
487487
enabled: (rowRecord: Space) => !isReservedSpace(rowRecord),
488-
'data-test-subj': (rowRecord) => `${rowRecord.name}-deleteSpace`,
488+
'data-test-subj': (rowRecord) => `${rowRecord.id}-deleteSpace`,
489489
},
490490
],
491491
});

0 commit comments

Comments
 (0)