diff --git a/src/ui/public/capabilities/ui_capabilities.test.ts b/src/ui/public/capabilities/ui_capabilities.test.ts index 1508907b5eaa66..a9276429abfacb 100644 --- a/src/ui/public/capabilities/ui_capabilities.test.ts +++ b/src/ui/public/capabilities/ui_capabilities.test.ts @@ -22,7 +22,7 @@ jest.mock( () => ({ getInjected: (key: string) => { if (key !== 'uiCapabilities') { - throw new Error(`Unxpected key for test: ${key}`); + throw new Error(`Unexpected key for test: ${key}`); } return { diff --git a/x-pack/plugins/spaces/index.ts b/x-pack/plugins/spaces/index.ts index 7c04b46eca689c..69cf3dd58fef77 100644 --- a/x-pack/plugins/spaces/index.ts +++ b/x-pack/plugins/spaces/index.ts @@ -98,8 +98,7 @@ export const spaces = (kibana: any) => if (vars.activeSpace.space) { vars.uiCapabilities = await toggleUiCapabilities( vars.uiCapabilities, - vars.activeSpace.space, - spacesClient + vars.activeSpace.space ); } 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 1ecff814530e3e..67eb48f4030d8c 100644 --- a/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts +++ b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts @@ -6,41 +6,13 @@ import { UICapabilities } from 'ui/capabilities'; import { Space } from '../../common/model/space'; -import { SpacesClient } from './spaces_client'; -export async function toggleUiCapabilities( - uiCapabilities: UICapabilities, - activeSpace: Space, - spacesClient: SpacesClient -) { - // 1) Determine if user can manage spaces - await toggleManageSpacesCapability(uiCapabilities, spacesClient); - - // 2) Turn off capabilities that are disabled within this space +export async function toggleUiCapabilities(uiCapabilities: UICapabilities, activeSpace: Space) { toggleDisabledFeatures(uiCapabilities, activeSpace); return uiCapabilities; } -async function toggleManageSpacesCapability( - uiCapabilities: UICapabilities, - spacesClient: SpacesClient -) { - // Spaces special case - // Security is normally responsible for toggling such features, but since Spaces themselves are part of a security construct, - // the Spaces plugin is responsible for determining this specific capability. - try { - const canManageSpaces = await spacesClient.canEnumerateSpaces(); - if (!canManageSpaces) { - uiCapabilities.spaces.manage = false; - } - } catch (error) { - // TODO: Log - // Fail closed. - uiCapabilities.spaces.manage = false; - } -} - function toggleDisabledFeatures(uiCapabilities: UICapabilities, activeSpace: Space) { // TODO: get disabled features from active space // @ts-ignore