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

Removes visible features column from spaces grid when in serverless #194438

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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('ManagementService', () => {
getRolesAPIClient: getRolesAPIClientMock,
getPrivilegesAPIClient: jest.fn(),
eventTracker,
isServerless: false,
});

expect(mockKibanaSection.registerApp).toHaveBeenCalledTimes(1);
Expand All @@ -73,6 +74,7 @@ describe('ManagementService', () => {
getRolesAPIClient: getRolesAPIClientMock,
getPrivilegesAPIClient: jest.fn(),
eventTracker,
isServerless: false,
});
});
});
Expand All @@ -97,6 +99,7 @@ describe('ManagementService', () => {
getRolesAPIClient: jest.fn(),
getPrivilegesAPIClient: jest.fn(),
eventTracker,
isServerless: false,
});

service.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface SetupDeps {
eventTracker: EventTracker;
getPrivilegesAPIClient: () => Promise<PrivilegesAPIClientPublicContract>;
logger: Logger;
isServerless: boolean;
}

export class ManagementService {
Expand All @@ -42,6 +43,7 @@ export class ManagementService {
getRolesAPIClient,
eventTracker,
getPrivilegesAPIClient,
isServerless,
}: SetupDeps) {
this.registeredSpacesManagementApp = management.sections.section.kibana.registerApp(
spacesManagementApp.create({
Expand All @@ -52,6 +54,7 @@ export class ManagementService {
getRolesAPIClient,
eventTracker,
getPrivilegesAPIClient,
isServerless,
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ featuresStart.getFeatures.mockResolvedValue([
const spacesGridCommonProps = {
serverBasePath: '',
maxSpaces: 1000,
isServerless: false,
};

describe('SpacesGridPage', () => {
Expand Down Expand Up @@ -326,6 +327,7 @@ describe('SpacesGridPage', () => {
maxSpaces={1}
allowSolutionVisibility
serverBasePath={spacesGridCommonProps.serverBasePath}
isServerless={false}
/>
);

Expand Down Expand Up @@ -410,4 +412,81 @@ describe('SpacesGridPage', () => {
title: 'Error loading spaces',
});
});

it(`renders the 'Features visible' column when not serverless`, async () => {
const httpStart = httpServiceMock.createStartContract();
httpStart.get.mockResolvedValue([]);

const error = new Error('something awful happened');

const notifications = notificationServiceMock.createStartContract();

const wrapper = shallowWithIntl(
<SpacesGridPage
spacesManager={spacesManager}
getFeatures={() => Promise.reject(error)}
notifications={notifications}
getUrlForApp={getUrlForApp}
history={history}
capabilities={{
navLinks: {},
management: {},
catalogue: {},
spaces: { manage: true },
}}
allowSolutionVisibility
{...spacesGridCommonProps}
/>
);

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

expect(wrapper.find('EuiInMemoryTable').prop('columns')).toContainEqual(
expect.objectContaining({
field: 'disabledFeatures',
name: 'Features visible',
})
);
});

it(`does not render the 'Features visible' column when serverless`, async () => {
const httpStart = httpServiceMock.createStartContract();
httpStart.get.mockResolvedValue([]);

const error = new Error('something awful happened');

const notifications = notificationServiceMock.createStartContract();

const wrapper = shallowWithIntl(
<SpacesGridPage
spacesManager={spacesManager}
getFeatures={() => Promise.reject(error)}
notifications={notifications}
getUrlForApp={getUrlForApp}
history={history}
capabilities={{
navLinks: {},
management: {},
catalogue: {},
spaces: { manage: true },
}}
allowSolutionVisibility
{...spacesGridCommonProps}
isServerless={true}
/>
);

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

expect(wrapper.find('EuiInMemoryTable').prop('columns')).not.toContainEqual(
expect.objectContaining({
field: 'disabledFeatures',
name: 'Features visible',
})
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ interface Props {
getUrlForApp: ApplicationStart['getUrlForApp'];
maxSpaces: number;
allowSolutionVisibility: boolean;
isServerless: boolean;
}

interface State {
Expand Down Expand Up @@ -335,7 +336,8 @@ export class SpacesGridPage extends Component<Props, State> {
},
];

const shouldShowFeaturesColumn = !activeSolution || activeSolution === SOLUTION_VIEW_CLASSIC;
const shouldShowFeaturesColumn =
!this.props.isServerless && (!activeSolution || activeSolution === SOLUTION_VIEW_CLASSIC);
if (shouldShowFeaturesColumn) {
config.push({
field: 'disabledFeatures',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async function mountApp(basePath: string, pathname: string, spaceId?: string) {
getRolesAPIClient: jest.fn(),
getPrivilegesAPIClient: jest.fn(),
eventTracker,
isServerless: false,
})
.mount({
basePath,
Expand All @@ -102,6 +103,7 @@ describe('spacesManagementApp', () => {
getRolesAPIClient: jest.fn(),
getPrivilegesAPIClient: jest.fn(),
eventTracker,
isServerless: false,
})
).toMatchInlineSnapshot(`
Object {
Expand All @@ -126,7 +128,7 @@ describe('spacesManagementApp', () => {
css="You have tried to stringify object returned from \`css\` function. It isn't supposed to be used directly (e.g. as value of the \`className\` prop), but rather handed to emotion so it can handle it (e.g. as value of \`css\` prop)."
data-test-subj="kbnRedirectAppLink"
>
Spaces Page: {"capabilities":{"catalogue":{},"management":{},"navLinks":{}},"notifications":{"toasts":{}},"spacesManager":{"onActiveSpaceChange$":{}},"serverBasePath":"","history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"maxSpaces":1000,"allowSolutionVisibility":true}
Spaces Page: {"capabilities":{"catalogue":{},"management":{},"navLinks":{}},"notifications":{"toasts":{}},"spacesManager":{"onActiveSpaceChange$":{}},"serverBasePath":"","history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"maxSpaces":1000,"allowSolutionVisibility":true,"isServerless":false}
</div>
</div>
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface CreateParams {
getRolesAPIClient: () => Promise<RolesAPIClient>;
eventTracker: EventTracker;
getPrivilegesAPIClient: () => Promise<PrivilegesAPIClientPublicContract>;
isServerless: boolean;
}

export const spacesManagementApp = Object.freeze({
Expand All @@ -48,6 +49,7 @@ export const spacesManagementApp = Object.freeze({
eventTracker,
getRolesAPIClient,
getPrivilegesAPIClient,
isServerless,
}: CreateParams) {
const title = i18n.translate('xpack.spaces.displayName', {
defaultMessage: 'Spaces',
Expand Down Expand Up @@ -92,6 +94,7 @@ export const spacesManagementApp = Object.freeze({
getUrlForApp={application.getUrlForApp}
maxSpaces={config.maxSpaces}
allowSolutionVisibility={config.allowSolutionVisibility}
isServerless={isServerless}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/spaces/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class SpacesPlugin implements Plugin<SpacesPluginSetup, SpacesPluginStart
getRolesAPIClient,
eventTracker: this.eventTracker,
getPrivilegesAPIClient,
isServerless: this.isServerless,
});
}

Expand Down