mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Hides Spaces actions in serverless saved objects management (#169457)
Closes #169424 ## Summary Adds check against `SpacesApi.hasOnlyDefaultSpace` to, when true, bypass registering the `share-to-space` and `copy-to-space` actions and the `Spaces` column in the saved objects management UI. ### Manual Testing - Start Elasticsearch with `yarn es serverless` - Start Kibana with `yarn start --serverless security` - Navigate to `Project Settings`->`Management`->`Content` -> `Saved Objects` - Verify that the `Spaces` column does not appear in the Saved Objects table - Verify that the `Actions` column does not contain either the `Copy-to-space` or `Share-to-space` actions for any object (will still contain `Inspect` and `View relationships`) - Stop Kibana and Elasticsearch - Start Elasticsearch with `yarn es snapshot --license=trial` - Start Kibana with `yarn start` - Add sample flight data to generate some saved objects - Navigate to `Stack Management`->`Kibana`->`Saved Objects` - Verify that the `Spaces` column does appear in the Saved Objects table - Verify that the `Actions` column does contain both the `Copy-to-space` or `Share-to-space` actions for applicable object types (e.g. data views) ### Automated Testing - src/plugins/saved_objects_management/public/services/action_service.test.ts - src/plugins/saved_objects_management/public/services/column_service.test.ts --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4d1618ef41
commit
38ca94f8b7
5 changed files with 28 additions and 5 deletions
|
@ -64,6 +64,18 @@ describe('SavedObjectsManagementActionRegistry', () => {
|
|||
`"Saved Objects Management Action with id 'my-action' already exists"`
|
||||
);
|
||||
});
|
||||
|
||||
it('does not register spaces share and copy actions when SpacesApi.hasOnlyDefaultSpace is true', () => {
|
||||
const action = createAction('foo');
|
||||
setup.register(action);
|
||||
const start = service.start(spacesPluginMock.createStartContract(true));
|
||||
expect(start.getAll()).toEqual(
|
||||
expect.not.arrayContaining([
|
||||
expect.any(ShareToSpaceSavedObjectsManagementAction),
|
||||
expect.any(CopyToSpaceSavedObjectsManagementAction),
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#has', () => {
|
||||
|
|
|
@ -46,7 +46,7 @@ export class SavedObjectsManagementActionService {
|
|||
}
|
||||
|
||||
start(spacesApi?: SpacesApi): SavedObjectsManagementActionServiceStart {
|
||||
if (spacesApi) {
|
||||
if (spacesApi && !spacesApi.hasOnlyDefaultSpace) {
|
||||
registerSpacesApiActions(this, spacesApi);
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -58,5 +58,14 @@ describe('SavedObjectsManagementColumnRegistry', () => {
|
|||
`"Saved Objects Management Column with id 'my-column' already exists"`
|
||||
);
|
||||
});
|
||||
|
||||
it('does not register space column when SpacesApi.hasOnlyDefaultSpace is true', () => {
|
||||
const column = createColumn('foo');
|
||||
setup.register(column);
|
||||
const start = service.start(spacesPluginMock.createStartContract(true));
|
||||
expect(start.getAll()).toEqual(
|
||||
expect.not.arrayContaining([expect.any(ShareToSpaceSavedObjectsManagementColumn)])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ export class SavedObjectsManagementColumnService {
|
|||
}
|
||||
|
||||
start(spacesApi?: SpacesApi): SavedObjectsManagementColumnServiceStart {
|
||||
if (spacesApi) {
|
||||
if (spacesApi && !spacesApi.hasOnlyDefaultSpace) {
|
||||
registerSpacesApiColumns(this, spacesApi);
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -11,11 +11,11 @@ import type { SpacesPluginStart } from './plugin';
|
|||
import type { SpacesApi } from './types';
|
||||
import type { SpacesApiUi, SpacesApiUiComponent } from './ui_api';
|
||||
|
||||
const createApiMock = (): jest.Mocked<SpacesApi> => ({
|
||||
const createApiMock = (hasOnlyDefaultSpace: boolean): jest.Mocked<SpacesApi> => ({
|
||||
getActiveSpace$: jest.fn().mockReturnValue(of()),
|
||||
getActiveSpace: jest.fn(),
|
||||
ui: createApiUiMock(),
|
||||
hasOnlyDefaultSpace: false,
|
||||
hasOnlyDefaultSpace,
|
||||
});
|
||||
|
||||
type SpacesApiUiMock = Omit<jest.Mocked<SpacesApiUi>, 'components'> & {
|
||||
|
@ -48,7 +48,9 @@ const createApiUiComponentsMock = () => {
|
|||
return mock;
|
||||
};
|
||||
|
||||
const createStartContract = (): jest.Mocked<SpacesPluginStart> => createApiMock();
|
||||
const createStartContract = (
|
||||
hasOnlyDefaultSpace: boolean = false
|
||||
): jest.Mocked<SpacesPluginStart> => createApiMock(hasOnlyDefaultSpace);
|
||||
|
||||
export const spacesPluginMock = {
|
||||
createStartContract,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue