Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spaces] UX improvements to spaces grid #188261

Merged
merged 19 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/spaces/images/space-management.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ featuresStart.getFeatures.mockResolvedValue([
}),
]);

const spacesGridCommonProps = {
serverBasePath: '',
maxSpaces: 1000,
};

describe('SpacesGridPage', () => {
const getUrlForApp = (appId: string) => appId;
const history = scopedHistoryMock.create();
Expand All @@ -79,7 +84,7 @@ describe('SpacesGridPage', () => {
catalogue: {},
spaces: { manage: true },
}}
maxSpaces={1000}
{...spacesGridCommonProps}
/>
);

Expand Down Expand Up @@ -138,8 +143,8 @@ describe('SpacesGridPage', () => {
catalogue: {},
spaces: { manage: true },
}}
maxSpaces={1000}
solutionNavExperiment={Promise.resolve(true)}
{...spacesGridCommonProps}
/>
);

Expand All @@ -156,6 +161,103 @@ describe('SpacesGridPage', () => {
});
});

it('renders a "current" badge for the current space', async () => {
spacesManager.getActiveSpace.mockResolvedValue(spaces[2]);
const current = await spacesManager.getActiveSpace();
expect(current.id).toBe('custom-2');

const wrapper = mountWithIntl(
<SpacesGridPage
spacesManager={spacesManager as unknown as SpacesManager}
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
getUrlForApp={getUrlForApp}
history={history}
capabilities={{
navLinks: {},
management: {},
catalogue: {},
spaces: { manage: true },
}}
solutionNavExperiment={Promise.resolve(true)}
{...spacesGridCommonProps}
/>
);

// allow spacesManager to load spaces and lazy-load SpaceAvatar
await act(async () => {});
wrapper.update();

const activeRow = wrapper.find('[data-test-subj="spacesListTableRow-custom-2"]');
const nameCell = activeRow.find('[data-test-subj="spacesListTableRowNameCell"]');
const activeBadge = nameCell.find('EuiBadge');
expect(activeBadge.text()).toBe('current');
});

it('renders a non-clickable "switch" action for the current space', async () => {
spacesManager.getActiveSpace.mockResolvedValue(spaces[2]);
const current = await spacesManager.getActiveSpace();
expect(current.id).toBe('custom-2');

const wrapper = mountWithIntl(
<SpacesGridPage
spacesManager={spacesManager as unknown as SpacesManager}
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
getUrlForApp={getUrlForApp}
history={history}
capabilities={{
navLinks: {},
management: {},
catalogue: {},
spaces: { manage: true },
}}
solutionNavExperiment={Promise.resolve(true)}
{...spacesGridCommonProps}
/>
);

// allow spacesManager to load spaces and lazy-load SpaceAvatar
await act(async () => {});
wrapper.update();

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

it('renders a clickable "switch" action for the non-current space', async () => {
spacesManager.getActiveSpace.mockResolvedValue(spaces[2]);
const current = await spacesManager.getActiveSpace();
expect(current.id).toBe('custom-2');

const wrapper = mountWithIntl(
<SpacesGridPage
spacesManager={spacesManager as unknown as SpacesManager}
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
getUrlForApp={getUrlForApp}
history={history}
capabilities={{
navLinks: {},
management: {},
catalogue: {},
spaces: { manage: true },
}}
solutionNavExperiment={Promise.resolve(true)}
{...spacesGridCommonProps}
/>
);

// allow spacesManager to load spaces and lazy-load SpaceAvatar
await act(async () => {});
wrapper.update();

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

it('renders a create spaces button', async () => {
const httpStart = httpServiceMock.createStartContract();
httpStart.get.mockResolvedValue([]);
Expand All @@ -173,7 +275,7 @@ describe('SpacesGridPage', () => {
catalogue: {},
spaces: { manage: true },
}}
maxSpaces={1000}
{...spacesGridCommonProps}
/>
);

Expand Down Expand Up @@ -203,6 +305,7 @@ describe('SpacesGridPage', () => {
spaces: { manage: true },
}}
maxSpaces={1}
serverBasePath={spacesGridCommonProps.serverBasePath}
/>
);

Expand Down Expand Up @@ -236,7 +339,7 @@ describe('SpacesGridPage', () => {
catalogue: {},
spaces: { manage: true },
}}
maxSpaces={1000}
{...spacesGridCommonProps}
/>
);

Expand Down Expand Up @@ -271,7 +374,7 @@ describe('SpacesGridPage', () => {
catalogue: {},
spaces: { manage: true },
}}
maxSpaces={1000}
{...spacesGridCommonProps}
/>
);

Expand Down
Loading