diff --git a/src/legacy/core_plugins/kibana/index.js b/src/legacy/core_plugins/kibana/index.js index d2bab2a5df907..64a8f4eec1199 100644 --- a/src/legacy/core_plugins/kibana/index.js +++ b/src/legacy/core_plugins/kibana/index.js @@ -240,9 +240,7 @@ export default function (kibana) { migrations, }, - uiCapabilities: async function (server) { - const { savedObjects } = server; - + uiCapabilities: async function () { return { discover: { show: true, @@ -275,14 +273,11 @@ export default function (kibana) { indexPatterns: { save: true, }, - savedObjectsManagement: savedObjects.types.reduce((acc, type) => ({ - ...acc, - [type]: { - delete: true, - edit: true, - read: true, - } - }), {}), + savedObjectsManagement: { + delete: true, + edit: true, + read: true, + }, management: { /* * Management settings correspond to management section/link ids, and should not be changed diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/_view.js b/src/legacy/core_plugins/kibana/public/management/sections/objects/_view.js index 5d981b1c48ec0..8e432cb91cc6e 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/_view.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/_view.js @@ -139,7 +139,7 @@ uiModules.get('apps/management', ['monospaced.elastic']) } }; - const { edit: canEdit, delete: canDelete } = uiCapabilities.savedObjectsManagement[service.type]; + const { edit: canEdit, delete: canDelete } = uiCapabilities.savedObjectsManagement; $scope.canEdit = canEdit; $scope.canDelete = canDelete; $scope.canViewInApp = canViewInApp(uiCapabilities, service.type); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap index a34c598ee5b30..9dbfc9866536b 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap @@ -257,7 +257,7 @@ exports[`ObjectsTable should render normally 1`] = ` size="xs" /> { @@ -272,41 +258,6 @@ describe('ObjectsTable', () => { expect(addDangerMock).toHaveBeenCalled(); }); - it('should filter find operation based on the uiCapabilities', async () => { - const uiCapabilities = { - savedObjectsManagement: { - 'index-pattern': { - read: false, - }, - visualization: { - read: false, - }, - dashboard: { - read: false, - }, - search: { - read: true, - } - } - }; - const customizedProps = { ...defaultProps, uiCapabilities }; - const component = shallowWithIntl( - - ); - - // Ensure all promises resolve - await new Promise(resolve => process.nextTick(resolve)); - // Ensure the state changes are reflected - component.update(); - - expect(findObjects).toHaveBeenCalledWith(expect.objectContaining({ - type: ['search'] - })); - }); - describe('export', () => { it('should export selected objects', async () => { const mockSelectedSavedObjects = [ @@ -452,42 +403,6 @@ describe('ObjectsTable', () => { expect(getRelationships).toHaveBeenCalledWith('search', '1', savedObjectTypes, defaultProps.$http, defaultProps.basePath); }); - it('should fetch relationships filtered based on the uiCapabilities', async () => { - const { getRelationships } = require('../../../lib/get_relationships'); - - const uiCapabilities = { - savedObjectsManagement: { - 'index-pattern': { - read: false, - }, - visualization: { - read: false, - }, - dashboard: { - read: false, - }, - search: { - read: true, - } - } - }; - const customizedProps = { ...defaultProps, uiCapabilities }; - const component = shallowWithIntl( - - ); - - // Ensure all promises resolve - await new Promise(resolve => process.nextTick(resolve)); - // Ensure the state changes are reflected - component.update(); - - await component.instance().getRelationships('search', '1'); - const savedObjectTypes = ['search']; - expect(getRelationships).toHaveBeenCalledWith('search', '1', savedObjectTypes, defaultProps.$http, defaultProps.basePath); - }); - it('should show the flyout', async () => { const component = shallowWithIntl( {}, isSearching: false, onShowRelationships: () => {}, - canDeleteSavedObjectTypes: ['visualization'] + canDelete: true }; describe('Table', () => { @@ -127,9 +127,9 @@ describe('Table', () => { expect(component.state().isSearchTextValid).toBe(true); }); - it(`restricts which saved objects can be deleted based on type`, () => { + it(`prevents saved objects from being deleted`, () => { const selectedSavedObjects = [{ type: 'visualization' }, { type: 'search' }, { type: 'index-pattern' }]; - const customizedProps = { ...defaultProps, selectedSavedObjects, canDeleteSavedObjectTypes: ['visualization'] }; + const customizedProps = { ...defaultProps, selectedSavedObjects, canDelete: false }; const component = shallowWithIntl( type) - .filter(type => !this.props.canDeleteSavedObjectTypes.includes(type)); - const button = ( 0 + !this.props.canDelete } title={ - unableToDeleteSavedObjectTypes.length > 0 ? `Unable to delete ${unableToDeleteSavedObjectTypes.join(', ')}` : undefined + this.props.canDelete + ? undefined + : i18n.translate( + 'kbn.management.objects.objectsTable.table.deleteButtonTitle', + { defaultMessage: 'Unable to delete saved objects' } + ) } data-test-subj="savedObjectsManagementDelete" > diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/objects_table.js b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/objects_table.js index b1e98e50c05fa..9c1f1a84e1bb6 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/objects_table.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/objects_table.js @@ -82,9 +82,7 @@ class ObjectsTableUI extends Component { constructor(props) { super(props); - this.savedObjectTypes = POSSIBLE_TYPES.filter(type => { - return this.props.uiCapabilities.savedObjectsManagement[type].read; - }); + this.savedObjectTypes = POSSIBLE_TYPES; this.state = { totalCount: 0, @@ -677,10 +675,6 @@ class ObjectsTableUI extends Component { view: `${type} (${savedObjectCounts[type] || 0})`, })); - const canDeleteSavedObjectTypes = POSSIBLE_TYPES.filter(type => { - return this.props.uiCapabilities.savedObjectsManagement[type].delete; - }); - return ( [ - this.actions.ui.get('savedObjectsManagement', type, 'delete'), - this.actions.ui.get('savedObjectsManagement', type, 'edit'), - this.actions.ui.get('savedObjectsManagement', type, 'read'), - ]) - ), - ...privilegeDefinition.savedObject.read.map(type => - this.actions.ui.get('savedObjectsManagement', type, 'read') - ), - ]); - } -} diff --git a/x-pack/plugins/security/server/lib/authorization/privileges/privileges.test.ts b/x-pack/plugins/security/server/lib/authorization/privileges/privileges.test.ts index e18b9ecdf6fe3..3bd3f53fce531 100644 --- a/x-pack/plugins/security/server/lib/authorization/privileges/privileges.test.ts +++ b/x-pack/plugins/security/server/lib/authorization/privileges/privileges.test.ts @@ -622,90 +622,6 @@ describe('features', () => { }); }); -describe('savedObjectsManagement feature', () => { - test(`saved objects privileges create 'savedObjectsManagement' actions`, () => { - const features: Feature[] = [ - { - id: 'savedObjectsManagement', - name: 'Saved Objects Management', - icon: 'arrowDown', - app: [], - catalogue: [], - management: {}, - privileges: { - all: { - ui: [], - savedObject: { - all: ['all-savedObject-all-1'], - read: ['all-savedObject-read-1'], - }, - }, - read: { - ui: [], - savedObject: { - all: ['read-savedObject-all-1'], - read: ['read-savedObject-read-1'], - }, - }, - }, - }, - ]; - - const mockXPackMainPlugin = { - getFeatures: jest.fn().mockReturnValue(features), - }; - - const privileges = privilegesFactory(actions, mockXPackMainPlugin as any); - - const actual = privileges.get(); - expect(actual).toHaveProperty('features.savedObjectsManagement.all', [ - actions.login, - actions.version, - actions.savedObject.get('all-savedObject-all-1', 'bulk_get'), - actions.savedObject.get('all-savedObject-all-1', 'get'), - actions.savedObject.get('all-savedObject-all-1', 'find'), - actions.savedObject.get('all-savedObject-all-1', 'create'), - actions.savedObject.get('all-savedObject-all-1', 'bulk_create'), - actions.savedObject.get('all-savedObject-all-1', 'update'), - actions.savedObject.get('all-savedObject-all-1', 'delete'), - - actions.savedObject.get('all-savedObject-read-1', 'bulk_get'), - actions.savedObject.get('all-savedObject-read-1', 'get'), - actions.savedObject.get('all-savedObject-read-1', 'find'), - - actions.ui.get('savedObjectsManagement', 'all-savedObject-all-1', 'delete'), - actions.ui.get('savedObjectsManagement', 'all-savedObject-all-1', 'edit'), - actions.ui.get('savedObjectsManagement', 'all-savedObject-all-1', 'read'), - - actions.ui.get('savedObjectsManagement', 'all-savedObject-read-1', 'read'), - - actions.allHack, - ]); - - expect(actual).toHaveProperty('features.savedObjectsManagement.read', [ - actions.login, - actions.version, - actions.savedObject.get('read-savedObject-all-1', 'bulk_get'), - actions.savedObject.get('read-savedObject-all-1', 'get'), - actions.savedObject.get('read-savedObject-all-1', 'find'), - actions.savedObject.get('read-savedObject-all-1', 'create'), - actions.savedObject.get('read-savedObject-all-1', 'bulk_create'), - actions.savedObject.get('read-savedObject-all-1', 'update'), - actions.savedObject.get('read-savedObject-all-1', 'delete'), - - actions.savedObject.get('read-savedObject-read-1', 'bulk_get'), - actions.savedObject.get('read-savedObject-read-1', 'get'), - actions.savedObject.get('read-savedObject-read-1', 'find'), - - actions.ui.get('savedObjectsManagement', 'read-savedObject-all-1', 'delete'), - actions.ui.get('savedObjectsManagement', 'read-savedObject-all-1', 'edit'), - actions.ui.get('savedObjectsManagement', 'read-savedObject-all-1', 'read'), - - actions.ui.get('savedObjectsManagement', 'read-savedObject-read-1', 'read'), - ]); - }); -}); - describe('reserved', () => { test('actions defined at the feature cascade to the privileges', () => { const features: Feature[] = [ diff --git a/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts index 0a2368b07dcaa..4cec018959ab3 100644 --- a/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts +++ b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts @@ -60,21 +60,6 @@ function toggleDisabledFeatures( }); }); - // TODO: Revisit if/when savedObjectsManagement UI Capabilities are refactored - if (feature.id === 'savedObjectsManagement') { - const capability: Record> = uiCapabilities[ - feature.id - ] as Record>; - - Object.keys(capability).forEach(savedObjectType => { - Object.keys(capability[savedObjectType]).forEach(typeCapability => { - capability[savedObjectType][typeCapability] = false; - }); - }); - - continue; - } - // Disable "sub features" that match the disabled feature if (uiCapabilities.hasOwnProperty(feature.id)) { const capability = uiCapabilities[feature.id]; diff --git a/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts b/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts index 151732e4b1d57..d55db153cce14 100644 --- a/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts +++ b/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts @@ -206,14 +206,14 @@ const buildKibanaFeatures = (savedObjectTypes: string[]) => { all: [...savedObjectTypes], read: [], }, - ui: [], + ui: ['read', 'edit', 'delete'], }, read: { savedObject: { all: [], read: [...savedObjectTypes], }, - ui: [], + ui: ['read'], }, }, }, diff --git a/x-pack/test/ui_capabilities/common/saved_objects_management_builder.ts b/x-pack/test/ui_capabilities/common/saved_objects_management_builder.ts deleted file mode 100644 index 3beae32d5f93b..0000000000000 --- a/x-pack/test/ui_capabilities/common/saved_objects_management_builder.ts +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable max-classes-per-file */ -class SavedObjectsTypeUICapabilitiesGroup { - public all = ['delete', 'edit', 'read']; - public read = ['read']; - public none = [] as string[]; -} -const savedObjectsTypeUICapabilitiesGroup = new SavedObjectsTypeUICapabilitiesGroup(); - -interface OnlyParameters { - all?: string | string[]; - read?: string | string[]; -} - -const coerceToArray = (itemOrItemsOrNil: T | T[] | undefined): T[] => { - if (itemOrItemsOrNil == null) { - return []; - } - - return Array.isArray(itemOrItemsOrNil) ? itemOrItemsOrNil : [itemOrItemsOrNil]; -}; - -export class SavedObjectsManagementBuilder { - private allSavedObjectTypes: string[]; - - constructor(spacesEnabled: boolean) { - this.allSavedObjectTypes = [ - ...(spacesEnabled ? ['space'] : []), - 'config', - 'telemetry', - 'graph-workspace', - 'ml-telemetry', - 'apm-telemetry', - 'map', - 'maps-telemetry', - 'canvas-workpad', - 'canvas-element', - 'infrastructure-ui-source', - 'upgrade-assistant-reindex-operation', - 'upgrade-assistant-telemetry', - 'index-pattern', - 'visualization', - 'search', - 'dashboard', - 'url', - 'server', - 'kql-telemetry', - 'timelion-sheet', - 'ui-metric', - 'sample-data-telemetry', - 'siem-ui-timeline', - 'siem-ui-timeline-note', - 'siem-ui-timeline-pinned-event', - ]; - } - - public uiCapabilities(group: keyof SavedObjectsTypeUICapabilitiesGroup) { - return savedObjectsTypeUICapabilitiesGroup.all.reduce( - (acc2, uiCapability) => ({ - ...acc2, - [uiCapability]: savedObjectsTypeUICapabilitiesGroup[group].includes(uiCapability), - }), - {} - ); - } - - public build(parameters: OnlyParameters): Record { - const readTypes = coerceToArray(parameters.read); - const allTypes = coerceToArray(parameters.all); - return this.allSavedObjectTypes.reduce( - (acc, savedObjectType) => ({ - ...acc, - [savedObjectType]: savedObjectsTypeUICapabilitiesGroup.all.reduce( - (acc2, uiCapability) => ({ - ...acc2, - [uiCapability]: - (readTypes.includes(savedObjectType) && - savedObjectsTypeUICapabilitiesGroup.read.includes(uiCapability)) || - (allTypes.includes(savedObjectType) && - savedObjectsTypeUICapabilitiesGroup.all.includes(uiCapability)), - }), - {} - ), - }), - {} - ); - } -} diff --git a/x-pack/test/ui_capabilities/security_and_spaces/tests/index.ts b/x-pack/test/ui_capabilities/security_and_spaces/tests/index.ts index f3878534b2ac8..0ba3cba6fbc50 100644 --- a/x-pack/test/ui_capabilities/security_and_spaces/tests/index.ts +++ b/x-pack/test/ui_capabilities/security_and_spaces/tests/index.ts @@ -73,6 +73,5 @@ export default function uiCapabilitiesTests({ loadTestFile(require.resolve('./catalogue')); loadTestFile(require.resolve('./foo')); loadTestFile(require.resolve('./nav_links')); - loadTestFile(require.resolve('./saved_objects_management')); }); } diff --git a/x-pack/test/ui_capabilities/security_and_spaces/tests/saved_objects_management.ts b/x-pack/test/ui_capabilities/security_and_spaces/tests/saved_objects_management.ts deleted file mode 100644 index 915b781eb6a03..0000000000000 --- a/x-pack/test/ui_capabilities/security_and_spaces/tests/saved_objects_management.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import expect from '@kbn/expect'; -import { mapValues } from 'lodash'; -import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers'; -import { SavedObjectsManagementBuilder } from '../../common/saved_objects_management_builder'; -import { - UICapabilitiesService, - GetUICapabilitiesFailureReason, -} from '../../common/services/ui_capabilities'; -import { UserAtSpaceScenarios } from '../scenarios'; - -const savedObjectsManagementBuilder = new SavedObjectsManagementBuilder(true); - -// eslint-disable-next-line import/no-default-export -export default function savedObjectsManagementTests({ - getService, -}: KibanaFunctionalTestDefaultProviders) { - const uiCapabilitiesService: UICapabilitiesService = getService('uiCapabilities'); - - describe('savedObjectsManagement', () => { - UserAtSpaceScenarios.forEach(scenario => { - it(`${scenario.id}`, async () => { - const { user, space } = scenario; - - const uiCapabilities = await uiCapabilitiesService.get({ - credentials: { username: user.username, password: user.password }, - spaceId: space.id, - }); - switch (scenario.id) { - case 'superuser at everything_space': - case 'global_all at everything_space': - case 'dual_privileges_all at everything_space': - case 'everything_space_all at everything_space': - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - const expected = mapValues(uiCapabilities.value!.savedObjectsManagement, () => - savedObjectsManagementBuilder.uiCapabilities('all') - ); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql(expected); - break; - - case 'dual_privileges_read at everything_space': - case 'global_read at everything_space': - case 'everything_space_read at everything_space': - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - const readExpected = mapValues(uiCapabilities.value!.savedObjectsManagement, () => - savedObjectsManagementBuilder.uiCapabilities('read') - ); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql(readExpected); - break; - - case 'superuser at nothing_space': - case 'nothing_space_all at nothing_space': - case 'nothing_space_read at nothing_space': - case 'global_all at nothing_space': - case 'global_read at nothing_space': - case 'dual_privileges_all at nothing_space': - case 'dual_privileges_read at nothing_space': - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - const noneExpected = mapValues(uiCapabilities.value!.savedObjectsManagement, () => - savedObjectsManagementBuilder.uiCapabilities('none') - ); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql(noneExpected); - break; - case 'no_kibana_privileges at everything_space': - case 'no_kibana_privileges at nothing_space': - case 'legacy_all at everything_space': - case 'legacy_all at nothing_space': - case 'everything_space_all at nothing_space': - case 'everything_space_read at nothing_space': - case 'nothing_space_all at everything_space': - case 'nothing_space_read at everything_space': - expect(uiCapabilities.success).to.be(false); - expect(uiCapabilities.failureReason).to.be( - GetUICapabilitiesFailureReason.RedirectedToRoot - ); - break; - - default: - throw new UnreachableError(scenario); - } - }); - }); - }); -} diff --git a/x-pack/test/ui_capabilities/security_only/tests/index.ts b/x-pack/test/ui_capabilities/security_only/tests/index.ts index 615b2e92fea36..d58ae1ef3786f 100644 --- a/x-pack/test/ui_capabilities/security_only/tests/index.ts +++ b/x-pack/test/ui_capabilities/security_only/tests/index.ts @@ -55,6 +55,5 @@ export default function uiCapabilitesTests({ loadTestFile(require.resolve('./catalogue')); loadTestFile(require.resolve('./foo')); loadTestFile(require.resolve('./nav_links')); - loadTestFile(require.resolve('./saved_objects_management')); }); } diff --git a/x-pack/test/ui_capabilities/security_only/tests/saved_objects_management.ts b/x-pack/test/ui_capabilities/security_only/tests/saved_objects_management.ts deleted file mode 100644 index 5c3eb54a0b150..0000000000000 --- a/x-pack/test/ui_capabilities/security_only/tests/saved_objects_management.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { mapValues } from 'lodash'; -import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers'; -import { SavedObjectsManagementBuilder } from '../../common/saved_objects_management_builder'; -import { - UICapabilitiesService, - GetUICapabilitiesFailureReason, -} from '../../common/services/ui_capabilities'; -import { UserScenarios } from '../scenarios'; - -const savedObjectsManagementBuilder = new SavedObjectsManagementBuilder(false); - -// eslint-disable-next-line import/no-default-export -export default function savedObjectsManagementTests({ - getService, -}: KibanaFunctionalTestDefaultProviders) { - const uiCapabilitiesService: UICapabilitiesService = getService('uiCapabilities'); - - describe('savedObjectsManagement', () => { - UserScenarios.forEach(scenario => { - it(`${scenario.fullName}`, async () => { - const uiCapabilities = await uiCapabilitiesService.get({ - credentials: { - username: scenario.username, - password: scenario.password, - }, - }); - switch (scenario.username) { - case 'superuser': - case 'all': - case 'dual_privileges_all': - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - const expected = mapValues(uiCapabilities.value!.savedObjectsManagement, () => - savedObjectsManagementBuilder.uiCapabilities('all') - ); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql(expected); - break; - case 'read': - case 'dual_privileges_read': - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - const expectedRead = mapValues(uiCapabilities.value!.savedObjectsManagement, () => - savedObjectsManagementBuilder.uiCapabilities('read') - ); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql(expectedRead); - break; - case 'foo_all': - case 'foo_read': - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql( - savedObjectsManagementBuilder.build({ - all: [], - read: [], - }) - ); - break; - case 'no_kibana_privileges': - // these users have no access to any ui capabilities - case 'legacy_all': - case 'no_kibana_privileges': - expect(uiCapabilities.success).to.be(false); - expect(uiCapabilities.failureReason).to.be(GetUICapabilitiesFailureReason.NotFound); - break; - default: - throw new UnreachableError(scenario); - } - }); - }); - }); -} diff --git a/x-pack/test/ui_capabilities/spaces_only/tests/index.ts b/x-pack/test/ui_capabilities/spaces_only/tests/index.ts index fa97f2bf2f4b8..fd54528fa61bc 100644 --- a/x-pack/test/ui_capabilities/spaces_only/tests/index.ts +++ b/x-pack/test/ui_capabilities/spaces_only/tests/index.ts @@ -41,6 +41,5 @@ export default function uiCapabilitesTests({ loadTestFile(require.resolve('./catalogue')); loadTestFile(require.resolve('./foo')); loadTestFile(require.resolve('./nav_links')); - loadTestFile(require.resolve('./saved_objects_management')); }); } diff --git a/x-pack/test/ui_capabilities/spaces_only/tests/saved_objects_management.ts b/x-pack/test/ui_capabilities/spaces_only/tests/saved_objects_management.ts deleted file mode 100644 index 513702c5e98c2..0000000000000 --- a/x-pack/test/ui_capabilities/spaces_only/tests/saved_objects_management.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { mapValues } from 'lodash'; -import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers'; -import { SavedObjectsManagementBuilder } from '../../common/saved_objects_management_builder'; -import { UICapabilitiesService } from '../../common/services/ui_capabilities'; -import { SpaceScenarios } from '../scenarios'; - -const savedObjectsManagementBuilder = new SavedObjectsManagementBuilder(true); - -// eslint-disable-next-line import/no-default-export -export default function savedObjectsManagementTests({ - getService, -}: KibanaFunctionalTestDefaultProviders) { - const uiCapabilitiesService: UICapabilitiesService = getService('uiCapabilities'); - - describe('savedObjectsManagement', () => { - SpaceScenarios.forEach(scenario => { - it(`${scenario.name}`, async () => { - switch (scenario.id) { - case 'nothing_space': - // Saved Objects Managment is not available when everything is disabled. - const nothingSpaceCapabilities = await uiCapabilitiesService.get({ - spaceId: scenario.id, - }); - expect(nothingSpaceCapabilities.success).to.be(true); - expect(nothingSpaceCapabilities.value).to.have.property('savedObjectsManagement'); - const nothingSpaceExpected = mapValues( - nothingSpaceCapabilities.value!.savedObjectsManagement, - () => savedObjectsManagementBuilder.uiCapabilities('none') - ); - expect(nothingSpaceCapabilities.value!.savedObjectsManagement).to.eql( - nothingSpaceExpected - ); - break; - default: - // Otherwise it's available without restriction - const uiCapabilities = await uiCapabilitiesService.get({ spaceId: scenario.id }); - expect(uiCapabilities.success).to.be(true); - expect(uiCapabilities.value).to.have.property('savedObjectsManagement'); - const expected = mapValues(uiCapabilities.value!.savedObjectsManagement, () => - savedObjectsManagementBuilder.uiCapabilities('all') - ); - expect(uiCapabilities.value!.savedObjectsManagement).to.eql(expected); - } - }); - }); - }); -}