diff --git a/.eslintrc.js b/.eslintrc.js index 2c55dd2528ef..06fd805a02aa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1567,7 +1567,6 @@ module.exports = { { files: [ 'src/plugins/security_oss/**/*.{js,mjs,ts,tsx}', - 'src/plugins/spaces_oss/**/*.{js,mjs,ts,tsx}', 'src/plugins/interactive_setup/**/*.{js,mjs,ts,tsx}', 'x-pack/plugins/encrypted_saved_objects/**/*.{js,mjs,ts,tsx}', 'x-pack/plugins/security/**/*.{js,mjs,ts,tsx}', diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 93848ee75628..a457ae426d3e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -280,7 +280,6 @@ # Security /src/core/server/csp/ @elastic/kibana-security @elastic/kibana-core /src/plugins/security_oss/ @elastic/kibana-security -/src/plugins/spaces_oss/ @elastic/kibana-security /src/plugins/interactive_setup/ @elastic/kibana-security /test/security_functional/ @elastic/kibana-security /x-pack/plugins/spaces/ @elastic/kibana-security diff --git a/api_docs/spaces_oss.json b/api_docs/spaces_oss.json deleted file mode 100644 index cd59756b548b..000000000000 --- a/api_docs/spaces_oss.json +++ /dev/null @@ -1,1320 +0,0 @@ -{ - "id": "spacesOss", - "client": { - "classes": [], - "functions": [], - "interfaces": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.LegacyUrlConflictProps", - "type": "Interface", - "tags": [], - "label": "LegacyUrlConflictProps", - "description": [ - "\nProperties for the LegacyUrlConflict component." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.LegacyUrlConflictProps.objectNoun", - "type": "string", - "tags": [], - "label": "objectNoun", - "description": [ - "\nThe string that is used to describe the object in the callout, e.g., _There is a legacy URL for this page that points to a different\n**object**_.\n\nDefault value is 'object'." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.LegacyUrlConflictProps.currentObjectId", - "type": "string", - "tags": [], - "label": "currentObjectId", - "description": [ - "\nThe ID of the object that is currently shown on the page." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.LegacyUrlConflictProps.otherObjectId", - "type": "string", - "tags": [], - "label": "otherObjectId", - "description": [ - "\nThe ID of the other object that the legacy URL alias points to." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.LegacyUrlConflictProps.otherObjectPath", - "type": "string", - "tags": [], - "label": "otherObjectPath", - "description": [ - "\nThe path to use for the new URL, optionally including `search` and/or `hash` URL components." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps", - "type": "Interface", - "tags": [], - "label": "ShareToSpaceFlyoutProps", - "description": [ - "\nProperties for the ShareToSpaceFlyout." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.savedObjectTarget", - "type": "Object", - "tags": [], - "label": "savedObjectTarget", - "description": [ - "\nThe object to render the flyout for." - ], - "signature": [ - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.ShareToSpaceSavedObjectTarget", - "text": "ShareToSpaceSavedObjectTarget" - } - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.flyoutIcon", - "type": "string", - "tags": [], - "label": "flyoutIcon", - "description": [ - "\nThe EUI icon that is rendered in the flyout's title.\n\nDefault is 'share'." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.flyoutTitle", - "type": "string", - "tags": [], - "label": "flyoutTitle", - "description": [ - "\nThe string that is rendered in the flyout's title.\n\nDefault is 'Edit spaces for object'." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.enableCreateCopyCallout", - "type": "CompoundType", - "tags": [], - "label": "enableCreateCopyCallout", - "description": [ - "\nWhen enabled, if the object is not yet shared to multiple spaces, a callout will be displayed that suggests the user might want to\ncreate a copy instead.\n\nDefault value is false." - ], - "signature": [ - "boolean | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.enableCreateNewSpaceLink", - "type": "CompoundType", - "tags": [], - "label": "enableCreateNewSpaceLink", - "description": [ - "\nWhen enabled, if no other spaces exist _and_ the user has the appropriate privileges, a sentence will be displayed that suggests the\nuser might want to create a space.\n\nDefault value is false." - ], - "signature": [ - "boolean | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.behaviorContext", - "type": "CompoundType", - "tags": [], - "label": "behaviorContext", - "description": [ - "\nWhen set to 'within-space' (default), the flyout behaves like it is running on a page within the active space, and it will prevent the\nuser from removing the object from the active space.\n\nConversely, when set to 'outside-space', the flyout behaves like it is running on a page outside of any space, so it will allow the\nuser to remove the object from the active space." - ], - "signature": [ - "\"within-space\" | \"outside-space\" | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.changeSpacesHandler", - "type": "Function", - "tags": [], - "label": "changeSpacesHandler", - "description": [ - "\nOptional handler that is called when the user has saved changes and there are spaces to be added to and/or removed from the object and\nits relatives. If this is not defined, a default handler will be used that calls `/api/spaces/_update_objects_spaces` and displays a\ntoast indicating what occurred." - ], - "signature": [ - "((objects: { type: string; id: string; }[], spacesToAdd: string[], spacesToRemove: string[]) => Promise) | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.changeSpacesHandler.$1", - "type": "Array", - "tags": [], - "label": "objects", - "description": [], - "signature": [ - "{ type: string; id: string; }[]" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "isRequired": true - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.changeSpacesHandler.$2", - "type": "Array", - "tags": [], - "label": "spacesToAdd", - "description": [], - "signature": [ - "string[]" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "isRequired": true - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.changeSpacesHandler.$3", - "type": "Array", - "tags": [], - "label": "spacesToRemove", - "description": [], - "signature": [ - "string[]" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "isRequired": true - } - ], - "returnComment": [] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.onUpdate", - "type": "Function", - "tags": [], - "label": "onUpdate", - "description": [ - "\nOptional callback when the target object and its relatives are updated." - ], - "signature": [ - "((updatedObjects: { type: string; id: string; }[]) => void) | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.onUpdate.$1", - "type": "Array", - "tags": [], - "label": "updatedObjects", - "description": [], - "signature": [ - "{ type: string; id: string; }[]" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "isRequired": true - } - ], - "returnComment": [] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceFlyoutProps.onClose", - "type": "Function", - "tags": [], - "label": "onClose", - "description": [ - "\nOptional callback when the flyout is closed." - ], - "signature": [ - "(() => void) | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [], - "returnComment": [] - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget", - "type": "Interface", - "tags": [], - "label": "ShareToSpaceSavedObjectTarget", - "description": [ - "\nDescribes the target saved object during a share operation." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget.type", - "type": "string", - "tags": [], - "label": "type", - "description": [ - "\nThe object's type." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget.id", - "type": "string", - "tags": [], - "label": "id", - "description": [ - "\nThe object's ID." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget.namespaces", - "type": "Array", - "tags": [], - "label": "namespaces", - "description": [ - "\nThe namespaces that the object currently exists in." - ], - "signature": [ - "string[]" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget.icon", - "type": "string", - "tags": [], - "label": "icon", - "description": [ - "\nThe EUI icon that is rendered in the flyout's subtitle.\n\nDefault is 'empty'." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget.title", - "type": "string", - "tags": [], - "label": "title", - "description": [ - "\nThe string that is rendered in the flyout's subtitle.\n\nDefault is `${type} [id=${id}]`." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.ShareToSpaceSavedObjectTarget.noun", - "type": "string", - "tags": [], - "label": "noun", - "description": [ - "\nThe string that is used to describe the object in several places, e.g., _Make **object** available in selected spaces only_.\n\nDefault value is 'object'." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceAvatarProps", - "type": "Interface", - "tags": [], - "label": "SpaceAvatarProps", - "description": [ - "\nProperties for the SpaceAvatar component." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceAvatarProps.space", - "type": "Object", - "tags": [], - "label": "space", - "description": [ - "The space to represent with an avatar." - ], - "signature": [ - "{ id?: string | undefined; name?: string | undefined; description?: string | undefined; color?: string | undefined; initials?: string | undefined; imageUrl?: string | undefined; disabledFeatures?: string[] | undefined; _reserved?: boolean | undefined; }" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceAvatarProps.size", - "type": "CompoundType", - "tags": [], - "label": "size", - "description": [ - "The size of the avatar." - ], - "signature": [ - "\"m\" | \"s\" | \"l\" | \"xl\" | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceAvatarProps.className", - "type": "string", - "tags": [], - "label": "className", - "description": [ - "Optional CSS class(es) to apply." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceAvatarProps.announceSpaceName", - "type": "CompoundType", - "tags": [], - "label": "announceSpaceName", - "description": [ - "\nWhen enabled, allows EUI to provide an aria-label for this component, which is announced on screen readers.\n\nDefault value is true." - ], - "signature": [ - "boolean | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceAvatarProps.isDisabled", - "type": "CompoundType", - "tags": [], - "label": "isDisabled", - "description": [ - "\nWhether or not to render the avatar in a disabled state.\n\nDefault value is false." - ], - "signature": [ - "boolean | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceListProps", - "type": "Interface", - "tags": [], - "label": "SpaceListProps", - "description": [ - "\nProperties for the SpaceList component." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceListProps.namespaces", - "type": "Array", - "tags": [], - "label": "namespaces", - "description": [ - "\nThe namespaces of a saved object to render into a corresponding list of spaces." - ], - "signature": [ - "string[]" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceListProps.displayLimit", - "type": "number", - "tags": [], - "label": "displayLimit", - "description": [ - "\nOptional limit to the number of spaces that can be displayed in the list. If the number of spaces exceeds this limit, they will be\nhidden behind a \"show more\" button. Set to 0 to disable.\n\nDefault value is 5." - ], - "signature": [ - "number | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpaceListProps.behaviorContext", - "type": "CompoundType", - "tags": [], - "label": "behaviorContext", - "description": [ - "\nWhen set to 'within-space' (default), the space list behaves like it is running on a page within the active space, and it will omit the\nactive space (e.g., it displays a list of all the _other_ spaces that an object is shared to).\n\nConversely, when set to 'outside-space', the space list behaves like it is running on a page outside of any space, so it will not omit\nthe active space." - ], - "signature": [ - "\"within-space\" | \"outside-space\" | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApi", - "type": "Interface", - "tags": [], - "label": "SpacesApi", - "description": [ - "\nClient-side Spaces API." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApi.getActiveSpace$", - "type": "Function", - "tags": [], - "label": "getActiveSpace$", - "description": [ - "\nObservable representing the currently active space.\nThe details of the space can change without a full page reload (such as display name, color, etc.)" - ], - "signature": [ - "() => ", - "Observable", - "<", - { - "pluginId": "spacesOss", - "scope": "common", - "docId": "kibSpacesOssPluginApi", - "section": "def-common.Space", - "text": "Space" - }, - ">" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [], - "returnComment": [] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApi.getActiveSpace", - "type": "Function", - "tags": [], - "label": "getActiveSpace", - "description": [ - "\nRetrieve the currently active space." - ], - "signature": [ - "() => Promise<", - { - "pluginId": "spacesOss", - "scope": "common", - "docId": "kibSpacesOssPluginApi", - "section": "def-common.Space", - "text": "Space" - }, - ">" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [], - "returnComment": [] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApi.ui", - "type": "Object", - "tags": [], - "label": "ui", - "description": [ - "\nUI components and services to add spaces capabilities to an application." - ], - "signature": [ - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesApiUi", - "text": "SpacesApiUi" - } - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUi", - "type": "Interface", - "tags": [], - "label": "SpacesApiUi", - "description": [ - "\nUI components and services to add spaces capabilities to an application." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUi.components", - "type": "Object", - "tags": [], - "label": "components", - "description": [ - "\nLazy-loadable {@link SpacesApiUiComponent | React components} to support the Spaces feature." - ], - "signature": [ - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesApiUiComponent", - "text": "SpacesApiUiComponent" - } - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUi.redirectLegacyUrl", - "type": "Function", - "tags": [], - "label": "redirectLegacyUrl", - "description": [ - "\nRedirect the user from a legacy URL to a new URL. This needs to be used if a call to `SavedObjectsClient.resolve()` results in an\n`\"aliasMatch\"` outcome, which indicates that the user has loaded the page using a legacy URL. Calling this function will trigger a\nclient-side redirect to the new URL, and it will display a toast to the user.\n\nConsumers need to determine the local path for the new URL on their own, based on the object ID that was used to call\n`SavedObjectsClient.resolve()` (old ID) and the object ID in the result (new ID). For example...\n\nThe old object ID is `workpad-123` and the new object ID is `workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e`.\n\nFull legacy URL: `https://localhost:5601/app/canvas#/workpad/workpad-123/page/1`\n\nNew URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1`\n\nThe protocol, hostname, port, base path, and app path are automatically included.\n" - ], - "signature": [ - "(path: string, objectNoun?: string | undefined) => Promise" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUi.redirectLegacyUrl.$1", - "type": "string", - "tags": [], - "label": "path", - "description": [ - "The path to use for the new URL, optionally including `search` and/or `hash` URL components." - ], - "signature": [ - "string" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "isRequired": true - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUi.redirectLegacyUrl.$2", - "type": "string", - "tags": [], - "label": "objectNoun", - "description": [ - "The string that is used to describe the object in the toast, e.g., _The **object** you're looking for has a new\nlocation_. Default value is 'object'." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "isRequired": false - } - ], - "returnComment": [] - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUiComponent", - "type": "Interface", - "tags": [], - "label": "SpacesApiUiComponent", - "description": [ - "\nReact UI components to be used to display the Spaces feature in any application." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUiComponent.getSpacesContextProvider", - "type": "Function", - "tags": [], - "label": "getSpacesContextProvider", - "description": [ - "\nProvides a context that is required to render some Spaces components." - ], - "signature": [ - "(props: ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesContextProps", - "text": "SpacesContextProps" - }, - ") => React.ReactElement React.ReactElement React.Component)> | null) | (new (props: any) => React.Component)>" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "returnComment": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.props", - "type": "Uncategorized", - "tags": [], - "label": "props", - "description": [], - "signature": [ - "T" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUiComponent.getShareToSpaceFlyout", - "type": "Function", - "tags": [], - "label": "getShareToSpaceFlyout", - "description": [ - "\nDisplays a flyout to edit the spaces that an object is shared to.\n\nNote: must be rendered inside of a SpacesContext." - ], - "signature": [ - "(props: ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.ShareToSpaceFlyoutProps", - "text": "ShareToSpaceFlyoutProps" - }, - ") => React.ReactElement React.ReactElement React.Component)> | null) | (new (props: any) => React.Component)>" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "returnComment": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.props", - "type": "Uncategorized", - "tags": [], - "label": "props", - "description": [], - "signature": [ - "T" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUiComponent.getSpaceList", - "type": "Function", - "tags": [], - "label": "getSpaceList", - "description": [ - "\nDisplays a corresponding list of spaces for a given list of saved object namespaces. It shows up to five spaces (and an indicator for\nany number of spaces that the user is not authorized to see) by default. If more than five named spaces would be displayed, the extras\n(along with the unauthorized spaces indicator, if present) are hidden behind a button. If '*' (aka \"All spaces\") is present, it\nsupersedes all of the above and just displays a single badge without a button.\n\nNote: must be rendered inside of a SpacesContext." - ], - "signature": [ - "(props: ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpaceListProps", - "text": "SpaceListProps" - }, - ") => React.ReactElement React.ReactElement React.Component)> | null) | (new (props: any) => React.Component)>" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "returnComment": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.props", - "type": "Uncategorized", - "tags": [], - "label": "props", - "description": [], - "signature": [ - "T" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUiComponent.getLegacyUrlConflict", - "type": "Function", - "tags": [], - "label": "getLegacyUrlConflict", - "description": [ - "\nDisplays a callout that needs to be used if a call to `SavedObjectsClient.resolve()` results in an `\"conflict\"` outcome, which\nindicates that the user has loaded the page which is associated directly with one object (A), *and* with a legacy URL that points to a\ndifferent object (B).\n\nIn this case, `SavedObjectsClient.resolve()` has returned object A. This component displays a warning callout to the user explaining\nthat there is a conflict, and it includes a button that will redirect the user to object B when clicked.\n\nConsumers need to determine the local path for the new URL on their own, based on the object ID that was used to call\n`SavedObjectsClient.resolve()` (A) and the `aliasTargetId` value in the response (B). For example...\n\nA is `workpad-123` and B is `workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e`.\n\nFull legacy URL: `https://localhost:5601/app/canvas#/workpad/workpad-123/page/1`\n\nNew URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1`" - ], - "signature": [ - "(props: ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.LegacyUrlConflictProps", - "text": "LegacyUrlConflictProps" - }, - ") => React.ReactElement React.ReactElement React.Component)> | null) | (new (props: any) => React.Component)>" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "returnComment": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.props", - "type": "Uncategorized", - "tags": [], - "label": "props", - "description": [], - "signature": [ - "T" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ] - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesApiUiComponent.getSpaceAvatar", - "type": "Function", - "tags": [], - "label": "getSpaceAvatar", - "description": [ - "\nDisplays an avatar for the given space." - ], - "signature": [ - "(props: ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpaceAvatarProps", - "text": "SpaceAvatarProps" - }, - ") => React.ReactElement React.ReactElement React.Component)> | null) | (new (props: any) => React.Component)>" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "returnComment": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.props", - "type": "Uncategorized", - "tags": [], - "label": "props", - "description": [], - "signature": [ - "T" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ] - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesAvailableStartContract", - "type": "Interface", - "tags": [], - "label": "SpacesAvailableStartContract", - "description": [ - "\nOSS Spaces plugin start contract when the Spaces feature is enabled." - ], - "signature": [ - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesAvailableStartContract", - "text": "SpacesAvailableStartContract" - }, - " extends ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesApi", - "text": "SpacesApi" - } - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesAvailableStartContract.isSpacesAvailable", - "type": "boolean", - "tags": [], - "label": "isSpacesAvailable", - "description": [ - "Indicates if the Spaces feature is enabled." - ], - "signature": [ - "true" - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesContextProps", - "type": "Interface", - "tags": [], - "label": "SpacesContextProps", - "description": [ - "\nProperties for the SpacesContext." - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesContextProps.feature", - "type": "string", - "tags": [], - "label": "feature", - "description": [ - "\nIf a feature is specified, all Spaces components will treat it appropriately if the feature is disabled in a given Space." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesUnavailableStartContract", - "type": "Interface", - "tags": [ - "deprecated" - ], - "label": "SpacesUnavailableStartContract", - "description": [ - "\nOSS Spaces plugin start contract when the Spaces feature is disabled." - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": true, - "removeBy": "8.0", - "references": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesUnavailableStartContract.isSpacesAvailable", - "type": "boolean", - "tags": [], - "label": "isSpacesAvailable", - "description": [ - "Indicates if the Spaces feature is enabled." - ], - "signature": [ - "false" - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false - } - ], - "initialIsOpen": false - } - ], - "enums": [], - "misc": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.LazyComponentFn", - "type": "Type", - "tags": [], - "label": "LazyComponentFn", - "description": [ - "\nFunction that returns a promise for a lazy-loadable component." - ], - "signature": [ - "(props: T) => React.ReactElement React.ReactElement React.Component)> | null) | (new (props: any) => React.Component)>" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false, - "returnComment": [], - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.props", - "type": "Uncategorized", - "tags": [], - "label": "props", - "description": [], - "signature": [ - "T" - ], - "path": "src/plugins/spaces_oss/public/api.ts", - "deprecated": false - } - ], - "initialIsOpen": false - } - ], - "objects": [], - "setup": { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesOssPluginSetup", - "type": "Interface", - "tags": [], - "label": "SpacesOssPluginSetup", - "description": [ - "\nOSS Spaces plugin setup contract." - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesOssPluginSetup.registerSpacesApi", - "type": "Function", - "tags": [ - "private" - ], - "label": "registerSpacesApi", - "description": [ - "\nRegister a provider for the Spaces API.\n\nOnly one provider can be registered, subsequent calls to this method will fail.\n" - ], - "signature": [ - "(provider: ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesApi", - "text": "SpacesApi" - }, - ") => void" - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesOssPluginSetup.registerSpacesApi.$1", - "type": "Object", - "tags": [], - "label": "provider", - "description": [ - "the API provider." - ], - "signature": [ - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesApi", - "text": "SpacesApi" - } - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false, - "isRequired": true - } - ], - "returnComment": [] - } - ], - "lifecycle": "setup", - "initialIsOpen": true - }, - "start": { - "parentPluginId": "spacesOss", - "id": "def-public.SpacesOssPluginStart", - "type": "Type", - "tags": [], - "label": "SpacesOssPluginStart", - "description": [ - "\nOSS Spaces plugin start contract." - ], - "signature": [ - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesAvailableStartContract", - "text": "SpacesAvailableStartContract" - }, - " | ", - { - "pluginId": "spacesOss", - "scope": "public", - "docId": "kibSpacesOssPluginApi", - "section": "def-public.SpacesUnavailableStartContract", - "text": "SpacesUnavailableStartContract" - } - ], - "path": "src/plugins/spaces_oss/public/types.ts", - "deprecated": false, - "lifecycle": "start", - "initialIsOpen": true - } - }, - "server": { - "classes": [], - "functions": [], - "interfaces": [], - "enums": [], - "misc": [], - "objects": [] - }, - "common": { - "classes": [], - "functions": [], - "interfaces": [ - { - "parentPluginId": "spacesOss", - "id": "def-common.Space", - "type": "Interface", - "tags": [], - "label": "Space", - "description": [ - "\nA Space." - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false, - "children": [ - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.id", - "type": "string", - "tags": [], - "label": "id", - "description": [ - "\nThe unique identifier for this space.\nThe id becomes part of the \"URL Identifier\" of the space.\n\nExample: an id of `marketing` would result in the URL identifier of `/s/marketing`." - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.name", - "type": "string", - "tags": [], - "label": "name", - "description": [ - "\nDisplay name for this space." - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.description", - "type": "string", - "tags": [], - "label": "description", - "description": [ - "\nOptional description for this space." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.color", - "type": "string", - "tags": [], - "label": "color", - "description": [ - "\nOptional color (hex code) for this space.\nIf neither `color` nor `imageUrl` is specified, then a color will be automatically generated." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.initials", - "type": "string", - "tags": [], - "label": "initials", - "description": [ - "\nOptional display initials for this space's avatar. Supports a maximum of 2 characters.\nIf initials are not provided, then they will be derived from the space name automatically.\n\nInitials are not displayed if an `imageUrl` has been specified." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.imageUrl", - "type": "string", - "tags": [], - "label": "imageUrl", - "description": [ - "\nOptional base-64 encoded data image url to show as this space's avatar.\nThis setting takes precedence over any configured `color` or `initials`." - ], - "signature": [ - "string | undefined" - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space.disabledFeatures", - "type": "Array", - "tags": [], - "label": "disabledFeatures", - "description": [ - "\nThe set of feature ids that should be hidden within this space." - ], - "signature": [ - "string[]" - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - }, - { - "parentPluginId": "spacesOss", - "id": "def-common.Space._reserved", - "type": "CompoundType", - "tags": [ - "private" - ], - "label": "_reserved", - "description": [ - "\nIndicates that this space is reserved (system controlled).\nReserved spaces cannot be created or deleted by end-users." - ], - "signature": [ - "boolean | undefined" - ], - "path": "src/plugins/spaces_oss/common/types.ts", - "deprecated": false - } - ], - "initialIsOpen": false - } - ], - "enums": [], - "misc": [], - "objects": [] - } -} \ No newline at end of file diff --git a/api_docs/spaces_oss.mdx b/api_docs/spaces_oss.mdx deleted file mode 100644 index d166a37a9373..000000000000 --- a/api_docs/spaces_oss.mdx +++ /dev/null @@ -1,41 +0,0 @@ ---- -id: kibSpacesOssPluginApi -slug: /kibana-dev-docs/spacesOssPluginApi -title: spacesOss -image: https://source.unsplash.com/400x175/?github -summary: API docs for the spacesOss plugin -date: 2020-11-16 -tags: ['contributor', 'dev', 'apidocs', 'kibana', 'spacesOss'] -warning: This document is auto-generated and is meant to be viewed inside our experimental, new docs system. Reach out in #docs-engineering for more info. ---- -import spacesOssObj from './spaces_oss.json'; - -This plugin exposes a limited set of spaces functionality to OSS plugins. - -Contact [Platform Security](https://github.com/orgs/elastic/teams/kibana-security) for questions regarding this plugin. - -**Code health stats** - -| Public API count | Any count | Items lacking comments | Missing exports | -|-------------------|-----------|------------------------|-----------------| -| 77 | 0 | 10 | 0 | - -## Client - -### Setup - - -### Start - - -### Interfaces - - -### Consts, variables and types - - -## Common - -### Interfaces - - diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 66e09579e986..0f4afe184b23 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -227,10 +227,6 @@ so they can properly protect the data within their clusters. generating deep links to other apps, and creating short URLs. -|{kib-repo}blob/{branch}/src/plugins/spaces_oss/README.md[spacesOss] -|Bridge plugin for consumption of the Spaces feature from OSS plugins. - - |{kib-repo}blob/{branch}/src/plugins/telemetry/README.md[telemetry] |Telemetry allows Kibana features to have usage tracked in the wild. The general term "telemetry" refers to multiple things: diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 0dc17484ccb0..3f846eaff285 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -98,7 +98,6 @@ pageLoadAssetSize: runtimeFields: 41752 stackAlerts: 29684 presentationUtil: 94301 - spacesOss: 18817 indexPatternFieldEditor: 50000 osquery: 107090 fileUpload: 25664 diff --git a/src/plugins/dashboard/kibana.json b/src/plugins/dashboard/kibana.json index d270b7dad3c7..164be971d22b 100644 --- a/src/plugins/dashboard/kibana.json +++ b/src/plugins/dashboard/kibana.json @@ -19,7 +19,7 @@ "presentationUtil", "visualizations" ], - "optionalPlugins": ["home", "spacesOss", "savedObjectsTaggingOss", "usageCollection"], + "optionalPlugins": ["home", "spaces", "savedObjectsTaggingOss", "usageCollection"], "server": true, "ui": true, "requiredBundles": ["home", "kibanaReact", "kibanaUtils", "presentationUtil"] diff --git a/src/plugins/dashboard/public/application/dashboard_router.tsx b/src/plugins/dashboard/public/application/dashboard_router.tsx index 902a03bd84ad..073160b698d9 100644 --- a/src/plugins/dashboard/public/application/dashboard_router.tsx +++ b/src/plugins/dashboard/public/application/dashboard_router.tsx @@ -79,13 +79,13 @@ export async function mountApp({ urlForwarding, data: dataStart, share: shareStart, + spaces: spacesApi, embeddable: embeddableStart, savedObjectsTaggingOss, visualizations, presentationUtil, } = pluginsStart; - const spacesApi = pluginsStart.spacesOss?.isSpacesAvailable ? pluginsStart.spacesOss : undefined; const activeSpaceId = spacesApi && (await spacesApi.getActiveSpace$().pipe(first()).toPromise())?.id; let globalEmbedSettings: DashboardEmbedSettings | undefined; diff --git a/src/plugins/dashboard/public/plugin.tsx b/src/plugins/dashboard/public/plugin.tsx index 501b1807be54..acaf1cee7092 100644 --- a/src/plugins/dashboard/public/plugin.tsx +++ b/src/plugins/dashboard/public/plugin.tsx @@ -80,7 +80,7 @@ import { UrlGeneratorState } from '../../share/public'; import { ExportCSVAction } from './application/actions/export_csv_action'; import { dashboardFeatureCatalog } from './dashboard_strings'; import { replaceUrlHashQuery } from '../../kibana_utils/public'; -import { SpacesOssPluginStart } from './services/spaces'; +import { SpacesPluginStart } from './services/spaces'; declare module '../../share/public' { export interface UrlGeneratorStateMapping { @@ -118,7 +118,7 @@ export interface DashboardStartDependencies { savedObjects: SavedObjectsStart; presentationUtil: PresentationUtilPluginStart; savedObjectsTaggingOss?: SavedObjectTaggingOssPluginStart; - spacesOss?: SpacesOssPluginStart; + spaces?: SpacesPluginStart; visualizations: VisualizationsStart; } diff --git a/src/plugins/dashboard/public/services/spaces.ts b/src/plugins/dashboard/public/services/spaces.ts index e6d2c6400818..89a0acaf611b 100644 --- a/src/plugins/dashboard/public/services/spaces.ts +++ b/src/plugins/dashboard/public/services/spaces.ts @@ -6,4 +6,4 @@ * Side Public License, v 1. */ -export { SpacesOssPluginStart } from '../../../spaces_oss/public'; +export { SpacesPluginStart } from '../../../../../x-pack/plugins/spaces/public'; diff --git a/src/plugins/dashboard/tsconfig.json b/src/plugins/dashboard/tsconfig.json index 4febb8b5555c..7558ade4705b 100644 --- a/src/plugins/dashboard/tsconfig.json +++ b/src/plugins/dashboard/tsconfig.json @@ -30,9 +30,9 @@ { "path": "../saved_objects_tagging_oss/tsconfig.json" }, { "path": "../saved_objects/tsconfig.json" }, { "path": "../ui_actions/tsconfig.json" }, - { "path": "../spaces_oss/tsconfig.json" }, { "path": "../charts/tsconfig.json" }, { "path": "../discover/tsconfig.json" }, { "path": "../visualizations/tsconfig.json" }, + { "path": "../../../x-pack/plugins/spaces/tsconfig.json" }, ] } diff --git a/src/plugins/saved_objects_management/kibana.json b/src/plugins/saved_objects_management/kibana.json index 48e61eb9e4da..b8207e0627b8 100644 --- a/src/plugins/saved_objects_management/kibana.json +++ b/src/plugins/saved_objects_management/kibana.json @@ -8,7 +8,7 @@ "server": true, "ui": true, "requiredPlugins": ["management", "data"], - "optionalPlugins": ["dashboard", "visualizations", "discover", "home", "savedObjectsTaggingOss", "spacesOss"], + "optionalPlugins": ["dashboard", "visualizations", "discover", "home", "savedObjectsTaggingOss", "spaces"], "extraPublicDirs": ["public/lib"], "requiredBundles": ["kibanaReact", "home"] } diff --git a/src/plugins/saved_objects_management/public/management_section/mount_section.tsx b/src/plugins/saved_objects_management/public/management_section/mount_section.tsx index a21ad6b7a440..e5aaec6fa4bb 100644 --- a/src/plugins/saved_objects_management/public/management_section/mount_section.tsx +++ b/src/plugins/saved_objects_management/public/management_section/mount_section.tsx @@ -39,7 +39,7 @@ export const mountManagementSection = async ({ }: MountParams) => { const [ coreStart, - { data, savedObjectsTaggingOss, spacesOss }, + { data, savedObjectsTaggingOss, spaces: spacesApi }, pluginStart, ] = await core.getStartServices(); const { element, history, setBreadcrumbs } = mountParams; @@ -61,8 +61,6 @@ export const mountManagementSection = async ({ return children! as React.ReactElement; }; - const spacesApi = spacesOss?.isSpacesAvailable ? spacesOss : undefined; - ReactDOM.render( diff --git a/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx b/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx index fd938abd2704..f22f0333ec22 100644 --- a/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx +++ b/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx @@ -13,10 +13,7 @@ import { Query } from '@elastic/eui'; import { parse } from 'query-string'; import { i18n } from '@kbn/i18n'; import { CoreStart, ChromeBreadcrumb } from 'src/core/public'; -import type { - SpacesAvailableStartContract, - SpacesContextProps, -} from 'src/plugins/spaces_oss/public'; +import type { SpacesApi, SpacesContextProps } from '../../../../../x-pack/plugins/spaces/public'; import { DataPublicPluginStart } from '../../../data/public'; import { SavedObjectsTaggingApi } from '../../../saved_objects_tagging_oss/public'; import { @@ -42,7 +39,7 @@ const SavedObjectsTablePage = ({ coreStart: CoreStart; dataStart: DataPublicPluginStart; taggingApi?: SavedObjectsTaggingApi; - spacesApi?: SpacesAvailableStartContract; + spacesApi?: SpacesApi; allowedTypes: string[]; serviceRegistry: ISavedObjectsManagementServiceRegistry; actionRegistry: SavedObjectsManagementActionServiceStart; diff --git a/src/plugins/saved_objects_management/public/plugin.ts b/src/plugins/saved_objects_management/public/plugin.ts index f4578c4c4b8e..cc6bd8300546 100644 --- a/src/plugins/saved_objects_management/public/plugin.ts +++ b/src/plugins/saved_objects_management/public/plugin.ts @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import { CoreSetup, CoreStart, Plugin } from 'src/core/public'; +import type { SpacesPluginStart } from '../../../../x-pack/plugins/spaces/public'; import { ManagementSetup } from '../../management/public'; import { DataPublicPluginStart } from '../../data/public'; import { DashboardStart } from '../../dashboard/public'; @@ -15,7 +16,6 @@ import { DiscoverStart } from '../../discover/public'; import { HomePublicPluginSetup, FeatureCatalogueCategory } from '../../home/public'; import { VisualizationsStart } from '../../visualizations/public'; import { SavedObjectTaggingOssPluginStart } from '../../saved_objects_tagging_oss/public'; -import type { SpacesOssPluginStart } from '../../spaces_oss/public'; import { SavedObjectsManagementActionService, SavedObjectsManagementActionServiceSetup, @@ -50,7 +50,7 @@ export interface StartDependencies { visualizations?: VisualizationsStart; discover?: DiscoverStart; savedObjectsTaggingOss?: SavedObjectTaggingOssPluginStart; - spacesOss?: SpacesOssPluginStart; + spaces?: SpacesPluginStart; } export class SavedObjectsManagementPlugin @@ -116,9 +116,9 @@ export class SavedObjectsManagementPlugin }; } - public start(core: CoreStart, { data }: StartDependencies) { - const actionStart = this.actionService.start(); - const columnStart = this.columnService.start(); + public start(_core: CoreStart, { spaces: spacesApi }: StartDependencies) { + const actionStart = this.actionService.start(spacesApi); + const columnStart = this.columnService.start(spacesApi); return { actions: actionStart, diff --git a/src/plugins/saved_objects_management/public/services/action_service.test.ts b/src/plugins/saved_objects_management/public/services/action_service.test.ts index 609cd5e5d3a0..7a2536611f58 100644 --- a/src/plugins/saved_objects_management/public/services/action_service.test.ts +++ b/src/plugins/saved_objects_management/public/services/action_service.test.ts @@ -6,6 +6,11 @@ * Side Public License, v 1. */ +import { spacesPluginMock } from '../../../../../x-pack/plugins/spaces/public/mocks'; +import { + CopyToSpaceSavedObjectsManagementAction, + ShareToSpaceSavedObjectsManagementAction, +} from './actions'; import { SavedObjectsManagementActionService, SavedObjectsManagementActionServiceSetup, @@ -44,8 +49,12 @@ describe('SavedObjectsManagementActionRegistry', () => { it('allows actions to be registered and retrieved', () => { const action = createAction('foo'); setup.register(action); - const start = service.start(); - expect(start.getAll()).toContain(action); + const start = service.start(spacesPluginMock.createStartContract()); + expect(start.getAll()).toEqual([ + action, + expect.any(ShareToSpaceSavedObjectsManagementAction), + expect.any(CopyToSpaceSavedObjectsManagementAction), + ]); }); it('does not allow actions with duplicate ids to be registered', () => { diff --git a/src/plugins/saved_objects_management/public/services/action_service.ts b/src/plugins/saved_objects_management/public/services/action_service.ts index 015a4953fe23..b72ca3d2535d 100644 --- a/src/plugins/saved_objects_management/public/services/action_service.ts +++ b/src/plugins/saved_objects_management/public/services/action_service.ts @@ -6,6 +6,11 @@ * Side Public License, v 1. */ +import type { SpacesApi } from '../../../../../x-pack/plugins/spaces/public'; +import { + CopyToSpaceSavedObjectsManagementAction, + ShareToSpaceSavedObjectsManagementAction, +} from './actions'; import { SavedObjectsManagementAction } from './types'; export interface SavedObjectsManagementActionServiceSetup { @@ -40,10 +45,21 @@ export class SavedObjectsManagementActionService { }; } - start(): SavedObjectsManagementActionServiceStart { + start(spacesApi?: SpacesApi): SavedObjectsManagementActionServiceStart { + if (spacesApi) { + registerSpacesApiActions(this, spacesApi); + } return { has: (actionId) => this.actions.has(actionId), getAll: () => [...this.actions.values()], }; } } + +function registerSpacesApiActions( + service: SavedObjectsManagementActionService, + spacesApi: SpacesApi +) { + service.setup().register(new ShareToSpaceSavedObjectsManagementAction(spacesApi.ui)); + service.setup().register(new CopyToSpaceSavedObjectsManagementAction(spacesApi.ui)); +} diff --git a/src/plugins/saved_objects_management/public/services/actions/copy_saved_objects_to_space_action.tsx b/src/plugins/saved_objects_management/public/services/actions/copy_saved_objects_to_space_action.tsx new file mode 100644 index 000000000000..5773f64a1e62 --- /dev/null +++ b/src/plugins/saved_objects_management/public/services/actions/copy_saved_objects_to_space_action.tsx @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { useMemo } from 'react'; + +import { i18n } from '@kbn/i18n'; + +import type { + CopyToSpaceFlyoutProps, + SpacesApiUi, +} from '../../../../../../x-pack/plugins/spaces/public'; +import type { SavedObjectsManagementRecord } from '../types'; +import { SavedObjectsManagementAction } from '../types'; + +interface WrapperProps { + spacesApiUi: SpacesApiUi; + props: CopyToSpaceFlyoutProps; +} + +const Wrapper = ({ spacesApiUi, props }: WrapperProps) => { + const LazyComponent = useMemo(() => spacesApiUi.components.getCopyToSpaceFlyout, [spacesApiUi]); + + return ; +}; + +export class CopyToSpaceSavedObjectsManagementAction extends SavedObjectsManagementAction { + public id: string = 'copy_saved_objects_to_space'; + + public euiAction = { + name: i18n.translate('savedObjectsManagement.copyToSpace.actionTitle', { + defaultMessage: 'Copy to space', + }), + description: i18n.translate('savedObjectsManagement.copyToSpace.actionDescription', { + defaultMessage: 'Make a copy of this saved object in one or more spaces', + }), + icon: 'copy', + type: 'icon', + available: (object: SavedObjectsManagementRecord) => { + return object.meta.namespaceType !== 'agnostic' && !object.meta.hiddenType; + }, + onClick: (object: SavedObjectsManagementRecord) => { + this.start(object); + }, + }; + + constructor(private readonly spacesApiUi: SpacesApiUi) { + super(); + } + + public render = () => { + if (!this.record) { + throw new Error('No record available! `render()` was likely called before `start()`.'); + } + + const props: CopyToSpaceFlyoutProps = { + onClose: this.onClose, + savedObjectTarget: { + type: this.record.type, + id: this.record.id, + namespaces: this.record.namespaces ?? [], + title: this.record.meta.title, + icon: this.record.meta.icon, + }, + }; + + return ; + }; + + private onClose = () => { + this.finish(); + }; +} diff --git a/src/plugins/spaces_oss/jest.config.js b/src/plugins/saved_objects_management/public/services/actions/index.ts similarity index 64% rename from src/plugins/spaces_oss/jest.config.js rename to src/plugins/saved_objects_management/public/services/actions/index.ts index 8be5bf6e0fb5..39cde652fd54 100644 --- a/src/plugins/spaces_oss/jest.config.js +++ b/src/plugins/saved_objects_management/public/services/actions/index.ts @@ -6,8 +6,5 @@ * Side Public License, v 1. */ -module.exports = { - preset: '@kbn/test', - rootDir: '../../..', - roots: ['/src/plugins/spaces_oss'], -}; +export { CopyToSpaceSavedObjectsManagementAction } from './copy_saved_objects_to_space_action'; +export { ShareToSpaceSavedObjectsManagementAction } from './share_saved_objects_to_space_action'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_action.test.tsx b/src/plugins/saved_objects_management/public/services/actions/share_saved_objects_to_space_action.test.tsx similarity index 86% rename from x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_action.test.tsx rename to src/plugins/saved_objects_management/public/services/actions/share_saved_objects_to_space_action.test.tsx index 9c3a56aac20a..235f8d4508a6 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_action.test.tsx +++ b/src/plugins/saved_objects_management/public/services/actions/share_saved_objects_to_space_action.test.tsx @@ -1,18 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import type { SavedObjectsManagementRecord } from 'src/plugins/saved_objects_management/public'; - -import { uiApiMock } from '../ui_api/mocks'; +import { spacesPluginMock } from '../../../../../../x-pack/plugins/spaces/public/mocks'; +import type { SavedObjectsManagementRecord } from '../types'; import { ShareToSpaceSavedObjectsManagementAction } from './share_saved_objects_to_space_action'; describe('ShareToSpaceSavedObjectsManagementAction', () => { const createAction = () => { - const spacesApiUi = uiApiMock.create(); + const { ui: spacesApiUi } = spacesPluginMock.createStartContract(); return new ShareToSpaceSavedObjectsManagementAction(spacesApiUi); }; describe('#euiAction.available', () => { diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_action.tsx b/src/plugins/saved_objects_management/public/services/actions/share_saved_objects_to_space_action.tsx similarity index 79% rename from x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_action.tsx rename to src/plugins/saved_objects_management/public/services/actions/share_saved_objects_to_space_action.tsx index 90dda8ad0b01..e36c13bd8fd8 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_action.tsx +++ b/src/plugins/saved_objects_management/public/services/actions/share_saved_objects_to_space_action.tsx @@ -1,17 +1,21 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import type { SavedObjectsManagementRecord } from 'src/plugins/saved_objects_management/public'; -import type { ShareToSpaceFlyoutProps, SpacesApiUi } from 'src/plugins/spaces_oss/public'; -import { SavedObjectsManagementAction } from '../../../../../src/plugins/saved_objects_management/public'; +import type { + ShareToSpaceFlyoutProps, + SpacesApiUi, +} from '../../../../../../x-pack/plugins/spaces/public'; +import type { SavedObjectsManagementRecord } from '../types'; +import { SavedObjectsManagementAction } from '../types'; interface WrapperProps { spacesApiUi: SpacesApiUi; @@ -28,10 +32,10 @@ export class ShareToSpaceSavedObjectsManagementAction extends SavedObjectsManage public id: string = 'share_saved_objects_to_space'; public euiAction = { - name: i18n.translate('xpack.spaces.shareToSpace.actionTitle', { + name: i18n.translate('savedObjectsManagement.shareToSpace.actionTitle', { defaultMessage: 'Share to space', }), - description: i18n.translate('xpack.spaces.shareToSpace.actionDescription', { + description: i18n.translate('savedObjectsManagement.shareToSpace.actionDescription', { defaultMessage: 'Share this saved object to one or more spaces', }), icon: 'share', diff --git a/src/plugins/saved_objects_management/public/services/column_service.test.ts b/src/plugins/saved_objects_management/public/services/column_service.test.ts index 3e18cdaec0c4..581a55fa0066 100644 --- a/src/plugins/saved_objects_management/public/services/column_service.test.ts +++ b/src/plugins/saved_objects_management/public/services/column_service.test.ts @@ -6,6 +6,8 @@ * Side Public License, v 1. */ +import { spacesPluginMock } from '../../../../../x-pack/plugins/spaces/public/mocks'; +// import { ShareToSpaceSavedObjectsManagementColumn } from './columns'; import { SavedObjectsManagementColumnService, SavedObjectsManagementColumnServiceSetup, @@ -40,8 +42,11 @@ describe('SavedObjectsManagementColumnRegistry', () => { it('allows columns to be registered and retrieved', () => { const column = createColumn('foo'); setup.register(column); - const start = service.start(); - expect(start.getAll()).toContain(column); + const start = service.start(spacesPluginMock.createStartContract()); + expect(start.getAll()).toEqual([ + column, + // expect.any(ShareToSpaceSavedObjectsManagementColumn), + ]); }); it('does not allow columns with duplicate ids to be registered', () => { diff --git a/src/plugins/saved_objects_management/public/services/column_service.ts b/src/plugins/saved_objects_management/public/services/column_service.ts index fb919af2b402..74c06a3d3321 100644 --- a/src/plugins/saved_objects_management/public/services/column_service.ts +++ b/src/plugins/saved_objects_management/public/services/column_service.ts @@ -6,6 +6,8 @@ * Side Public License, v 1. */ +import type { SpacesApi } from '../../../../../x-pack/plugins/spaces/public'; +// import { ShareToSpaceSavedObjectsManagementColumn } from './columns'; import { SavedObjectsManagementColumn } from './types'; export interface SavedObjectsManagementColumnServiceSetup { @@ -36,9 +38,20 @@ export class SavedObjectsManagementColumnService { }; } - start(): SavedObjectsManagementColumnServiceStart { + start(spacesApi?: SpacesApi): SavedObjectsManagementColumnServiceStart { + if (spacesApi) { + registerSpacesApiColumns(this, spacesApi); + } return { getAll: () => [...this.columns.values()], }; } } + +function registerSpacesApiColumns( + service: SavedObjectsManagementColumnService, + spacesApi: SpacesApi +) { + // Note: this column is hidden for now because no saved objects are shareable. It should be uncommented when at least one saved object type is multi-namespace. + // service.setup().register(new ShareToSpaceSavedObjectsManagementColumn(spacesApi.ui)); +} diff --git a/src/plugins/spaces_oss/common/index.ts b/src/plugins/saved_objects_management/public/services/columns/index.ts similarity index 78% rename from src/plugins/spaces_oss/common/index.ts rename to src/plugins/saved_objects_management/public/services/columns/index.ts index a499a06983e6..f93c603f9011 100644 --- a/src/plugins/spaces_oss/common/index.ts +++ b/src/plugins/saved_objects_management/public/services/columns/index.ts @@ -6,4 +6,4 @@ * Side Public License, v 1. */ -export { Space } from './types'; +export { ShareToSpaceSavedObjectsManagementColumn } from './share_saved_objects_to_space_column'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.tsx b/src/plugins/saved_objects_management/public/services/columns/share_saved_objects_to_space_column.tsx similarity index 69% rename from x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.tsx rename to src/plugins/saved_objects_management/public/services/columns/share_saved_objects_to_space_column.tsx index 609811cd6b7c..736b656f15d9 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.tsx +++ b/src/plugins/saved_objects_management/public/services/columns/share_saved_objects_to_space_column.tsx @@ -1,15 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import type { SavedObjectsManagementColumn } from 'src/plugins/saved_objects_management/public'; -import type { SpaceListProps, SpacesApiUi } from 'src/plugins/spaces_oss/public'; + +import type { SpaceListProps, SpacesApiUi } from '../../../../../../x-pack/plugins/spaces/public'; +import type { SavedObjectsManagementColumn } from '../types'; interface WrapperProps { spacesApiUi: SpacesApiUi; @@ -28,10 +30,10 @@ export class ShareToSpaceSavedObjectsManagementColumn public euiColumn = { field: 'namespaces', - name: i18n.translate('xpack.spaces.shareToSpace.columnTitle', { + name: i18n.translate('savedObjectsManagement.shareToSpace.columnTitle', { defaultMessage: 'Shared spaces', }), - description: i18n.translate('xpack.spaces.shareToSpace.columnDescription', { + description: i18n.translate('savedObjectsManagement.shareToSpace.columnDescription', { defaultMessage: 'The other spaces that this object is currently shared to', }), render: (namespaces: string[] | undefined) => { diff --git a/src/plugins/saved_objects_management/tsconfig.json b/src/plugins/saved_objects_management/tsconfig.json index 0f26da69acd1..545d4697ca2c 100644 --- a/src/plugins/saved_objects_management/tsconfig.json +++ b/src/plugins/saved_objects_management/tsconfig.json @@ -20,6 +20,6 @@ { "path": "../kibana_react/tsconfig.json" }, { "path": "../management/tsconfig.json" }, { "path": "../visualizations/tsconfig.json" }, - { "path": "../spaces_oss/tsconfig.json" }, + { "path": "../../../x-pack/plugins/spaces/tsconfig.json" }, ] } diff --git a/src/plugins/spaces_oss/README.md b/src/plugins/spaces_oss/README.md deleted file mode 100644 index 73de736d6fb4..000000000000 --- a/src/plugins/spaces_oss/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# SpacesOss - -Bridge plugin for consumption of the Spaces feature from OSS plugins. diff --git a/src/plugins/spaces_oss/common/types.ts b/src/plugins/spaces_oss/common/types.ts deleted file mode 100644 index b5c418cf3177..000000000000 --- a/src/plugins/spaces_oss/common/types.ts +++ /dev/null @@ -1,62 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -/** - * A Space. - */ -export interface Space { - /** - * The unique identifier for this space. - * The id becomes part of the "URL Identifier" of the space. - * - * Example: an id of `marketing` would result in the URL identifier of `/s/marketing`. - */ - id: string; - - /** - * Display name for this space. - */ - name: string; - - /** - * Optional description for this space. - */ - description?: string; - - /** - * Optional color (hex code) for this space. - * If neither `color` nor `imageUrl` is specified, then a color will be automatically generated. - */ - color?: string; - - /** - * Optional display initials for this space's avatar. Supports a maximum of 2 characters. - * If initials are not provided, then they will be derived from the space name automatically. - * - * Initials are not displayed if an `imageUrl` has been specified. - */ - initials?: string; - - /** - * Optional base-64 encoded data image url to show as this space's avatar. - * This setting takes precedence over any configured `color` or `initials`. - */ - imageUrl?: string; - - /** - * The set of feature ids that should be hidden within this space. - */ - disabledFeatures: string[]; - - /** - * Indicates that this space is reserved (system controlled). - * Reserved spaces cannot be created or deleted by end-users. - * @private - */ - _reserved?: boolean; -} diff --git a/src/plugins/spaces_oss/kibana.json b/src/plugins/spaces_oss/kibana.json deleted file mode 100644 index 10127634618f..000000000000 --- a/src/plugins/spaces_oss/kibana.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "spacesOss", - "owner": { - "name": "Platform Security", - "githubTeam": "kibana-security" - }, - "description": "This plugin exposes a limited set of spaces functionality to OSS plugins.", - "version": "kibana", - "server": false, - "ui": true, - "requiredPlugins": [], - "optionalPlugins": [] -} diff --git a/src/plugins/spaces_oss/public/api.ts b/src/plugins/spaces_oss/public/api.ts deleted file mode 100644 index 7492142f0d79..000000000000 --- a/src/plugins/spaces_oss/public/api.ts +++ /dev/null @@ -1,302 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import type { ReactElement } from 'react'; -import type { Observable } from 'rxjs'; - -import type { Space } from '../common'; - -/** - * Client-side Spaces API. - */ -export interface SpacesApi { - /** - * Observable representing the currently active space. - * The details of the space can change without a full page reload (such as display name, color, etc.) - */ - getActiveSpace$(): Observable; - - /** - * Retrieve the currently active space. - */ - getActiveSpace(): Promise; - - /** - * UI components and services to add spaces capabilities to an application. - */ - ui: SpacesApiUi; -} - -/** - * Function that returns a promise for a lazy-loadable component. - */ -export type LazyComponentFn = (props: T) => ReactElement; - -/** - * UI components and services to add spaces capabilities to an application. - */ -export interface SpacesApiUi { - /** - * Lazy-loadable {@link SpacesApiUiComponent | React components} to support the Spaces feature. - */ - components: SpacesApiUiComponent; - /** - * Redirect the user from a legacy URL to a new URL. This needs to be used if a call to `SavedObjectsClient.resolve()` results in an - * `"aliasMatch"` outcome, which indicates that the user has loaded the page using a legacy URL. Calling this function will trigger a - * client-side redirect to the new URL, and it will display a toast to the user. - * - * Consumers need to determine the local path for the new URL on their own, based on the object ID that was used to call - * `SavedObjectsClient.resolve()` (old ID) and the object ID in the result (new ID). For example... - * - * The old object ID is `workpad-123` and the new object ID is `workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e`. - * - * Full legacy URL: `https://localhost:5601/app/canvas#/workpad/workpad-123/page/1` - * - * New URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1` - * - * The protocol, hostname, port, base path, and app path are automatically included. - * - * @param path The path to use for the new URL, optionally including `search` and/or `hash` URL components. - * @param objectNoun The string that is used to describe the object in the toast, e.g., _The **object** you're looking for has a new - * location_. Default value is 'object'. - */ - redirectLegacyUrl: (path: string, objectNoun?: string) => Promise; -} - -/** - * React UI components to be used to display the Spaces feature in any application. - */ -export interface SpacesApiUiComponent { - /** - * Provides a context that is required to render some Spaces components. - */ - getSpacesContextProvider: LazyComponentFn; - /** - * Displays a flyout to edit the spaces that an object is shared to. - * - * Note: must be rendered inside of a SpacesContext. - */ - getShareToSpaceFlyout: LazyComponentFn; - /** - * Displays a corresponding list of spaces for a given list of saved object namespaces. It shows up to five spaces (and an indicator for - * any number of spaces that the user is not authorized to see) by default. If more than five named spaces would be displayed, the extras - * (along with the unauthorized spaces indicator, if present) are hidden behind a button. If '*' (aka "All spaces") is present, it - * supersedes all of the above and just displays a single badge without a button. - * - * Note: must be rendered inside of a SpacesContext. - */ - getSpaceList: LazyComponentFn; - /** - * Displays a callout that needs to be used if a call to `SavedObjectsClient.resolve()` results in an `"conflict"` outcome, which - * indicates that the user has loaded the page which is associated directly with one object (A), *and* with a legacy URL that points to a - * different object (B). - * - * In this case, `SavedObjectsClient.resolve()` has returned object A. This component displays a warning callout to the user explaining - * that there is a conflict, and it includes a button that will redirect the user to object B when clicked. - * - * Consumers need to determine the local path for the new URL on their own, based on the object ID that was used to call - * `SavedObjectsClient.resolve()` (A) and the `alias_target_id` value in the response (B). For example... - * - * A is `workpad-123` and B is `workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e`. - * - * Full legacy URL: `https://localhost:5601/app/canvas#/workpad/workpad-123/page/1` - * - * New URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1` - */ - getLegacyUrlConflict: LazyComponentFn; - /** - * Displays an avatar for the given space. - */ - getSpaceAvatar: LazyComponentFn; -} - -/** - * Properties for the SpacesContext. - */ -export interface SpacesContextProps { - /** - * If a feature is specified, all Spaces components will treat it appropriately if the feature is disabled in a given Space. - */ - feature?: string; -} - -/** - * Properties for the ShareToSpaceFlyout. - */ -export interface ShareToSpaceFlyoutProps { - /** - * The object to render the flyout for. - */ - savedObjectTarget: ShareToSpaceSavedObjectTarget; - /** - * The EUI icon that is rendered in the flyout's title. - * - * Default is 'share'. - */ - flyoutIcon?: string; - /** - * The string that is rendered in the flyout's title. - * - * Default is 'Edit spaces for object'. - */ - flyoutTitle?: string; - /** - * When enabled, if the object is not yet shared to multiple spaces, a callout will be displayed that suggests the user might want to - * create a copy instead. - * - * Default value is false. - */ - enableCreateCopyCallout?: boolean; - /** - * When enabled, if no other spaces exist _and_ the user has the appropriate privileges, a sentence will be displayed that suggests the - * user might want to create a space. - * - * Default value is false. - */ - enableCreateNewSpaceLink?: boolean; - /** - * When set to 'within-space' (default), the flyout behaves like it is running on a page within the active space, and it will prevent the - * user from removing the object from the active space. - * - * Conversely, when set to 'outside-space', the flyout behaves like it is running on a page outside of any space, so it will allow the - * user to remove the object from the active space. - */ - behaviorContext?: 'within-space' | 'outside-space'; - /** - * Optional handler that is called when the user has saved changes and there are spaces to be added to and/or removed from the object and - * its relatives. If this is not defined, a default handler will be used that calls `/api/spaces/_update_objects_spaces` and displays a - * toast indicating what occurred. - */ - changeSpacesHandler?: ( - objects: Array<{ type: string; id: string }>, - spacesToAdd: string[], - spacesToRemove: string[] - ) => Promise; - /** - * Optional callback when the target object and its relatives are updated. - */ - onUpdate?: (updatedObjects: Array<{ type: string; id: string }>) => void; - /** - * Optional callback when the flyout is closed. - */ - onClose?: () => void; -} - -/** - * Describes the target saved object during a share operation. - */ -export interface ShareToSpaceSavedObjectTarget { - /** - * The object's type. - */ - type: string; - /** - * The object's ID. - */ - id: string; - /** - * The namespaces that the object currently exists in. - */ - namespaces: string[]; - /** - * The EUI icon that is rendered in the flyout's subtitle. - * - * Default is 'empty'. - */ - icon?: string; - /** - * The string that is rendered in the flyout's subtitle. - * - * Default is `${type} [id=${id}]`. - */ - title?: string; - /** - * The string that is used to describe the object in several places, e.g., _Make **object** available in selected spaces only_. - * - * Default value is 'object'. - */ - noun?: string; -} - -/** - * Properties for the SpaceList component. - */ -export interface SpaceListProps { - /** - * The namespaces of a saved object to render into a corresponding list of spaces. - */ - namespaces: string[]; - /** - * Optional limit to the number of spaces that can be displayed in the list. If the number of spaces exceeds this limit, they will be - * hidden behind a "show more" button. Set to 0 to disable. - * - * Default value is 5. - */ - displayLimit?: number; - /** - * When set to 'within-space' (default), the space list behaves like it is running on a page within the active space, and it will omit the - * active space (e.g., it displays a list of all the _other_ spaces that an object is shared to). - * - * Conversely, when set to 'outside-space', the space list behaves like it is running on a page outside of any space, so it will not omit - * the active space. - */ - behaviorContext?: 'within-space' | 'outside-space'; -} - -/** - * Properties for the LegacyUrlConflict component. - */ -export interface LegacyUrlConflictProps { - /** - * The string that is used to describe the object in the callout, e.g., _There is a legacy URL for this page that points to a different - * **object**_. - * - * Default value is 'object'. - */ - objectNoun?: string; - /** - * The ID of the object that is currently shown on the page. - */ - currentObjectId: string; - /** - * The ID of the other object that the legacy URL alias points to. - */ - otherObjectId: string; - /** - * The path to use for the new URL, optionally including `search` and/or `hash` URL components. - */ - otherObjectPath: string; -} - -/** - * Properties for the SpaceAvatar component. - */ -export interface SpaceAvatarProps { - /** The space to represent with an avatar. */ - space: Partial; - - /** The size of the avatar. */ - size?: 's' | 'm' | 'l' | 'xl'; - - /** Optional CSS class(es) to apply. */ - className?: string; - - /** - * When enabled, allows EUI to provide an aria-label for this component, which is announced on screen readers. - * - * Default value is true. - */ - announceSpaceName?: boolean; - - /** - * Whether or not to render the avatar in a disabled state. - * - * Default value is false. - */ - isDisabled?: boolean; -} diff --git a/src/plugins/spaces_oss/public/index.ts b/src/plugins/spaces_oss/public/index.ts deleted file mode 100644 index 9c4d5fd17700..000000000000 --- a/src/plugins/spaces_oss/public/index.ts +++ /dev/null @@ -1,31 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { SpacesOssPlugin } from './plugin'; - -export type { - SpacesOssPluginSetup, - SpacesOssPluginStart, - SpacesAvailableStartContract, - SpacesUnavailableStartContract, -} from './types'; - -export type { - LazyComponentFn, - SpacesApi, - SpacesApiUi, - SpacesApiUiComponent, - SpacesContextProps, - ShareToSpaceFlyoutProps, - ShareToSpaceSavedObjectTarget, - SpaceListProps, - LegacyUrlConflictProps, - SpaceAvatarProps, -} from './api'; - -export const plugin = () => new SpacesOssPlugin(); diff --git a/src/plugins/spaces_oss/public/mocks/index.ts b/src/plugins/spaces_oss/public/mocks/index.ts deleted file mode 100644 index dc7b9e34fe82..000000000000 --- a/src/plugins/spaces_oss/public/mocks/index.ts +++ /dev/null @@ -1,24 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import type { SpacesOssPluginSetup, SpacesOssPluginStart } from '../'; -import { spacesApiMock } from '../api.mock'; - -const createSetupContract = (): jest.Mocked => ({ - registerSpacesApi: jest.fn(), -}); - -const createStartContract = (): jest.Mocked => ({ - isSpacesAvailable: true, - ...spacesApiMock.create(), -}); - -export const spacesOssPluginMock = { - createSetupContract, - createStartContract, -}; diff --git a/src/plugins/spaces_oss/public/plugin.test.ts b/src/plugins/spaces_oss/public/plugin.test.ts deleted file mode 100644 index fcbe1c7d86ce..000000000000 --- a/src/plugins/spaces_oss/public/plugin.test.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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { spacesApiMock } from './api.mock'; -import { SpacesOssPlugin } from './plugin'; - -describe('SpacesOssPlugin', () => { - let plugin: SpacesOssPlugin; - - beforeEach(() => { - plugin = new SpacesOssPlugin(); - }); - - describe('#setup', () => { - it('only allows the API to be registered once', async () => { - const spacesApi = spacesApiMock.create(); - const { registerSpacesApi } = plugin.setup(); - - expect(() => registerSpacesApi(spacesApi)).not.toThrow(); - - expect(() => registerSpacesApi(spacesApi)).toThrowErrorMatchingInlineSnapshot( - `"Spaces API can only be registered once"` - ); - }); - }); - - describe('#start', () => { - it('returns the spaces API if registered', async () => { - const spacesApi = spacesApiMock.create(); - const { registerSpacesApi } = plugin.setup(); - - registerSpacesApi(spacesApi); - - const { isSpacesAvailable, ...api } = plugin.start(); - - expect(isSpacesAvailable).toBe(true); - expect(api).toStrictEqual(spacesApi); - }); - - it('does not return the spaces API if not registered', async () => { - plugin.setup(); - - const { isSpacesAvailable, ...api } = plugin.start(); - - expect(isSpacesAvailable).toBe(false); - expect(Object.keys(api)).toHaveLength(0); - }); - }); -}); diff --git a/src/plugins/spaces_oss/public/plugin.ts b/src/plugins/spaces_oss/public/plugin.ts deleted file mode 100644 index 2531453257e3..000000000000 --- a/src/plugins/spaces_oss/public/plugin.ts +++ /dev/null @@ -1,42 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import type { Plugin } from 'src/core/public'; - -import type { SpacesApi } from './api'; -import type { SpacesOssPluginSetup, SpacesOssPluginStart } from './types'; - -export class SpacesOssPlugin implements Plugin { - private api?: SpacesApi; - - constructor() {} - - public setup() { - return { - registerSpacesApi: (provider: SpacesApi) => { - if (this.api) { - throw new Error('Spaces API can only be registered once'); - } - this.api = provider; - }, - }; - } - - public start() { - if (this.api) { - return { - isSpacesAvailable: true as true, - ...this.api!, - }; - } else { - return { - isSpacesAvailable: false as false, - }; - } - } -} diff --git a/src/plugins/spaces_oss/public/types.ts b/src/plugins/spaces_oss/public/types.ts deleted file mode 100644 index df20e9be6eaa..000000000000 --- a/src/plugins/spaces_oss/public/types.ts +++ /dev/null @@ -1,48 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import type { SpacesApi } from './api'; - -/** - * OSS Spaces plugin start contract when the Spaces feature is enabled. - */ -export interface SpacesAvailableStartContract extends SpacesApi { - /** Indicates if the Spaces feature is enabled. */ - isSpacesAvailable: true; -} - -/** - * OSS Spaces plugin start contract when the Spaces feature is disabled. - * @deprecated The Spaces plugin will always be enabled starting in 8.0. - * @removeBy 8.0 - */ -export interface SpacesUnavailableStartContract { - /** Indicates if the Spaces feature is enabled. */ - isSpacesAvailable: false; -} - -/** - * OSS Spaces plugin setup contract. - */ -export interface SpacesOssPluginSetup { - /** - * Register a provider for the Spaces API. - * - * Only one provider can be registered, subsequent calls to this method will fail. - * - * @param provider the API provider. - * - * @private designed to only be consumed by the `spaces` plugin. - */ - registerSpacesApi(provider: SpacesApi): void; -} - -/** - * OSS Spaces plugin start contract. - */ -export type SpacesOssPluginStart = SpacesAvailableStartContract | SpacesUnavailableStartContract; diff --git a/src/plugins/spaces_oss/tsconfig.json b/src/plugins/spaces_oss/tsconfig.json deleted file mode 100644 index 35942863c1f1..000000000000 --- a/src/plugins/spaces_oss/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./target/types", - "emitDeclarationOnly": true, - "declaration": true, - "declarationMap": true - }, - "include": [ - "common/**/*", - "public/**/*", - ], - "references": [ - { "path": "../../core/tsconfig.json" }, - ] -} diff --git a/x-pack/plugins/maps/tsconfig.json b/x-pack/plugins/maps/tsconfig.json index 5245b374b9fe..3f6e1fdbe847 100644 --- a/x-pack/plugins/maps/tsconfig.json +++ b/x-pack/plugins/maps/tsconfig.json @@ -16,9 +16,26 @@ "references": [ { "path": "../../../src/core/tsconfig.json" }, { "path": "../../../src/plugins/maps_ems/tsconfig.json" }, + { "path": "../../../src/plugins/dashboard/tsconfig.json" }, + { "path": "../../../src/plugins/inspector/tsconfig.json" }, + { "path": "../../../src/plugins/data/tsconfig.json" }, + { "path": "../../../src/plugins/ui_actions/tsconfig.json" }, + { "path": "../../../src/plugins/navigation/tsconfig.json" }, + { "path": "../../../src/plugins/expressions/tsconfig.json" }, + { "path": "../../../src/plugins/visualizations/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" }, + { "path": "../../../src/plugins/saved_objects/tsconfig.json" }, + { "path": "../../../src/plugins/share/tsconfig.json" }, + { "path": "../../../src/plugins/presentation_util/tsconfig.json" }, + { "path": "../../../src/plugins/home/tsconfig.json" }, + { "path": "../../../src/plugins/charts/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../features/tsconfig.json" }, { "path": "../licensing/tsconfig.json" }, { "path": "../file_upload/tsconfig.json" }, { "path": "../saved_objects_tagging/tsconfig.json" }, + { "path": "../security/tsconfig.json" } ] } diff --git a/x-pack/plugins/ml/public/application/components/job_spaces_list/job_spaces_list.tsx b/x-pack/plugins/ml/public/application/components/job_spaces_list/job_spaces_list.tsx index a405f0486430..8f17591fdd64 100644 --- a/x-pack/plugins/ml/public/application/components/job_spaces_list/job_spaces_list.tsx +++ b/x-pack/plugins/ml/public/application/components/job_spaces_list/job_spaces_list.tsx @@ -9,13 +9,12 @@ import React, { FC, useCallback, useState } from 'react'; import { EuiButtonEmpty } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import type { ShareToSpaceFlyoutProps } from 'src/plugins/spaces_oss/public'; import { JobType, ML_SAVED_OBJECT_TYPE, SavedObjectResult, } from '../../../../common/types/saved_objects'; -import type { SpacesPluginStart } from '../../../../../spaces/public'; +import type { SpacesPluginStart, ShareToSpaceFlyoutProps } from '../../../../../spaces/public'; import { ml } from '../../services/ml_api_service'; import { useToastNotificationService } from '../../services/toast_notification_service'; diff --git a/x-pack/plugins/ml/public/application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx b/x-pack/plugins/ml/public/application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx index a1528b91d5ab..8dccbe973318 100644 --- a/x-pack/plugins/ml/public/application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx +++ b/x-pack/plugins/ml/public/application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx @@ -22,7 +22,6 @@ import { EuiFlexItem, } from '@elastic/eui'; -import type { SpacesContextProps } from 'src/plugins/spaces_oss/public'; import type { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; import type { DataPublicPluginStart } from 'src/plugins/data/public'; import { PLUGIN_ID } from '../../../../../../common/constants/app'; @@ -41,7 +40,7 @@ import { DataFrameAnalyticsList } from '../../../../data_frame_analytics/pages/a import { AccessDeniedPage } from '../access_denied_page'; import { InsufficientLicensePage } from '../insufficient_license_page'; import type { SharePluginStart } from '../../../../../../../../../src/plugins/share/public'; -import type { SpacesPluginStart } from '../../../../../../../spaces/public'; +import type { SpacesPluginStart, SpacesContextProps } from '../../../../../../../spaces/public'; import { JobSpacesSyncFlyout } from '../../../../components/job_spaces_sync'; import { getDefaultAnomalyDetectionJobsListState } from '../../../../jobs/jobs_list/jobs'; import { getMlGlobalServices } from '../../../../app'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx index ef1338ab9d97..3a66b6d80c61 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx @@ -35,12 +35,11 @@ import type { ScopedHistory, } from 'src/core/public'; import type { IndexPatternsContract } from 'src/plugins/data/public'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; import { reactRouterNavigate } from '../../../../../../../src/plugins/kibana_react/public'; import type { KibanaFeature } from '../../../../../features/common'; import type { FeaturesPluginStart } from '../../../../../features/public'; -import type { Space } from '../../../../../spaces/public'; +import type { Space, SpacesApiUi } from '../../../../../spaces/public'; import type { SecurityLicense } from '../../../../common/licensing'; import type { BuiltinESPrivileges, diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx index 486b1c8bc1d0..c9c7df222df2 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx @@ -8,9 +8,8 @@ import React, { Component } from 'react'; import type { Capabilities } from 'src/core/public'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; -import type { Space } from '../../../../../../../spaces/public'; +import type { Space, SpacesApiUi } from '../../../../../../../spaces/public'; import type { Role } from '../../../../../../common/model'; import type { KibanaPrivileges } from '../../../model'; import { CollapsiblePanel } from '../../collapsible_panel'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx index 48a0d1865305..27bf246c0596 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx @@ -17,9 +17,8 @@ import { import React, { Fragment, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; -import type { Space } from '../../../../../../../../spaces/public'; +import type { Space, SpacesApiUi } from '../../../../../../../../spaces/public'; import type { Role } from '../../../../../../../common/model'; import type { KibanaPrivileges } from '../../../../model'; import { PrivilegeSummaryTable } from './privilege_summary_table'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx index 582a7d6c5427..56c841f68f50 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx @@ -20,9 +20,8 @@ import { import React, { Fragment, useMemo, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; -import type { Space } from '../../../../../../../../spaces/public'; +import type { Space, SpacesApiUi } from '../../../../../../../../spaces/public'; import type { Role, RoleKibanaPrivilege } from '../../../../../../../common/model'; import type { KibanaPrivileges, SecuredFeature } from '../../../../model'; import { isGlobalPrivilegeDefinition } from '../../../privilege_utils'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.tsx index fd535d20de55..38c122ba1008 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.tsx @@ -9,9 +9,8 @@ import React, { Fragment, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; +import type { Space, SpacesApiUi } from '../../../../../../../../spaces/public'; import type { RoleKibanaPrivilege } from '../../../../../../../common/model'; import { isGlobalPrivilegeDefinition } from '../../../privilege_utils'; import { SpacesPopoverList } from '../../../spaces_popover_list'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx index 9ca41a018cd3..6492ca6e01af 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx @@ -20,9 +20,8 @@ import React, { Component, Fragment } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { Capabilities } from 'src/core/public'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; -import type { Space } from '../../../../../../../../spaces/public'; +import type { Space, SpacesApiUi } from '../../../../../../../../spaces/public'; import type { Role } from '../../../../../../../common/model'; import { isRoleReserved } from '../../../../../../../common/model'; import type { KibanaPrivileges } from '../../../../model'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx index 2925866a5752..fb21fac3006b 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx @@ -17,8 +17,8 @@ import React from 'react'; import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from 'src/core/public/mocks'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../../../../spaces/public'; import { SpaceAvatarInternal } from '../../../../../../spaces/public/space_avatar/space_avatar_internal'; import { spacesManagerMock } from '../../../../../../spaces/public/spaces_manager/mocks'; import { getUiApi } from '../../../../../../spaces/public/ui_api'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx index 9861b008beb9..e715cb217ae6 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx @@ -19,10 +19,9 @@ import React, { Component, memo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../../../../spaces/common'; +import type { Space, SpacesApiUi } from '../../../../../../spaces/public'; interface Props { spaces: Space[]; diff --git a/x-pack/plugins/spaces/common/index.ts b/x-pack/plugins/spaces/common/index.ts index 003a0c068a16..3af87c44f8e0 100644 --- a/x-pack/plugins/spaces/common/index.ts +++ b/x-pack/plugins/spaces/common/index.ts @@ -9,6 +9,7 @@ export { isReservedSpace } from './is_reserved_space'; export { MAX_SPACE_INITIALS, SPACE_SEARCH_COUNT_THRESHOLD, ENTER_SPACE_PATH } from './constants'; export { addSpaceIdToPath, getSpaceIdFromPath } from './lib/spaces_url_parser'; export type { + Space, GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult, diff --git a/x-pack/plugins/spaces/common/is_reserved_space.test.ts b/x-pack/plugins/spaces/common/is_reserved_space.test.ts index 0128a7483f16..630d4a000f3e 100644 --- a/x-pack/plugins/spaces/common/is_reserved_space.test.ts +++ b/x-pack/plugins/spaces/common/is_reserved_space.test.ts @@ -5,9 +5,8 @@ * 2.0. */ -import type { Space } from 'src/plugins/spaces_oss/common'; - import { isReservedSpace } from './is_reserved_space'; +import type { Space } from './types'; test('it returns true for reserved spaces', () => { const space: Space = { diff --git a/x-pack/plugins/spaces/common/is_reserved_space.ts b/x-pack/plugins/spaces/common/is_reserved_space.ts index f78fe7bbdac1..92b9a0a99ddb 100644 --- a/x-pack/plugins/spaces/common/is_reserved_space.ts +++ b/x-pack/plugins/spaces/common/is_reserved_space.ts @@ -7,7 +7,7 @@ import { get } from 'lodash'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from './types'; /** * Returns whether the given Space is reserved or not. diff --git a/x-pack/plugins/spaces/common/types.ts b/x-pack/plugins/spaces/common/types.ts index 55bd1c137f8c..39864447310b 100644 --- a/x-pack/plugins/spaces/common/types.ts +++ b/x-pack/plugins/spaces/common/types.ts @@ -5,7 +5,60 @@ * 2.0. */ -import type { Space } from 'src/plugins/spaces_oss/common'; +/** + * A Space. + */ +export interface Space { + /** + * The unique identifier for this space. + * The id becomes part of the "URL Identifier" of the space. + * + * Example: an id of `marketing` would result in the URL identifier of `/s/marketing`. + */ + id: string; + + /** + * Display name for this space. + */ + name: string; + + /** + * Optional description for this space. + */ + description?: string; + + /** + * Optional color (hex code) for this space. + * If neither `color` nor `imageUrl` is specified, then a color will be automatically generated. + */ + color?: string; + + /** + * Optional display initials for this space's avatar. Supports a maximum of 2 characters. + * If initials are not provided, then they will be derived from the space name automatically. + * + * Initials are not displayed if an `imageUrl` has been specified. + */ + initials?: string; + + /** + * Optional base-64 encoded data image url to show as this space's avatar. + * This setting takes precedence over any configured `color` or `initials`. + */ + imageUrl?: string; + + /** + * The set of feature ids that should be hidden within this space. + */ + disabledFeatures: string[]; + + /** + * Indicates that this space is reserved (system controlled). + * Reserved spaces cannot be created or deleted by end-users. + * @private + */ + _reserved?: boolean; +} /** * Controls how spaces are retrieved. diff --git a/x-pack/plugins/spaces/kibana.json b/x-pack/plugins/spaces/kibana.json index e01224d03bfc..090e5d089448 100644 --- a/x-pack/plugins/spaces/kibana.json +++ b/x-pack/plugins/spaces/kibana.json @@ -8,13 +8,12 @@ "version": "8.0.0", "kibanaVersion": "kibana", "configPath": ["xpack", "spaces"], - "requiredPlugins": ["features", "licensing", "spacesOss"], + "requiredPlugins": ["features", "licensing"], "optionalPlugins": [ "advancedSettings", "home", "management", - "usageCollection", - "savedObjectsManagement" + "usageCollection" ], "server": true, "ui": true, @@ -22,7 +21,6 @@ "requiredBundles": [ "esUiShared", "kibanaReact", - "savedObjectsManagement", "home" ] } diff --git a/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx index 5658f95b6285..28d64e41fcbe 100644 --- a/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx +++ b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx @@ -8,8 +8,8 @@ import React from 'react'; import type { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../common'; import { AdvancedSettingsSubtitle, AdvancedSettingsTitle } from './components'; interface SetupDeps { diff --git a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx index 75a27a3738e6..613cd9fdaebc 100644 --- a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx +++ b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx @@ -9,7 +9,8 @@ import { EuiCallOut, EuiSpacer } from '@elastic/eui'; import React, { Fragment, useEffect, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; + +import type { Space } from '../../../../common'; interface Props { getActiveSpace: () => Promise; diff --git a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx index 9bec9e32ca73..a5af84bd3394 100644 --- a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx +++ b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx @@ -9,8 +9,8 @@ import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiTitle } from '@elastic import React, { lazy, Suspense, useEffect, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../../common'; import { getSpaceAvatarComponent } from '../../../space_avatar'; // No need to wrap LazySpaceAvatar in an error boundary, because it is one of the first chunks loaded when opening Kibana. diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx index b04450ae4feb..8d9c2f17bdec 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx @@ -11,14 +11,14 @@ import { EuiBadge, EuiIconTip, EuiLoadingSpinner } from '@elastic/eui'; import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { SpacesDataEntry } from '../../types'; import type { SummarizedCopyToSpaceResult } from '../lib'; import type { ImportRetry } from '../types'; import { ResolveAllConflicts } from './resolve_all_conflicts'; interface Props { - space: Space; + space: SpacesDataEntry; summarizedCopyResult: SummarizedCopyToSpaceResult; conflictResolutionInProgress: boolean; retries: ImportRetry[]; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx index 3fee2fdfa975..f1472032fffa 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx @@ -7,7 +7,7 @@ import React from 'react'; -import type { CopyToSpaceFlyoutProps } from './copy_to_space_flyout_internal'; +import type { CopyToSpaceFlyoutProps } from '../types'; export const getCopyToSpaceFlyoutComponent = async (): Promise< React.FC diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx index c021d8bdf69a..998b202a8d6b 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx @@ -17,11 +17,8 @@ import React, { Fragment } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { - FailedImport, - ProcessedImportResponse, -} from 'src/plugins/saved_objects_management/public'; +import type { FailedImport, ProcessedImportResponse } from '../lib'; import type { ImportRetry } from '../types'; interface Props { @@ -62,8 +59,8 @@ export const CopyToSpaceFlyoutFooter = (props: Props) => { let pendingCount = 0; let skippedCount = 0; let errorCount = 0; - if (spaceResult.status === 'success') { - successCount = spaceResult.importCount; + if (spaceResult.success === true) { + successCount = spaceResult.successfulImports.length; } else { const uniqueResolvableErrors = spaceResult.failedImports .filter(isResolvableError) diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx index cb821061b925..2bad5757613e 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx @@ -12,11 +12,11 @@ import React from 'react'; import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; import { coreMock } from 'src/core/public/mocks'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; import { getSpacesContextProviderWrapper } from '../../spaces_context'; import { spacesManagerMock } from '../../spaces_manager/mocks'; -import type { SavedObjectTarget } from '../types'; +import type { CopyToSpaceSavedObjectTarget } from '../types'; import { CopyModeControl } from './copy_mode_control'; import { getCopyToSpaceFlyoutComponent } from './copy_to_space_flyout'; import { CopyToSpaceForm } from './copy_to_space_form'; @@ -82,7 +82,7 @@ const setup = async (opts: SetupOpts = {}) => { namespaces: ['default'], icon: 'dashboard', title: 'foo', - } as SavedObjectTarget; + } as CopyToSpaceSavedObjectTarget; const SpacesContext = await getSpacesContextProviderWrapper({ getStartServices, diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.tsx index 8f219b7154de..7697780c352c 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.tsx @@ -24,31 +24,26 @@ import React, { useEffect, useMemo, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { ProcessedImportResponse } from 'src/plugins/saved_objects_management/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; -import { processImportResponse } from '../../../../../../src/plugins/saved_objects_management/public'; import { useSpaces } from '../../spaces_context'; -import type { CopyOptions, ImportRetry, SavedObjectTarget } from '../types'; +import type { SpacesDataEntry } from '../../types'; +import { processImportResponse } from '../lib'; +import type { ProcessedImportResponse } from '../lib'; +import type { CopyOptions, CopyToSpaceFlyoutProps, ImportRetry } from '../types'; import { CopyToSpaceFlyoutFooter } from './copy_to_space_flyout_footer'; import { CopyToSpaceForm } from './copy_to_space_form'; import { ProcessingCopyToSpace } from './processing_copy_to_space'; -export interface CopyToSpaceFlyoutProps { - onClose: () => void; - savedObjectTarget: SavedObjectTarget; -} - const INCLUDE_RELATED_DEFAULT = true; const CREATE_NEW_COPIES_DEFAULT = true; const OVERWRITE_ALL_DEFAULT = true; export const CopyToSpaceFlyoutInternal = (props: CopyToSpaceFlyoutProps) => { - const { spacesManager, services } = useSpaces(); + const { spacesManager, spacesDataPromise, services } = useSpaces(); const { notifications } = services; const toastNotifications = notifications!.toasts; - const { onClose, savedObjectTarget: object } = props; + const { onClose = () => null, savedObjectTarget: object } = props; const savedObjectTarget = useMemo( () => ({ type: object.type, @@ -66,22 +61,21 @@ export const CopyToSpaceFlyoutInternal = (props: CopyToSpaceFlyoutProps) => { selectedSpaceIds: [], }); - const [{ isLoading, spaces }, setSpacesState] = useState<{ isLoading: boolean; spaces: Space[] }>( - { - isLoading: true, - spaces: [], - } - ); + const [{ isLoading, spaces }, setSpacesState] = useState<{ + isLoading: boolean; + spaces: SpacesDataEntry[]; + }>({ + isLoading: true, + spaces: [], + }); useEffect(() => { - const getSpaces = spacesManager.getSpaces({ includeAuthorizedPurposes: true }); - const getActiveSpace = spacesManager.getActiveSpace(); - Promise.all([getSpaces, getActiveSpace]) - .then(([allSpaces, activeSpace]) => { + spacesDataPromise + .then(({ spacesMap }) => { setSpacesState({ isLoading: false, - spaces: allSpaces.filter( - ({ id, authorizedPurposes }) => - id !== activeSpace.id && authorizedPurposes?.copySavedObjectsIntoSpace !== false + spaces: [...spacesMap.values()].filter( + ({ isActiveSpace, isAuthorizedForPurpose }) => + isActiveSpace || isAuthorizedForPurpose('copySavedObjectsIntoSpace') ), }); }) @@ -92,7 +86,7 @@ export const CopyToSpaceFlyoutInternal = (props: CopyToSpaceFlyoutProps) => { }), }); }); - }, [spacesManager, toastNotifications]); + }, [spacesDataPromise, toastNotifications]); const [copyInProgress, setCopyInProgress] = useState(false); const [conflictResolutionInProgress, setConflictResolutionInProgress] = useState(false); diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx index e28e95ed42d2..1b92936816e5 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx @@ -9,16 +9,16 @@ import { EuiFormRow, EuiSpacer, EuiTitle } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; -import type { CopyOptions, SavedObjectTarget } from '../types'; +import type { SpacesDataEntry } from '../../types'; +import type { CopyOptions, CopyToSpaceSavedObjectTarget } from '../types'; import type { CopyMode } from './copy_mode_control'; import { CopyModeControl } from './copy_mode_control'; import { SelectableSpacesControl } from './selectable_spaces_control'; interface Props { - savedObjectTarget: Required; - spaces: Space[]; + savedObjectTarget: Required; + spaces: SpacesDataEntry[]; onUpdate: (copyOptions: CopyOptions) => void; copyOptions: CopyOptions; } diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts index f3173e14aa79..6001920f34c1 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts @@ -6,4 +6,3 @@ */ export { getCopyToSpaceFlyoutComponent } from './copy_to_space_flyout'; -export type { CopyToSpaceFlyoutProps } from './copy_to_space_flyout_internal'; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx index 1fba249e5410..91ee2acf6bb4 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx @@ -15,21 +15,21 @@ import { import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { ProcessedImportResponse } from 'src/plugins/saved_objects_management/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { SpacesDataEntry } from '../../types'; +import type { ProcessedImportResponse } from '../lib'; import { summarizeCopyResult } from '../lib'; -import type { CopyOptions, ImportRetry, SavedObjectTarget } from '../types'; +import type { CopyOptions, CopyToSpaceSavedObjectTarget, ImportRetry } from '../types'; import { SpaceResult, SpaceResultProcessing } from './space_result'; interface Props { - savedObjectTarget: Required; + savedObjectTarget: Required; copyInProgress: boolean; conflictResolutionInProgress: boolean; copyResult: Record; retries: Record; onRetriesChange: (retries: Record) => void; - spaces: Space[]; + spaces: SpacesDataEntry[]; copyOptions: CopyOptions; } @@ -95,7 +95,7 @@ export const ProcessingCopyToSpace = (props: Props) => { {props.copyOptions.selectedSpaceIds.map((id) => { - const space = props.spaces.find((s) => s.id === id) as Space; + const space = props.spaces.find((s) => s.id === id)!; const spaceCopyResult = props.copyResult[space.id]; const summarizedSpaceCopyResult = summarizeCopyResult( props.savedObjectTarget, diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx index 2f96646844a3..57b55ac5a261 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx @@ -12,10 +12,10 @@ import { EuiIconTip, EuiLoadingSpinner, EuiSelectable } from '@elastic/eui'; import React, { lazy, Suspense } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../common'; import { getSpaceAvatarComponent } from '../../space_avatar'; +import type { SpacesDataEntry } from '../../types'; // No need to wrap LazySpaceAvatar in an error boundary, because it is one of the first chunks loaded when opening Kibana. const LazySpaceAvatar = lazy(() => @@ -23,7 +23,7 @@ const LazySpaceAvatar = lazy(() => ); interface Props { - spaces: Space[]; + spaces: SpacesDataEntry[]; selectedSpaceIds: string[]; disabledSpaceIds: Set; onChange: (selectedSpaceIds: string[]) => void; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx index 6d14584ac21a..932b8bc9254f 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx @@ -17,9 +17,8 @@ import { } from '@elastic/eui'; import React, { lazy, Suspense, useState } from 'react'; -import type { Space } from 'src/plugins/spaces_oss/common'; - import { getSpaceAvatarComponent } from '../../space_avatar'; +import type { SpacesDataEntry } from '../../types'; import type { SummarizedCopyToSpaceResult } from '../lib'; import type { ImportRetry } from '../types'; import { CopyStatusSummaryIndicator } from './copy_status_summary_indicator'; @@ -31,7 +30,7 @@ const LazySpaceAvatar = lazy(() => ); interface Props { - space: Space; + space: SpacesDataEntry; summarizedCopyResult: SummarizedCopyToSpaceResult; retries: ImportRetry[]; onRetriesChange: (retries: ImportRetry[]) => void; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx index e2db8e7fb748..d58490a86b7f 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx @@ -25,15 +25,15 @@ import type { SavedObjectsImportAmbiguousConflictError, SavedObjectsImportConflictError, } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { SpacesDataEntry } from '../../types'; import type { SummarizedCopyToSpaceResult } from '../lib'; import type { ImportRetry } from '../types'; import { CopyStatusIndicator } from './copy_status_indicator'; interface Props { summarizedCopyResult: SummarizedCopyToSpaceResult; - space: Space; + space: SpacesDataEntry; retries: ImportRetry[]; onRetriesChange: (retries: ImportRetry[]) => void; destinationMap: Map; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx deleted file mode 100644 index 7818e648dd1c..000000000000 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { lazy } from 'react'; -import useAsync from 'react-use/lib/useAsync'; - -import { i18n } from '@kbn/i18n'; -import type { StartServicesAccessor } from 'src/core/public'; -import type { SavedObjectsManagementRecord } from 'src/plugins/saved_objects_management/public'; - -import { SavedObjectsManagementAction } from '../../../../../src/plugins/saved_objects_management/public'; -import type { PluginsStart } from '../plugin'; -import { SuspenseErrorBoundary } from '../suspense_error_boundary'; -import type { CopyToSpaceFlyoutProps } from './components'; -import { getCopyToSpaceFlyoutComponent } from './components'; - -const LazyCopyToSpaceFlyout = lazy(() => - getCopyToSpaceFlyoutComponent().then((component) => ({ default: component })) -); - -interface WrapperProps { - getStartServices: StartServicesAccessor; - props: CopyToSpaceFlyoutProps; -} - -const Wrapper = ({ getStartServices, props }: WrapperProps) => { - const { value: startServices = [{ notifications: undefined }] } = useAsync(getStartServices); - const [{ notifications }] = startServices; - - if (!notifications) { - return null; - } - - return ( - - - - ); -}; - -export class CopyToSpaceSavedObjectsManagementAction extends SavedObjectsManagementAction { - public id: string = 'copy_saved_objects_to_space'; - - public euiAction = { - name: i18n.translate('xpack.spaces.management.copyToSpace.actionTitle', { - defaultMessage: 'Copy to space', - }), - description: i18n.translate('xpack.spaces.management.copyToSpace.actionDescription', { - defaultMessage: 'Make a copy of this saved object in one or more spaces', - }), - icon: 'copy', - type: 'icon', - available: (object: SavedObjectsManagementRecord) => { - return object.meta.namespaceType !== 'agnostic' && !object.meta.hiddenType; - }, - onClick: (object: SavedObjectsManagementRecord) => { - this.start(object); - }, - }; - - constructor(private getStartServices: StartServicesAccessor) { - super(); - } - - public render = () => { - if (!this.record) { - throw new Error('No record available! `render()` was likely called before `start()`.'); - } - - const props: CopyToSpaceFlyoutProps = { - onClose: this.onClose, - savedObjectTarget: { - type: this.record.type, - id: this.record.id, - namespaces: this.record.namespaces ?? [], - title: this.record.meta.title, - icon: this.record.meta.icon, - }, - }; - - return ; - }; - - private onClose = () => { - this.finish(); - }; -} diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts deleted file mode 100644 index f55a7d805460..000000000000 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts +++ /dev/null @@ -1,32 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { coreMock } from 'src/core/public/mocks'; -import { savedObjectsManagementPluginMock } from 'src/plugins/saved_objects_management/public/mocks'; - -import { CopyToSpaceSavedObjectsManagementAction } from './copy_saved_objects_to_space_action'; -import { CopySavedObjectsToSpaceService } from './copy_saved_objects_to_space_service'; - -describe('CopySavedObjectsToSpaceService', () => { - describe('#setup', () => { - it('registers the CopyToSpaceSavedObjectsManagementAction', () => { - const { getStartServices } = coreMock.createSetup(); - const deps = { - savedObjectsManagementSetup: savedObjectsManagementPluginMock.createSetupContract(), - getStartServices, - }; - - const service = new CopySavedObjectsToSpaceService(); - service.setup(deps); - - expect(deps.savedObjectsManagementSetup.actions.register).toHaveBeenCalledTimes(1); - expect(deps.savedObjectsManagementSetup.actions.register).toHaveBeenCalledWith( - expect.any(CopyToSpaceSavedObjectsManagementAction) - ); - }); - }); -}); diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts deleted file mode 100644 index 17bb26cbf7f1..000000000000 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts +++ /dev/null @@ -1,24 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { StartServicesAccessor } from 'src/core/public'; -import type { SavedObjectsManagementPluginSetup } from 'src/plugins/saved_objects_management/public'; - -import type { PluginsStart } from '../plugin'; -import { CopyToSpaceSavedObjectsManagementAction } from './copy_saved_objects_to_space_action'; - -interface SetupDeps { - savedObjectsManagementSetup: SavedObjectsManagementPluginSetup; - getStartServices: StartServicesAccessor; -} - -export class CopySavedObjectsToSpaceService { - public setup({ savedObjectsManagementSetup, getStartServices }: SetupDeps) { - const action = new CopyToSpaceSavedObjectsManagementAction(getStartServices); - savedObjectsManagementSetup.actions.register(action); - } -} diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/index.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/index.ts index abbbc8ba1368..2443c8443c09 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/index.ts +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/index.ts @@ -6,4 +6,4 @@ */ export { getCopyToSpaceFlyoutComponent } from './components'; -export { CopySavedObjectsToSpaceService } from './copy_saved_objects_to_space_service'; +export type { CopyToSpaceFlyoutProps, CopyToSpaceSavedObjectTarget } from './types'; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/index.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/index.ts index 882ee234ca5d..70a5cadd527b 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/index.ts +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/index.ts @@ -5,6 +5,9 @@ * 2.0. */ +export type { FailedImport, ProcessedImportResponse } from './process_import_response'; +export { processImportResponse } from './process_import_response'; + export type { SummarizedCopyToSpaceResult, SummarizedSavedObjectResult, diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/process_import_response.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/process_import_response.ts new file mode 100644 index 000000000000..cf402b0dd4ec --- /dev/null +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/process_import_response.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { + SavedObjectsImportAmbiguousConflictError, + SavedObjectsImportConflictError, + SavedObjectsImportFailure, + SavedObjectsImportMissingReferencesError, + SavedObjectsImportResponse, + SavedObjectsImportSuccess, + SavedObjectsImportUnknownError, + SavedObjectsImportUnsupportedTypeError, +} from 'src/core/public'; + +export interface FailedImport { + obj: Omit; + error: + | SavedObjectsImportConflictError + | SavedObjectsImportAmbiguousConflictError + | SavedObjectsImportUnsupportedTypeError + | SavedObjectsImportMissingReferencesError + | SavedObjectsImportUnknownError; +} + +export interface ProcessedImportResponse { + success: boolean; + failedImports: FailedImport[]; + successfulImports: SavedObjectsImportSuccess[]; +} + +// This is derived from the function of the same name in the savedObjectsManagement plugin +export function processImportResponse( + response: SavedObjectsImportResponse +): ProcessedImportResponse { + const { success, errors = [], successResults = [] } = response; + const failedImports = errors.map(({ error, ...obj }) => ({ obj, error })); + return { + success, + failedImports, + successfulImports: successResults, + }; +} diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.test.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.test.ts index 6a3d82aaef59..298b89050b63 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.test.ts +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.test.ts @@ -5,13 +5,8 @@ * 2.0. */ -import type { - FailedImport, - ProcessedImportResponse, - SavedObjectsManagementRecord, -} from 'src/plugins/saved_objects_management/public'; - -import type { SavedObjectTarget } from '../types'; +import type { FailedImport, ProcessedImportResponse } from '../lib'; +import type { CopyToSpaceSavedObjectTarget } from '../types'; import { summarizeCopyResult } from './summarize_copy_result'; // Sample data references: @@ -29,7 +24,7 @@ const OBJECTS = { namespaces: [], icon: 'dashboardApp', title: 'my-dashboard-title', - } as Required, + } as Required, MY_DASHBOARD: { type: 'dashboard', id: 'foo', @@ -43,7 +38,7 @@ const OBJECTS = { { type: 'visualization', id: 'foo', name: 'Visualization foo' }, { type: 'visualization', id: 'bar', name: 'Visualization bar' }, ], - } as SavedObjectsManagementRecord, + }, VISUALIZATION_FOO: { type: 'visualization', id: 'bar', @@ -54,7 +49,7 @@ const OBJECTS = { hiddenType: false, }, references: [{ type: 'index-pattern', id: 'foo', name: 'Index pattern foo' }], - } as SavedObjectsManagementRecord, + }, VISUALIZATION_BAR: { type: 'visualization', id: 'baz', @@ -65,7 +60,7 @@ const OBJECTS = { hiddenType: false, }, references: [{ type: 'index-pattern', id: 'bar', name: 'Index pattern bar' }], - } as SavedObjectsManagementRecord, + }, INDEX_PATTERN_FOO: { type: 'index-pattern', id: 'foo', @@ -76,7 +71,7 @@ const OBJECTS = { hiddenType: false, }, references: [], - } as SavedObjectsManagementRecord, + }, INDEX_PATTERN_BAR: { type: 'index-pattern', id: 'bar', @@ -87,7 +82,7 @@ const OBJECTS = { hiddenType: false, }, references: [], - } as SavedObjectsManagementRecord, + }, }; interface ObjectProperties { diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.ts index 68baba12d8b9..206952774ff9 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.ts +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/summarize_copy_result.ts @@ -9,12 +9,9 @@ import type { SavedObjectsImportAmbiguousConflictError, SavedObjectsImportConflictError, } from 'src/core/public'; -import type { - FailedImport, - ProcessedImportResponse, -} from 'src/plugins/saved_objects_management/public'; -import type { SavedObjectTarget } from '../types'; +import type { FailedImport, ProcessedImportResponse } from '../lib'; +import type { CopyToSpaceSavedObjectTarget } from '../types'; export interface SummarizedSavedObjectResult { type: string; @@ -68,7 +65,7 @@ export type SummarizedCopyToSpaceResult = | ProcessingResponse; export function summarizeCopyResult( - savedObjectTarget: Required, + savedObjectTarget: Required, copyResult: ProcessedImportResponse | undefined ): SummarizedCopyToSpaceResult { const conflicts = copyResult?.failedImports.filter(isAnyConflict) ?? []; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/types.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/types.ts index 60a4e176f40b..732d779c6f61 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/types.ts +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/types.ts @@ -20,7 +20,24 @@ export interface CopySavedObjectsToSpaceResponse { [spaceId: string]: SavedObjectsImportResponse; } -export interface SavedObjectTarget { +/** + * Properties for the CopyToSpaceFlyout. + */ +export interface CopyToSpaceFlyoutProps { + /** + * The object to render the flyout for. + */ + savedObjectTarget: CopyToSpaceSavedObjectTarget; + /** + * Optional callback when the flyout is closed. + */ + onClose?: () => void; +} + +/** + * Describes the target saved object during a copy operation. + */ +export interface CopyToSpaceSavedObjectTarget { /** * The object's type. */ diff --git a/x-pack/plugins/spaces/public/index.ts b/x-pack/plugins/spaces/public/index.ts index 08dda35a6eb1..d13f8f48e671 100644 --- a/x-pack/plugins/spaces/public/index.ts +++ b/x-pack/plugins/spaces/public/index.ts @@ -11,10 +11,28 @@ export { getSpaceColor, getSpaceImageUrl, getSpaceInitials } from './space_avata export { SpacesPluginSetup, SpacesPluginStart } from './plugin'; -export type { GetAllSpacesPurpose, GetSpaceResult } from '../common'; +export type { Space, GetAllSpacesPurpose, GetSpaceResult } from '../common'; -// re-export types from oss definition -export type { Space } from 'src/plugins/spaces_oss/common'; +export type { SpacesData, SpacesDataEntry, SpacesApi } from './types'; + +export type { + CopyToSpaceFlyoutProps, + CopyToSpaceSavedObjectTarget, +} from './copy_saved_objects_to_space'; + +export type { + LegacyUrlConflictProps, + ShareToSpaceFlyoutProps, + ShareToSpaceSavedObjectTarget, +} from './share_saved_objects_to_space'; + +export type { SpaceAvatarProps } from './space_avatar'; + +export type { SpaceListProps } from './space_list'; + +export type { SpacesContextProps, SpacesReactContextValue } from './spaces_context'; + +export type { LazyComponentFn, SpacesApiUi, SpacesApiUiComponent } from './ui_api'; export const plugin = () => { return new SpacesPlugin(); diff --git a/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx index f3ed578a9496..4c808f9a4758 100644 --- a/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx +++ b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx @@ -13,9 +13,9 @@ import useAsyncFn from 'react-use/lib/useAsyncFn'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import type { Space } from '../../../../common'; import type { SpacesManager } from '../../../spaces_manager'; interface Props { diff --git a/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx b/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx index 92b68426d172..dc78441c3ba0 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx @@ -12,8 +12,8 @@ import React, { Component, Fragment } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { NotificationsStart } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; import type { SpacesManager } from '../../spaces_manager'; import { ConfirmDeleteModal } from '../components/confirm_delete_modal'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx index 748167643030..9860d701ee4a 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx @@ -11,10 +11,10 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; import type { KibanaFeatureConfig } from '../../../../../features/public'; +import type { Space } from '../../../../common'; import { SectionPanel } from '../section_panel'; import { FeatureTable } from './feature_table'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx index 78ea73741a8a..2371a97370b5 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx @@ -25,9 +25,9 @@ import React, { Component } from 'react'; import { i18n } from '@kbn/i18n'; import type { AppCategory } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; import type { KibanaFeatureConfig } from '../../../../../features/public'; +import type { Space } from '../../../../common'; import { getEnabledFeatures } from '../../lib/feature_utils'; interface Props { diff --git a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx index 5a7ae701e97e..bd0621e539ed 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx @@ -23,10 +23,10 @@ import React, { Component } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { Capabilities, NotificationsStart, ScopedHistory } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { SectionLoading } from '../../../../../../src/plugins/es_ui_shared/public'; import type { FeaturesPluginStart, KibanaFeature } from '../../../../features/public'; +import type { Space } from '../../../common'; import { isReservedSpace } from '../../../common'; import { getSpacesFeatureDescription } from '../../constants'; import { getSpaceColor, getSpaceInitials } from '../../space_avatar'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx index da32ea79724a..6415444a0562 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx @@ -9,8 +9,8 @@ import { EuiBadge, EuiToolTip } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; import { isReservedSpace } from '../../../common'; interface Props { diff --git a/x-pack/plugins/spaces/public/management/lib/feature_utils.ts b/x-pack/plugins/spaces/public/management/lib/feature_utils.ts index d332b3e34c0a..7598e18d6680 100644 --- a/x-pack/plugins/spaces/public/management/lib/feature_utils.ts +++ b/x-pack/plugins/spaces/public/management/lib/feature_utils.ts @@ -5,9 +5,8 @@ * 2.0. */ -import type { Space } from 'src/plugins/spaces_oss/common'; - import type { KibanaFeatureConfig } from '../../../../features/common'; +import type { Space } from '../../../common'; export function getEnabledFeatures(features: KibanaFeatureConfig[], space: Partial) { return features.filter((feature) => !(space.disabledFeatures || []).includes(feature.id)); diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx index 200b868a1b10..e40f92bd5448 100644 --- a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx @@ -26,10 +26,10 @@ import type { NotificationsStart, ScopedHistory, } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { reactRouterNavigate } from '../../../../../../src/plugins/kibana_react/public'; import type { FeaturesPluginStart, KibanaFeature } from '../../../../features/public'; +import type { Space } from '../../../common'; import { isReservedSpace } from '../../../common'; import { DEFAULT_SPACE_ID } from '../../../common/constants'; import { getSpacesFeatureDescription } from '../../constants'; diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx index 4bf8b46fecb7..a7a7591b9456 100644 --- a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx @@ -12,13 +12,13 @@ import { Route, Router, Switch, useParams } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import type { StartServicesAccessor } from 'src/core/public'; import type { RegisterManagementAppArgs } from 'src/plugins/management/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { APP_WRAPPER_CLASS } from '../../../../../src/core/public'; import { KibanaContextProvider, RedirectAppLinks, } from '../../../../../src/plugins/kibana_react/public'; +import type { Space } from '../../common'; import type { PluginsStart } from '../plugin'; import type { SpacesManager } from '../spaces_manager'; diff --git a/src/plugins/spaces_oss/public/api.mock.ts b/x-pack/plugins/spaces/public/mocks.ts similarity index 68% rename from src/plugins/spaces_oss/public/api.mock.ts rename to x-pack/plugins/spaces/public/mocks.ts index 9ad7599b5ae6..897f58e1d649 100644 --- a/src/plugins/spaces_oss/public/api.mock.ts +++ b/x-pack/plugins/spaces/public/mocks.ts @@ -1,14 +1,15 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { of } from 'rxjs'; -import type { SpacesApi, SpacesApiUi, SpacesApiUiComponent } from './api'; +import type { SpacesPluginStart } from './plugin'; +import type { SpacesApi } from './types'; +import type { SpacesApiUi, SpacesApiUiComponent } from './ui_api'; const createApiMock = (): jest.Mocked => ({ getActiveSpace$: jest.fn().mockReturnValue(of()), @@ -24,6 +25,7 @@ const createApiUiMock = () => { const mock: SpacesApiUiMock = { components: createApiUiComponentsMock(), redirectLegacyUrl: jest.fn(), + useSpaces: jest.fn(), }; return mock; @@ -35,6 +37,7 @@ const createApiUiComponentsMock = () => { const mock: SpacesApiUiComponentMock = { getSpacesContextProvider: jest.fn(), getShareToSpaceFlyout: jest.fn(), + getCopyToSpaceFlyout: jest.fn(), getSpaceList: jest.fn(), getLegacyUrlConflict: jest.fn(), getSpaceAvatar: jest.fn(), @@ -43,6 +46,8 @@ const createApiUiComponentsMock = () => { return mock; }; -export const spacesApiMock = { - create: createApiMock, +const createStartContract = (): jest.Mocked => createApiMock(); + +export const spacesPluginMock = { + createStartContract, }; diff --git a/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx index 392a95c44592..5fafe151dade 100644 --- a/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx +++ b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx @@ -21,8 +21,8 @@ import React, { Component, lazy, Suspense } from 'react'; import type { InjectedIntl } from '@kbn/i18n/react'; import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; import type { ApplicationStart, Capabilities } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; import { addSpaceIdToPath, ENTER_SPACE_PATH, SPACE_SEARCH_COUNT_THRESHOLD } from '../../../common'; import { getSpaceAvatarComponent } from '../../space_avatar'; import { ManageSpacesButton } from './manage_spaces_button'; diff --git a/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx index 1653506c550f..41a05a38fa30 100644 --- a/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx +++ b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx @@ -11,8 +11,8 @@ import React, { Component, lazy, Suspense } from 'react'; import type { Subscription } from 'rxjs'; import type { ApplicationStart, Capabilities } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../common'; import { getSpaceAvatarComponent } from '../space_avatar'; import type { SpacesManager } from '../spaces_manager'; import { SpacesDescription } from './components/spaces_description'; diff --git a/x-pack/plugins/spaces/public/plugin.test.ts b/x-pack/plugins/spaces/public/plugin.test.ts index 39478ca2fd9b..43b701c48b2c 100644 --- a/x-pack/plugins/spaces/public/plugin.test.ts +++ b/x-pack/plugins/spaces/public/plugin.test.ts @@ -12,7 +12,6 @@ import { createManagementSectionMock, managementPluginMock, } from 'src/plugins/management/public/mocks'; -import { spacesOssPluginMock } from 'src/plugins/spaces_oss/public/mocks'; import { SpacesPlugin } from './plugin'; @@ -20,12 +19,9 @@ describe('Spaces plugin', () => { describe('#setup', () => { it('should register the spaces API and the space selector app', () => { const coreSetup = coreMock.createSetup(); - const spacesOss = spacesOssPluginMock.createSetupContract(); const plugin = new SpacesPlugin(); - plugin.setup(coreSetup, { spacesOss }); - - expect(spacesOss.registerSpacesApi).toHaveBeenCalledTimes(1); + plugin.setup(coreSetup, {}); expect(coreSetup.application.register).toHaveBeenCalledWith( expect.objectContaining({ @@ -39,7 +35,6 @@ describe('Spaces plugin', () => { it('should register the management and feature catalogue sections when the management and home plugins are both available', () => { const coreSetup = coreMock.createSetup(); - const spacesOss = spacesOssPluginMock.createSetupContract(); const home = homePluginMock.createSetupContract(); const management = managementPluginMock.createSetupContract(); @@ -50,7 +45,6 @@ describe('Spaces plugin', () => { const plugin = new SpacesPlugin(); plugin.setup(coreSetup, { - spacesOss, management, home, }); @@ -71,11 +65,10 @@ describe('Spaces plugin', () => { it('should register the advanced settings components if the advanced_settings plugin is available', () => { const coreSetup = coreMock.createSetup(); - const spacesOss = spacesOssPluginMock.createSetupContract(); const advancedSettings = advancedSettingsMock.createSetupContract(); const plugin = new SpacesPlugin(); - plugin.setup(coreSetup, { spacesOss, advancedSettings }); + plugin.setup(coreSetup, { advancedSettings }); expect(advancedSettings.component.register.mock.calls).toMatchInlineSnapshot(` Array [ @@ -97,11 +90,10 @@ describe('Spaces plugin', () => { describe('#start', () => { it('should register the spaces nav control', () => { const coreSetup = coreMock.createSetup(); - const spacesOss = spacesOssPluginMock.createSetupContract(); const coreStart = coreMock.createStart(); const plugin = new SpacesPlugin(); - plugin.setup(coreSetup, { spacesOss }); + plugin.setup(coreSetup, {}); plugin.start(coreStart); diff --git a/x-pack/plugins/spaces/public/plugin.tsx b/x-pack/plugins/spaces/public/plugin.tsx index 1ba1cd1a1f3d..782cb3ba708a 100644 --- a/x-pack/plugins/spaces/public/plugin.tsx +++ b/x-pack/plugins/spaces/public/plugin.tsx @@ -9,26 +9,21 @@ import type { CoreSetup, CoreStart, Plugin } from 'src/core/public'; import type { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public'; import type { HomePublicPluginSetup } from 'src/plugins/home/public'; import type { ManagementSetup, ManagementStart } from 'src/plugins/management/public'; -import type { SavedObjectsManagementPluginSetup } from 'src/plugins/saved_objects_management/public'; -import type { SpacesApi, SpacesOssPluginSetup } from 'src/plugins/spaces_oss/public'; import type { FeaturesPluginStart } from '../../features/public'; import { AdvancedSettingsService } from './advanced_settings'; -import { CopySavedObjectsToSpaceService } from './copy_saved_objects_to_space'; import { createSpacesFeatureCatalogueEntry } from './create_feature_catalogue_entry'; import { ManagementService } from './management'; import { initSpacesNavControl } from './nav_control'; -import { ShareSavedObjectsToSpaceService } from './share_saved_objects_to_space'; import { spaceSelectorApp } from './space_selector'; import { SpacesManager } from './spaces_manager'; +import type { SpacesApi } from './types'; import { getUiApi } from './ui_api'; export interface PluginsSetup { - spacesOss: SpacesOssPluginSetup; advancedSettings?: AdvancedSettingsSetup; home?: HomePublicPluginSetup; management?: ManagementSetup; - savedObjectsManagement?: SavedObjectsManagementPluginSetup; } export interface PluginsStart { @@ -84,27 +79,12 @@ export class SpacesPlugin implements Plugin ); interface Props { - spaces: ShareToSpaceTarget[]; + spaces: SpacesDataEntry[]; aliasesToDisable: InternalLegacyUrlAliasTarget[]; } @@ -38,10 +38,7 @@ export const AliasTable: FunctionComponent = ({ spaces, aliasesToDisable const spacesMap = useMemo( () => - spaces.reduce( - (acc, space) => acc.set(space.id, space), - new Map() - ), + spaces.reduce((acc, space) => acc.set(space.id, space), new Map()), [spaces] ); const filteredAliasesToDisable = useMemo( diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict.tsx index f053c081ab58..8aaf455204c9 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict.tsx @@ -7,8 +7,7 @@ import React from 'react'; -import type { LegacyUrlConflictProps } from 'src/plugins/spaces_oss/public'; - +import type { LegacyUrlConflictProps } from '../types'; import type { InternalProps } from './legacy_url_conflict_internal'; export const getLegacyUrlConflict = async ( diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict_internal.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict_internal.tsx index 1ebde52a734c..95bf7b404db3 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict_internal.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/legacy_url_conflict_internal.tsx @@ -18,9 +18,9 @@ import { first } from 'rxjs/operators'; import { FormattedMessage } from '@kbn/i18n/react'; import type { ApplicationStart, StartServicesAccessor } from 'src/core/public'; -import type { LegacyUrlConflictProps } from 'src/plugins/spaces_oss/public'; import type { PluginsStart } from '../../plugin'; +import type { LegacyUrlConflictProps } from '../types'; import { DEFAULT_OBJECT_NOUN } from './constants'; export interface InternalProps { diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/relatives_footer.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/relatives_footer.tsx index ea3f29724e0d..97318ea5312b 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/relatives_footer.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/relatives_footer.tsx @@ -10,7 +10,8 @@ import React, { useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import type { SavedObjectReferenceWithContext } from 'src/core/public'; -import type { ShareToSpaceSavedObjectTarget } from 'src/plugins/spaces_oss/public'; + +import type { ShareToSpaceSavedObjectTarget } from '../types'; interface Props { savedObjectTarget: ShareToSpaceSavedObjectTarget; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/selectable_spaces_control.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/selectable_spaces_control.tsx index fad819d35e18..4e45487a2056 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/selectable_spaces_control.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/selectable_spaces_control.tsx @@ -29,7 +29,7 @@ import { ALL_SPACES_ID, UNKNOWN_SPACE } from '../../../common/constants'; import { DocumentationLinksService } from '../../lib'; import { getSpaceAvatarComponent } from '../../space_avatar'; import { useSpaces } from '../../spaces_context'; -import type { ShareToSpaceTarget } from '../../types'; +import type { SpacesDataEntry } from '../../types'; import type { ShareOptions } from '../types'; import { NoSpacesAvailable } from './no_spaces_available'; @@ -39,7 +39,7 @@ const LazySpaceAvatar = lazy(() => ); interface Props { - spaces: ShareToSpaceTarget[]; + spaces: SpacesDataEntry[]; shareOptions: ShareOptions; onChange: (selectedSpaceIds: string[]) => void; enableCreateNewSpaceLink: boolean; @@ -248,7 +248,7 @@ export const SelectableSpacesControl = (props: Props) => { * Gets additional props for the selection option. */ function getAdditionalProps( - space: ShareToSpaceTarget, + space: SpacesDataEntry, activeSpaceId: string | false, checked: boolean ) { @@ -259,7 +259,7 @@ function getAdditionalProps( checked: 'on' as 'on', }; } - if (space.cannotShareToSpace) { + if (!space.isAuthorizedForPurpose('shareSavedObjectsIntoSpace')) { return { append: ( <> @@ -280,11 +280,11 @@ function getAdditionalProps( } /** - * Given the active space, create a comparator to sort a ShareToSpaceTarget array so that the active space is at the beginning, and space(s) for + * Given the active space, create a comparator to sort a SpacesDataEntry array so that the active space is at the beginning, and space(s) for * which the current feature is disabled are all at the end. */ function createSpacesComparator(activeSpaceId: string | false) { - return (a: ShareToSpaceTarget, b: ShareToSpaceTarget) => { + return (a: SpacesDataEntry, b: SpacesDataEntry) => { if (a.id === activeSpaceId) { return -1; } diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_mode_control.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_mode_control.tsx index 7151f72583d6..07439542bf83 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_mode_control.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_mode_control.tsx @@ -24,12 +24,12 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { ALL_SPACES_ID } from '../../../common/constants'; import { DocumentationLinksService } from '../../lib'; import { useSpaces } from '../../spaces_context'; -import type { ShareToSpaceTarget } from '../../types'; +import type { SpacesDataEntry } from '../../types'; import type { ShareOptions } from '../types'; import { SelectableSpacesControl } from './selectable_spaces_control'; interface Props { - spaces: ShareToSpaceTarget[]; + spaces: SpacesDataEntry[]; objectNoun: string; canShareToAllSpaces: boolean; shareOptions: ShareOptions; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx index dc2a358a653a..e0f25277c50f 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx @@ -7,7 +7,7 @@ import React from 'react'; -import type { ShareToSpaceFlyoutProps } from 'src/plugins/spaces_oss/public'; +import type { ShareToSpaceFlyoutProps } from '../types'; export const getShareToSpaceFlyoutComponent = async (): Promise< React.FC diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx index f02cae767405..8b435865c760 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx @@ -14,8 +14,8 @@ import React from 'react'; import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; import type { SavedObjectReferenceWithContext } from 'src/core/public'; import { coreMock } from 'src/core/public/mocks'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; import { ALL_SPACES_ID } from '../../../common/constants'; import { CopyToSpaceFlyoutInternal } from '../../copy_saved_objects_to_space/components/copy_to_space_flyout_internal'; import { getSpacesContextProviderWrapper } from '../../spaces_context'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.tsx index 712adeb26bcc..076825e7c70a 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.tsx @@ -26,17 +26,17 @@ import React, { lazy, Suspense, useEffect, useMemo, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { SavedObjectReferenceWithContext, ToastsStart } from 'src/core/public'; -import type { - ShareToSpaceFlyoutProps, - ShareToSpaceSavedObjectTarget, -} from 'src/plugins/spaces_oss/public'; import { ALL_SPACES_ID, UNKNOWN_SPACE } from '../../../common/constants'; import { getCopyToSpaceFlyoutComponent } from '../../copy_saved_objects_to_space'; import { useSpaces } from '../../spaces_context'; import type { SpacesManager } from '../../spaces_manager'; -import type { ShareToSpaceTarget } from '../../types'; -import type { ShareOptions } from '../types'; +import type { SpacesDataEntry } from '../../types'; +import type { + ShareOptions, + ShareToSpaceFlyoutProps, + ShareToSpaceSavedObjectTarget, +} from '../types'; import { AliasTable } from './alias_table'; import { DEFAULT_OBJECT_NOUN } from './constants'; import { RelativesFooter } from './relatives_footer'; @@ -124,7 +124,7 @@ function createDefaultChangeSpacesHandler( } export const ShareToSpaceFlyoutInternal = (props: ShareToSpaceFlyoutProps) => { - const { spacesManager, shareToSpacesDataPromise, services } = useSpaces(); + const { spacesManager, spacesDataPromise, services } = useSpaces(); const { notifications } = services; const toastNotifications = notifications!.toasts; @@ -168,7 +168,7 @@ export const ShareToSpaceFlyoutInternal = (props: ShareToSpaceFlyoutProps) => { const [{ isLoading, spaces, referenceGraph, aliasTargets }, setSpacesState] = useState<{ isLoading: boolean; - spaces: ShareToSpaceTarget[]; + spaces: SpacesDataEntry[]; referenceGraph: SavedObjectReferenceWithContext[]; aliasTargets: InternalLegacyUrlAliasTarget[]; }>({ isLoading: true, spaces: [], referenceGraph: [], aliasTargets: [] }); @@ -176,9 +176,9 @@ export const ShareToSpaceFlyoutInternal = (props: ShareToSpaceFlyoutProps) => { const { type, id } = savedObjectTarget; const getShareableReferences = spacesManager.getShareableReferences([{ type, id }]); const getPermissions = spacesManager.getShareSavedObjectPermissions(type); - Promise.all([shareToSpacesDataPromise, getShareableReferences, getPermissions]) - .then(([shareToSpacesData, shareableReferences, permissions]) => { - const activeSpaceId = !enableSpaceAgnosticBehavior && shareToSpacesData.activeSpaceId; + Promise.all([spacesDataPromise, getShareableReferences, getPermissions]) + .then(([spacesData, shareableReferences, permissions]) => { + const activeSpaceId = !enableSpaceAgnosticBehavior && spacesData.activeSpaceId; const selectedSpaceIds = savedObjectTarget.namespaces.filter( (spaceId) => spaceId !== activeSpaceId ); @@ -189,13 +189,13 @@ export const ShareToSpaceFlyoutInternal = (props: ShareToSpaceFlyoutProps) => { setCanShareToAllSpaces(permissions.shareToAllSpaces); setSpacesState({ isLoading: false, - spaces: [...shareToSpacesData.spacesMap].map(([, spaceTarget]) => spaceTarget), + spaces: [...spacesData.spacesMap].map(([, spaceTarget]) => spaceTarget), referenceGraph: shareableReferences.objects, aliasTargets: shareableReferences.objects.reduce( (acc, x) => { for (const space of x.spacesWithMatchingAliases ?? []) { if (space !== '?') { - const spaceExists = shareToSpacesData.spacesMap.has(space); + const spaceExists = spacesData.spacesMap.has(space); // If the user does not have privileges to view all spaces, they will be redacted; we cannot attempt to disable aliases for redacted spaces. acc.push({ targetSpace: space, targetType: x.type, sourceId: x.id, spaceExists }); } @@ -216,7 +216,7 @@ export const ShareToSpaceFlyoutInternal = (props: ShareToSpaceFlyoutProps) => { }, [ savedObjectTarget, spacesManager, - shareToSpacesDataPromise, + spacesDataPromise, toastNotifications, enableSpaceAgnosticBehavior, ]); diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_form.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_form.tsx index 7f8c659805c4..1841d634c648 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_form.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_form.tsx @@ -12,12 +12,12 @@ import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { ShareToSpaceTarget } from '../../types'; +import type { SpacesDataEntry } from '../../types'; import type { ShareOptions } from '../types'; import { ShareModeControl } from './share_mode_control'; interface Props { - spaces: ShareToSpaceTarget[]; + spaces: SpacesDataEntry[]; objectNoun: string; onUpdate: (shareOptions: ShareOptions) => void; shareOptions: ShareOptions; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/index.ts b/x-pack/plugins/spaces/public/share_saved_objects_to_space/index.ts index beed0fd9d592..fe90ee8d6a8a 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/index.ts +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/index.ts @@ -5,6 +5,10 @@ * 2.0. */ -export { ShareSavedObjectsToSpaceService } from './share_saved_objects_to_space_service'; export { getShareToSpaceFlyoutComponent, getLegacyUrlConflict } from './components'; export { createRedirectLegacyUrl } from './utils'; +export type { + LegacyUrlConflictProps, + ShareToSpaceFlyoutProps, + ShareToSpaceSavedObjectTarget, +} from './types'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.test.ts b/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.test.ts deleted file mode 100644 index eb973a48ef87..000000000000 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.test.ts +++ /dev/null @@ -1,38 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { savedObjectsManagementPluginMock } from 'src/plugins/saved_objects_management/public/mocks'; - -import { uiApiMock } from '../ui_api/mocks'; -import { ShareToSpaceSavedObjectsManagementAction } from './share_saved_objects_to_space_action'; -// import { ShareToSpaceSavedObjectsManagementColumn } from './share_saved_objects_to_space_column'; -import { ShareSavedObjectsToSpaceService } from './share_saved_objects_to_space_service'; - -describe('ShareSavedObjectsToSpaceService', () => { - describe('#setup', () => { - it('registers the ShareToSpaceSavedObjectsManagement Action and Column', () => { - const deps = { - savedObjectsManagementSetup: savedObjectsManagementPluginMock.createSetupContract(), - spacesApiUi: uiApiMock.create(), - }; - - const service = new ShareSavedObjectsToSpaceService(); - service.setup(deps); - - expect(deps.savedObjectsManagementSetup.actions.register).toHaveBeenCalledTimes(1); - expect(deps.savedObjectsManagementSetup.actions.register).toHaveBeenCalledWith( - expect.any(ShareToSpaceSavedObjectsManagementAction) - ); - - // expect(deps.savedObjectsManagementSetup.columns.register).toHaveBeenCalledTimes(1); - // expect(deps.savedObjectsManagementSetup.columns.register).toHaveBeenCalledWith( - // expect.any(ShareToSpaceSavedObjectsManagementColumn) - // ); - expect(deps.savedObjectsManagementSetup.columns.register).not.toHaveBeenCalled(); // ensure this test fails after column code is uncommented - }); - }); -}); diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.ts b/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.ts deleted file mode 100644 index bc7034776046..000000000000 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.ts +++ /dev/null @@ -1,27 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { SavedObjectsManagementPluginSetup } from 'src/plugins/saved_objects_management/public'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; - -import { ShareToSpaceSavedObjectsManagementAction } from './share_saved_objects_to_space_action'; -// import { ShareToSpaceSavedObjectsManagementColumn } from './share_saved_objects_to_space_column'; - -interface SetupDeps { - savedObjectsManagementSetup: SavedObjectsManagementPluginSetup; - spacesApiUi: SpacesApiUi; -} - -export class ShareSavedObjectsToSpaceService { - public setup({ savedObjectsManagementSetup, spacesApiUi }: SetupDeps) { - const action = new ShareToSpaceSavedObjectsManagementAction(spacesApiUi); - savedObjectsManagementSetup.actions.register(action); - // Note: this column is hidden for now because no saved objects are shareable. It should be uncommented when at least one saved object type is multi-namespace. - // const column = new ShareToSpaceSavedObjectsManagementColumn(spacesApiUi); - // savedObjectsManagementSetup.columns.register(column); - } -} diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/types.ts b/x-pack/plugins/spaces/public/share_saved_objects_to_space/types.ts index be8165e82273..1beccaa54628 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/types.ts +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/types.ts @@ -17,3 +17,126 @@ export type ImportRetry = Omit; export interface ShareSavedObjectsToSpaceResponse { [spaceId: string]: SavedObjectsImportResponse; } + +/** + * Properties for the LegacyUrlConflict component. + */ +export interface LegacyUrlConflictProps { + /** + * The string that is used to describe the object in the callout, e.g., _There is a legacy URL for this page that points to a different + * **object**_. + * + * Default value is 'object'. + */ + objectNoun?: string; + /** + * The ID of the object that is currently shown on the page. + */ + currentObjectId: string; + /** + * The ID of the other object that the legacy URL alias points to. + */ + otherObjectId: string; + /** + * The path to use for the new URL, optionally including `search` and/or `hash` URL components. + */ + otherObjectPath: string; +} + +/** + * Properties for the ShareToSpaceFlyout. + */ +export interface ShareToSpaceFlyoutProps { + /** + * The object to render the flyout for. + */ + savedObjectTarget: ShareToSpaceSavedObjectTarget; + /** + * The EUI icon that is rendered in the flyout's title. + * + * Default is 'share'. + */ + flyoutIcon?: string; + /** + * The string that is rendered in the flyout's title. + * + * Default is 'Edit spaces for object'. + */ + flyoutTitle?: string; + /** + * When enabled, if the object is not yet shared to multiple spaces, a callout will be displayed that suggests the user might want to + * create a copy instead. + * + * Default value is false. + */ + enableCreateCopyCallout?: boolean; + /** + * When enabled, if no other spaces exist _and_ the user has the appropriate privileges, a sentence will be displayed that suggests the + * user might want to create a space. + * + * Default value is false. + */ + enableCreateNewSpaceLink?: boolean; + /** + * When set to 'within-space' (default), the flyout behaves like it is running on a page within the active space, and it will prevent the + * user from removing the object from the active space. + * + * Conversely, when set to 'outside-space', the flyout behaves like it is running on a page outside of any space, so it will allow the + * user to remove the object from the active space. + */ + behaviorContext?: 'within-space' | 'outside-space'; + /** + * Optional handler that is called when the user has saved changes and there are spaces to be added to and/or removed from the object and + * its relatives. If this is not defined, a default handler will be used that calls `/api/spaces/_update_objects_spaces` and displays a + * toast indicating what occurred. + */ + changeSpacesHandler?: ( + objects: Array<{ type: string; id: string }>, + spacesToAdd: string[], + spacesToRemove: string[] + ) => Promise; + /** + * Optional callback when the target object and its relatives are updated. + */ + onUpdate?: (updatedObjects: Array<{ type: string; id: string }>) => void; + /** + * Optional callback when the flyout is closed. + */ + onClose?: () => void; +} + +/** + * Describes the target saved object during a share operation. + */ +export interface ShareToSpaceSavedObjectTarget { + /** + * The object's type. + */ + type: string; + /** + * The object's ID. + */ + id: string; + /** + * The namespaces that the object currently exists in. + */ + namespaces: string[]; + /** + * The EUI icon that is rendered in the flyout's subtitle. + * + * Default is 'empty'. + */ + icon?: string; + /** + * The string that is rendered in the flyout's subtitle. + * + * Default is `${type} [id=${id}]`. + */ + title?: string; + /** + * The string that is used to describe the object in several places, e.g., _Make **object** available in selected spaces only_. + * + * Default value is 'object'. + */ + noun?: string; +} diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/utils/redirect_legacy_url.ts b/x-pack/plugins/spaces/public/share_saved_objects_to_space/utils/redirect_legacy_url.ts index 338b2e8c94e0..d427b1bc0524 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/utils/redirect_legacy_url.ts +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/utils/redirect_legacy_url.ts @@ -9,9 +9,9 @@ import { first } from 'rxjs/operators'; import { i18n } from '@kbn/i18n'; import type { StartServicesAccessor } from 'src/core/public'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; import type { PluginsStart } from '../../plugin'; +import type { SpacesApiUi } from '../../ui_api'; import { DEFAULT_OBJECT_NOUN } from '../components/constants'; export function createRedirectLegacyUrl( diff --git a/x-pack/plugins/spaces/public/space_avatar/index.ts b/x-pack/plugins/spaces/public/space_avatar/index.ts index 86d94738f2c7..a8d67b396466 100644 --- a/x-pack/plugins/spaces/public/space_avatar/index.ts +++ b/x-pack/plugins/spaces/public/space_avatar/index.ts @@ -7,3 +7,4 @@ export { getSpaceAvatarComponent } from './space_avatar'; export * from './space_attributes'; +export type { SpaceAvatarProps } from './types'; diff --git a/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts b/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts index 682a61c6f23a..047e544f9405 100644 --- a/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts +++ b/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts @@ -7,8 +7,7 @@ import { VISUALIZATION_COLORS } from '@elastic/eui'; -import type { Space } from 'src/plugins/spaces_oss/common'; - +import type { Space } from '../../common'; import { MAX_SPACE_INITIALS } from '../../common'; // code point for lowercase "a" diff --git a/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx b/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx index a2d58a12c5ea..2bd86effcc65 100644 --- a/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx +++ b/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx @@ -7,7 +7,7 @@ import React from 'react'; -import type { SpaceAvatarProps } from 'src/plugins/spaces_oss/public'; +import type { SpaceAvatarProps } from './types'; export const getSpaceAvatarComponent = async (): Promise> => { const { SpaceAvatarInternal } = await import('./space_avatar_internal'); diff --git a/x-pack/plugins/spaces/public/space_avatar/space_avatar_internal.tsx b/x-pack/plugins/spaces/public/space_avatar/space_avatar_internal.tsx index 91b4dbf8a964..b8fd5ed77f48 100644 --- a/x-pack/plugins/spaces/public/space_avatar/space_avatar_internal.tsx +++ b/x-pack/plugins/spaces/public/space_avatar/space_avatar_internal.tsx @@ -10,25 +10,11 @@ import { EuiAvatar, isValidHex } from '@elastic/eui'; import type { FC } from 'react'; import React from 'react'; -import type { Space } from 'src/plugins/spaces_oss/common'; - import { MAX_SPACE_INITIALS } from '../../common'; import { getSpaceColor, getSpaceImageUrl, getSpaceInitials } from './space_attributes'; +import type { SpaceAvatarProps } from './types'; -interface Props { - space: Partial; - size?: 's' | 'm' | 'l' | 'xl'; - className?: string; - announceSpaceName?: boolean; - /** - * This property is passed to the underlying `EuiAvatar` component. If enabled, the SpaceAvatar will have a grayed out appearance. For - * example, this can be useful when rendering a list of spaces for a specific feature, if the feature is disabled in one of those spaces. - * Default: false. - */ - isDisabled?: boolean; -} - -export const SpaceAvatarInternal: FC = (props: Props) => { +export const SpaceAvatarInternal: FC = (props: SpaceAvatarProps) => { const { space, size, announceSpaceName, ...rest } = props; const spaceName = space.name ? space.name.trim() : ''; diff --git a/x-pack/plugins/spaces/public/space_avatar/types.ts b/x-pack/plugins/spaces/public/space_avatar/types.ts new file mode 100644 index 000000000000..365c71eeeea7 --- /dev/null +++ b/x-pack/plugins/spaces/public/space_avatar/types.ts @@ -0,0 +1,36 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { Space } from '../../common'; + +/** + * Properties for the SpaceAvatar component. + */ +export interface SpaceAvatarProps { + /** The space to represent with an avatar. */ + space: Partial; + + /** The size of the avatar. */ + size?: 's' | 'm' | 'l' | 'xl'; + + /** Optional CSS class(es) to apply. */ + className?: string; + + /** + * When enabled, allows EUI to provide an aria-label for this component, which is announced on screen readers. + * + * Default value is true. + */ + announceSpaceName?: boolean; + + /** + * Whether or not to render the avatar in a disabled state. + * + * Default value is false. + */ + isDisabled?: boolean; +} diff --git a/x-pack/plugins/spaces/public/space_list/index.ts b/x-pack/plugins/spaces/public/space_list/index.ts index 1570ad123b9a..9d367f3739c7 100644 --- a/x-pack/plugins/spaces/public/space_list/index.ts +++ b/x-pack/plugins/spaces/public/space_list/index.ts @@ -6,3 +6,4 @@ */ export { getSpaceListComponent } from './space_list'; +export type { SpaceListProps } from './types'; diff --git a/x-pack/plugins/spaces/public/space_list/space_list.tsx b/x-pack/plugins/spaces/public/space_list/space_list.tsx index efd8b367bcd4..86e6432d1e21 100644 --- a/x-pack/plugins/spaces/public/space_list/space_list.tsx +++ b/x-pack/plugins/spaces/public/space_list/space_list.tsx @@ -7,7 +7,7 @@ import React from 'react'; -import type { SpaceListProps } from 'src/plugins/spaces_oss/public'; +import type { SpaceListProps } from './types'; export const getSpaceListComponent = async (): Promise> => { const { SpaceListInternal } = await import('./space_list_internal'); diff --git a/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx b/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx index 8109444fc127..39ae339fb7e1 100644 --- a/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx +++ b/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx @@ -11,12 +11,12 @@ import React from 'react'; import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from 'src/core/public/mocks'; -import type { Space } from 'src/plugins/spaces_oss/common'; -import type { SpaceListProps } from 'src/plugins/spaces_oss/public'; +import type { Space } from '../../common'; import { getSpacesContextProviderWrapper } from '../spaces_context'; import { spacesManagerMock } from '../spaces_manager/mocks'; import { SpaceListInternal } from './space_list_internal'; +import type { SpaceListProps } from './types'; const ACTIVE_SPACE: Space = { id: 'default', diff --git a/x-pack/plugins/spaces/public/space_list/space_list_internal.tsx b/x-pack/plugins/spaces/public/space_list/space_list_internal.tsx index ac7e6446f2cc..bfe4486fafa7 100644 --- a/x-pack/plugins/spaces/public/space_list/space_list_internal.tsx +++ b/x-pack/plugins/spaces/public/space_list/space_list_internal.tsx @@ -18,12 +18,12 @@ import React, { lazy, Suspense, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { SpaceListProps } from 'src/plugins/spaces_oss/public'; import { ALL_SPACES_ID, UNKNOWN_SPACE } from '../../common/constants'; import { getSpaceAvatarComponent } from '../space_avatar'; import { useSpaces } from '../spaces_context'; -import type { ShareToSpacesData, ShareToSpaceTarget } from '../types'; +import type { SpacesData, SpacesDataEntry } from '../types'; +import type { SpaceListProps } from './types'; // No need to wrap LazySpaceAvatar in an error boundary, because it is one of the first chunks loaded when opening Kibana. const LazySpaceAvatar = lazy(() => @@ -31,6 +31,7 @@ const LazySpaceAvatar = lazy(() => ); const DEFAULT_DISPLAY_LIMIT = 5; +type SpaceTarget = Omit; /** * Displays a corresponding list of spaces for a given list of saved object namespaces. It shows up to five spaces (and an indicator for any @@ -43,16 +44,16 @@ export const SpaceListInternal = ({ displayLimit = DEFAULT_DISPLAY_LIMIT, behaviorContext, }: SpaceListProps) => { - const { shareToSpacesDataPromise } = useSpaces(); + const { spacesDataPromise } = useSpaces(); const [isExpanded, setIsExpanded] = useState(false); - const [shareToSpacesData, setShareToSpacesData] = useState(); + const [shareToSpacesData, setShareToSpacesData] = useState(); useEffect(() => { - shareToSpacesDataPromise.then((x) => { + spacesDataPromise.then((x) => { setShareToSpacesData(x); }); - }, [shareToSpacesDataPromise]); + }, [spacesDataPromise]); if (!shareToSpacesData) { return null; @@ -61,7 +62,7 @@ export const SpaceListInternal = ({ const isSharedToAllSpaces = namespaces.includes(ALL_SPACES_ID); const unauthorizedSpacesCount = namespaces.filter((namespace) => namespace === UNKNOWN_SPACE) .length; - let displayedSpaces: ShareToSpaceTarget[]; + let displayedSpaces: SpaceTarget[]; let button: ReactNode = null; if (isSharedToAllSpaces) { @@ -77,8 +78,8 @@ export const SpaceListInternal = ({ ]; } else { const authorized = namespaces.filter((namespace) => namespace !== UNKNOWN_SPACE); - const enabledSpaceTargets: ShareToSpaceTarget[] = []; - const disabledSpaceTargets: ShareToSpaceTarget[] = []; + const enabledSpaceTargets: SpaceTarget[] = []; + const disabledSpaceTargets: SpaceTarget[] = []; authorized.forEach((namespace) => { const spaceTarget = shareToSpacesData.spacesMap.get(namespace); if (spaceTarget === undefined) { diff --git a/x-pack/plugins/spaces/public/space_list/types.ts b/x-pack/plugins/spaces/public/space_list/types.ts new file mode 100644 index 000000000000..2e7e813a48a2 --- /dev/null +++ b/x-pack/plugins/spaces/public/space_list/types.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +/** + * Properties for the SpaceList component. + */ +export interface SpaceListProps { + /** + * The namespaces of a saved object to render into a corresponding list of spaces. + */ + namespaces: string[]; + /** + * Optional limit to the number of spaces that can be displayed in the list. If the number of spaces exceeds this limit, they will be + * hidden behind a "show more" button. Set to 0 to disable. + * + * Default value is 5. + */ + displayLimit?: number; + /** + * When set to 'within-space' (default), the space list behaves like it is running on a page within the active space, and it will omit the + * active space (e.g., it displays a list of all the _other_ spaces that an object is shared to). + * + * Conversely, when set to 'outside-space', the space list behaves like it is running on a page outside of any space, so it will not omit + * the active space. + */ + behaviorContext?: 'within-space' | 'outside-space'; +} diff --git a/x-pack/plugins/spaces/public/space_selector/components/space_card.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_card.tsx index 0628f79990af..214659169e72 100644 --- a/x-pack/plugins/spaces/public/space_selector/components/space_card.tsx +++ b/x-pack/plugins/spaces/public/space_selector/components/space_card.tsx @@ -10,8 +10,7 @@ import './space_card.scss'; import { EuiCard, EuiLoadingSpinner } from '@elastic/eui'; import React, { lazy, Suspense } from 'react'; -import type { Space } from 'src/plugins/spaces_oss/common'; - +import type { Space } from '../../../common'; import { addSpaceIdToPath, ENTER_SPACE_PATH } from '../../../common'; import { getSpaceAvatarComponent } from '../../space_avatar'; diff --git a/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx index e7bef5f64603..c13a3a53fbe8 100644 --- a/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx +++ b/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx @@ -10,8 +10,7 @@ import './space_cards.scss'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { Component } from 'react'; -import type { Space } from 'src/plugins/spaces_oss/common'; - +import type { Space } from '../../../common'; import { SpaceCard } from './space_card'; interface Props { diff --git a/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx index b4417d98bcac..e17c3e0078d4 100644 --- a/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx +++ b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx @@ -8,8 +8,8 @@ import React from 'react'; import { shallowWithIntl } from '@kbn/test/jest'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../common'; import { spacesManagerMock } from '../spaces_manager/mocks'; import { SpaceSelector } from './space_selector'; diff --git a/x-pack/plugins/spaces/public/space_selector/space_selector.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.tsx index cee304408495..00ad39bf0027 100644 --- a/x-pack/plugins/spaces/public/space_selector/space_selector.tsx +++ b/x-pack/plugins/spaces/public/space_selector/space_selector.tsx @@ -28,8 +28,8 @@ import ReactDOM from 'react-dom'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { CoreStart } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../common'; import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../common/constants'; import type { SpacesManager } from '../spaces_manager'; import { SpaceCards } from './components'; diff --git a/x-pack/plugins/spaces/public/spaces_context/context.tsx b/x-pack/plugins/spaces/public/spaces_context/context.tsx index e38a2f17151a..64df17bed576 100644 --- a/x-pack/plugins/spaces/public/spaces_context/context.tsx +++ b/x-pack/plugins/spaces/public/spaces_context/context.tsx @@ -7,29 +7,29 @@ import * as React from 'react'; +import type { CoreStart } from 'src/core/public'; + import type { SpacesManager } from '../spaces_manager'; -import type { ShareToSpacesData } from '../types'; -import type { KibanaServices, SpacesReactContext, SpacesReactContextValue } from './types'; +import type { SpacesData } from '../types'; +import type { SpacesReactContext, SpacesReactContextValue } from './types'; const { useContext, createElement, createContext } = React; -const context = createContext>>({}); +const context = createContext>>>({}); -export const useSpaces = (): SpacesReactContextValue< - KibanaServices & Extra -> => - useContext( - (context as unknown) as React.Context> - ); +export const useSpaces = < + Services extends Partial +>(): SpacesReactContextValue => + useContext((context as unknown) as React.Context>); -export const createSpacesReactContext = ( +export const createSpacesReactContext = >( services: Services, spacesManager: SpacesManager, - shareToSpacesDataPromise: Promise + spacesDataPromise: Promise ): SpacesReactContext => { const value: SpacesReactContextValue = { spacesManager, - shareToSpacesDataPromise, + spacesDataPromise, services, }; const Provider: React.FC = ({ children }) => diff --git a/x-pack/plugins/spaces/public/spaces_context/index.ts b/x-pack/plugins/spaces/public/spaces_context/index.ts index 0187131b02b9..5b5ff829b380 100644 --- a/x-pack/plugins/spaces/public/spaces_context/index.ts +++ b/x-pack/plugins/spaces/public/spaces_context/index.ts @@ -6,4 +6,5 @@ */ export { useSpaces } from './context'; +export type { SpacesContextProps, SpacesReactContextValue } from './types'; export { getSpacesContextProviderWrapper } from './wrapper'; diff --git a/x-pack/plugins/spaces/public/spaces_context/types.ts b/x-pack/plugins/spaces/public/spaces_context/types.ts index e73da7cb26b6..d3a6859875b9 100644 --- a/x-pack/plugins/spaces/public/spaces_context/types.ts +++ b/x-pack/plugins/spaces/public/spaces_context/types.ts @@ -11,23 +11,31 @@ import type { CoreStart, StartServicesAccessor } from 'src/core/public'; import type { PluginsStart } from '../plugin'; import type { SpacesManager } from '../spaces_manager'; -import type { ShareToSpacesData } from '../types'; +import type { SpacesData } from '../types'; -export type KibanaServices = Partial; - -export interface SpacesReactContextValue { +export interface SpacesReactContextValue> { readonly spacesManager: SpacesManager; - readonly shareToSpacesDataPromise: Promise; + readonly spacesDataPromise: Promise; readonly services: Services; } -export interface SpacesReactContext { - value: SpacesReactContextValue; +export interface SpacesReactContext> { + value: SpacesReactContextValue; Provider: React.FC; - Consumer: React.Consumer>; + Consumer: React.Consumer>; } export interface InternalProps { spacesManager: SpacesManager; getStartServices: StartServicesAccessor; } + +/** + * Properties for the SpacesContext. + */ +export interface SpacesContextProps { + /** + * If a feature is specified, all Spaces components will treat it appropriately if the feature is disabled in a given Space. + */ + feature?: string; +} diff --git a/x-pack/plugins/spaces/public/spaces_context/wrapper.tsx b/x-pack/plugins/spaces/public/spaces_context/wrapper.tsx index 6de14290abb7..8fae6e78d1bb 100644 --- a/x-pack/plugins/spaces/public/spaces_context/wrapper.tsx +++ b/x-pack/plugins/spaces/public/spaces_context/wrapper.tsx @@ -8,9 +8,7 @@ import type { PropsWithChildren } from 'react'; import React from 'react'; -import type { SpacesContextProps } from 'src/plugins/spaces_oss/public'; - -import type { InternalProps } from './types'; +import type { InternalProps, SpacesContextProps } from './types'; export const getSpacesContextProviderWrapper = async ( internalProps: InternalProps diff --git a/x-pack/plugins/spaces/public/spaces_context/wrapper_internal.tsx b/x-pack/plugins/spaces/public/spaces_context/wrapper_internal.tsx index dd6408e9550e..83ad69b1017d 100644 --- a/x-pack/plugins/spaces/public/spaces_context/wrapper_internal.tsx +++ b/x-pack/plugins/spaces/public/spaces_context/wrapper_internal.tsx @@ -9,12 +9,12 @@ import type { PropsWithChildren } from 'react'; import React, { useEffect, useMemo, useState } from 'react'; import type { ApplicationStart, DocLinksStart, NotificationsStart } from 'src/core/public'; -import type { SpacesContextProps } from 'src/plugins/spaces_oss/public'; +import type { GetAllSpacesPurpose } from '../../common'; import type { SpacesManager } from '../spaces_manager'; -import type { ShareToSpacesData, ShareToSpaceTarget } from '../types'; +import type { SpacesData, SpacesDataEntry } from '../types'; import { createSpacesReactContext } from './context'; -import type { InternalProps, SpacesReactContext } from './types'; +import type { InternalProps, SpacesContextProps, SpacesReactContext } from './types'; interface Services { application: ApplicationStart; @@ -22,25 +22,25 @@ interface Services { notifications: NotificationsStart; } -async function getShareToSpacesData( - spacesManager: SpacesManager, - feature?: string -): Promise { +async function getSpacesData(spacesManager: SpacesManager, feature?: string): Promise { const spaces = await spacesManager.getSpaces({ includeAuthorizedPurposes: true }); const activeSpace = await spacesManager.getActiveSpace(); const spacesMap = spaces - .map(({ authorizedPurposes, disabledFeatures, ...space }) => { + .map(({ authorizedPurposes, disabledFeatures, ...space }) => { const isActiveSpace = space.id === activeSpace.id; - const cannotShareToSpace = authorizedPurposes?.shareSavedObjectsIntoSpace === false; const isFeatureDisabled = feature !== undefined && disabledFeatures.includes(feature); return { ...space, ...(isActiveSpace && { isActiveSpace }), - ...(cannotShareToSpace && { cannotShareToSpace }), ...(isFeatureDisabled && { isFeatureDisabled }), + isAuthorizedForPurpose: (purpose: GetAllSpacesPurpose) => + // If authorizedPurposes is not present, then Security is disabled; normally in a situation like this we would "fail-secure", but + // in this case we are dealing with an abstraction over the client-side UI capabilities. There is no chance for privilege + // escalation here, and the correct behavior is that if Security is disabled, the user is implicitly authorized to do everything. + authorizedPurposes ? authorizedPurposes[purpose] === true : true, }; }) - .reduce((acc, cur) => acc.set(cur.id, cur), new Map()); + .reduce((acc, cur) => acc.set(cur.id, cur), new Map()); return { spacesMap, @@ -54,7 +54,7 @@ export const SpacesContextWrapperInternal = ( const { spacesManager, getStartServices, feature, children } = props; const [context, setContext] = useState | undefined>(); - const shareToSpacesDataPromise = useMemo(() => getShareToSpacesData(spacesManager, feature), [ + const spacesDataPromise = useMemo(() => getSpacesData(spacesManager, feature), [ spacesManager, feature, ]); @@ -63,9 +63,9 @@ export const SpacesContextWrapperInternal = ( getStartServices().then(([coreStart]) => { const { application, docLinks, notifications } = coreStart; const services = { application, docLinks, notifications }; - setContext(createSpacesReactContext(services, spacesManager, shareToSpacesDataPromise)); + setContext(createSpacesReactContext(services, spacesManager, spacesDataPromise)); }); - }, [getStartServices, shareToSpacesDataPromise, spacesManager]); + }, [getStartServices, spacesDataPromise, spacesManager]); if (!context) { return null; diff --git a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts index 5282163f93b1..3f3cc3f4d780 100644 --- a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts +++ b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts @@ -8,8 +8,7 @@ import type { Observable } from 'rxjs'; import { of } from 'rxjs'; -import type { Space } from 'src/plugins/spaces_oss/common'; - +import type { Space } from '../../common'; import type { SpacesManager } from './spaces_manager'; function createSpacesManagerMock() { diff --git a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts index 845373bf2229..d0406d744b72 100644 --- a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts +++ b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts @@ -13,9 +13,13 @@ import type { HttpSetup, SavedObjectsCollectMultiNamespaceReferencesResponse, } from 'src/core/public'; -import type { Space } from 'src/plugins/spaces_oss/common'; -import type { GetAllSpacesOptions, GetSpaceResult, LegacyUrlAliasTarget } from '../../common'; +import type { + GetAllSpacesOptions, + GetSpaceResult, + LegacyUrlAliasTarget, + Space, +} from '../../common'; import type { CopySavedObjectsToSpaceResponse } from '../copy_saved_objects_to_space/types'; interface SavedObjectTarget { diff --git a/x-pack/plugins/spaces/public/types.ts b/x-pack/plugins/spaces/public/types.ts index e999e332b988..fd926621b72d 100644 --- a/x-pack/plugins/spaces/public/types.ts +++ b/x-pack/plugins/spaces/public/types.ts @@ -5,14 +5,17 @@ * 2.0. */ -import type { GetSpaceResult } from '../common'; +import type { Observable } from 'rxjs'; + +import type { GetAllSpacesPurpose, GetSpaceResult, Space } from '../common'; +import type { SpacesApiUi } from './ui_api'; /** * The structure for all of the space data that must be loaded for share-to-space components to function. */ -export interface ShareToSpacesData { - /** A map of each existing space's ID and its associated {@link ShareToSpaceTarget}. */ - readonly spacesMap: Map; +export interface SpacesData { + /** A map of each existing space's ID and its associated {@link SpacesDataEntry}. */ + readonly spacesMap: Map; /** The ID of the active space. */ readonly activeSpaceId: string; } @@ -21,11 +24,33 @@ export interface ShareToSpacesData { * The data that was fetched for a specific space. Includes optional additional fields that are needed to handle edge cases in the * share-to-space components that consume it. */ -export interface ShareToSpaceTarget extends Omit { +export interface SpacesDataEntry + extends Omit { /** True if this space is the active space. */ isActiveSpace?: true; - /** True if the user has read access to this space, but is not authorized to share objects into this space. */ - cannotShareToSpace?: true; /** True if the current feature (specified in the `SpacesContext`) is disabled in this space. */ isFeatureDisabled?: true; + /** Returns true if the user is authorized for the given purpose. */ + isAuthorizedForPurpose(purpose: GetAllSpacesPurpose): boolean; +} + +/** + * Client-side Spaces API. + */ +export interface SpacesApi { + /** + * Observable representing the currently active space. + * The details of the space can change without a full page reload (such as display name, color, etc.) + */ + getActiveSpace$(): Observable; + + /** + * Retrieve the currently active space. + */ + getActiveSpace(): Promise; + + /** + * UI components and services to add spaces capabilities to an application. + */ + ui: SpacesApiUi; } diff --git a/x-pack/plugins/spaces/public/ui_api/components.tsx b/x-pack/plugins/spaces/public/ui_api/components.tsx index a277e3a1dd11..a33480712ffa 100644 --- a/x-pack/plugins/spaces/public/ui_api/components.tsx +++ b/x-pack/plugins/spaces/public/ui_api/components.tsx @@ -9,8 +9,8 @@ import type { FC, PropsWithChildren, PropsWithRef } from 'react'; import React from 'react'; import type { StartServicesAccessor } from 'src/core/public'; -import type { SpacesApiUiComponent } from 'src/plugins/spaces_oss/public'; +import { getCopyToSpaceFlyoutComponent } from '../copy_saved_objects_to_space'; import type { PluginsStart } from '../plugin'; import { getLegacyUrlConflict, @@ -21,6 +21,7 @@ import { getSpaceListComponent } from '../space_list'; import { getSpacesContextProviderWrapper } from '../spaces_context'; import type { SpacesManager } from '../spaces_manager'; import { LazyWrapper } from './lazy_wrapper'; +import type { SpacesApiUiComponent } from './types'; export interface GetComponentsOptions { spacesManager: SpacesManager; @@ -51,6 +52,7 @@ export const getComponents = ({ getSpacesContextProviderWrapper({ spacesManager, getStartServices }) ), getShareToSpaceFlyout: wrapLazy(getShareToSpaceFlyoutComponent, { showLoadingSpinner: false }), + getCopyToSpaceFlyout: wrapLazy(getCopyToSpaceFlyoutComponent, { showLoadingSpinner: false }), getSpaceList: wrapLazy(getSpaceListComponent), getLegacyUrlConflict: wrapLazy(() => getLegacyUrlConflict({ getStartServices })), getSpaceAvatar: wrapLazy(getSpaceAvatarComponent), diff --git a/x-pack/plugins/spaces/public/ui_api/index.ts b/x-pack/plugins/spaces/public/ui_api/index.ts index 4bfb482b4140..e0749b04de13 100644 --- a/x-pack/plugins/spaces/public/ui_api/index.ts +++ b/x-pack/plugins/spaces/public/ui_api/index.ts @@ -6,23 +6,27 @@ */ import type { StartServicesAccessor } from 'src/core/public'; -import type { SpacesApiUi } from 'src/plugins/spaces_oss/public'; import type { PluginsStart } from '../plugin'; import { createRedirectLegacyUrl } from '../share_saved_objects_to_space'; +import { useSpaces } from '../spaces_context'; import type { SpacesManager } from '../spaces_manager'; import { getComponents } from './components'; +import type { LazyComponentFn, SpacesApiUi, SpacesApiUiComponent } from './types'; interface GetUiApiOptions { spacesManager: SpacesManager; getStartServices: StartServicesAccessor; } +export type { LazyComponentFn, SpacesApiUi, SpacesApiUiComponent }; + export const getUiApi = ({ spacesManager, getStartServices }: GetUiApiOptions): SpacesApiUi => { const components = getComponents({ spacesManager, getStartServices }); return { components, redirectLegacyUrl: createRedirectLegacyUrl(getStartServices), + useSpaces, }; }; diff --git a/x-pack/plugins/spaces/public/ui_api/mocks.ts b/x-pack/plugins/spaces/public/ui_api/mocks.ts deleted file mode 100644 index fe3826a58fcc..000000000000 --- a/x-pack/plugins/spaces/public/ui_api/mocks.ts +++ /dev/null @@ -1,29 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { SpacesApiUi, SpacesApiUiComponent } from 'src/plugins/spaces_oss/public'; - -function createComponentsMock(): jest.Mocked { - return { - getSpacesContextProvider: jest.fn(), - getShareToSpaceFlyout: jest.fn(), - getSpaceList: jest.fn(), - getLegacyUrlConflict: jest.fn(), - getSpaceAvatar: jest.fn(), - }; -} - -function createUiApiMock(): jest.Mocked { - return { - components: createComponentsMock(), - redirectLegacyUrl: jest.fn(), - }; -} - -export const uiApiMock = { - create: createUiApiMock, -}; diff --git a/x-pack/plugins/spaces/public/ui_api/types.ts b/x-pack/plugins/spaces/public/ui_api/types.ts new file mode 100644 index 000000000000..5048e5a9b965 --- /dev/null +++ b/x-pack/plugins/spaces/public/ui_api/types.ts @@ -0,0 +1,112 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { ReactElement } from 'react'; + +import type { CoreStart } from 'src/core/public'; + +import type { CopyToSpaceFlyoutProps } from '../copy_saved_objects_to_space'; +import type { + LegacyUrlConflictProps, + ShareToSpaceFlyoutProps, +} from '../share_saved_objects_to_space'; +import type { SpaceAvatarProps } from '../space_avatar'; +import type { SpaceListProps } from '../space_list'; +import type { SpacesContextProps, SpacesReactContextValue } from '../spaces_context'; + +/** + * Function that returns a promise for a lazy-loadable component. + */ +export type LazyComponentFn = (props: T) => ReactElement; + +/** + * UI components and services to add spaces capabilities to an application. + */ +export interface SpacesApiUi { + /** + * Lazy-loadable {@link SpacesApiUiComponent | React components} to support the Spaces feature. + */ + components: SpacesApiUiComponent; + /** + * Redirect the user from a legacy URL to a new URL. This needs to be used if a call to `SavedObjectsClient.resolve()` results in an + * `"aliasMatch"` outcome, which indicates that the user has loaded the page using a legacy URL. Calling this function will trigger a + * client-side redirect to the new URL, and it will display a toast to the user. + * + * Consumers need to determine the local path for the new URL on their own, based on the object ID that was used to call + * `SavedObjectsClient.resolve()` (old ID) and the object ID in the result (new ID). For example... + * + * The old object ID is `workpad-123` and the new object ID is `workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e`. + * + * Full legacy URL: `https://localhost:5601/app/canvas#/workpad/workpad-123/page/1` + * + * New URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1` + * + * The protocol, hostname, port, base path, and app path are automatically included. + * + * @param path The path to use for the new URL, optionally including `search` and/or `hash` URL components. + * @param objectNoun The string that is used to describe the object in the toast, e.g., _The **object** you're looking for has a new + * location_. Default value is 'object'. + */ + redirectLegacyUrl: (path: string, objectNoun?: string) => Promise; + /** + * Helper function to easily access the Spaces React Context provider. + */ + useSpaces>(): SpacesReactContextValue; +} + +/** + * React UI components to be used to display the Spaces feature in any application. + */ +export interface SpacesApiUiComponent { + /** + * Provides a context that is required to render some Spaces components. + */ + getSpacesContextProvider: LazyComponentFn; + /** + * Displays a flyout to edit the spaces that an object is shared to. + * + * Note: must be rendered inside of a SpacesContext. + */ + getShareToSpaceFlyout: LazyComponentFn; + /** + * Displays a flyout to copy an object to other spaces. + * + * Note: must be rendered inside of a SpacesContext. + */ + getCopyToSpaceFlyout: LazyComponentFn; + /** + * Displays a corresponding list of spaces for a given list of saved object namespaces. It shows up to five spaces (and an indicator for + * any number of spaces that the user is not authorized to see) by default. If more than five named spaces would be displayed, the extras + * (along with the unauthorized spaces indicator, if present) are hidden behind a button. If '*' (aka "All spaces") is present, it + * supersedes all of the above and just displays a single badge without a button. + * + * Note: must be rendered inside of a SpacesContext. + */ + getSpaceList: LazyComponentFn; + /** + * Displays a callout that needs to be used if a call to `SavedObjectsClient.resolve()` results in an `"conflict"` outcome, which + * indicates that the user has loaded the page which is associated directly with one object (A), *and* with a legacy URL that points to a + * different object (B). + * + * In this case, `SavedObjectsClient.resolve()` has returned object A. This component displays a warning callout to the user explaining + * that there is a conflict, and it includes a button that will redirect the user to object B when clicked. + * + * Consumers need to determine the local path for the new URL on their own, based on the object ID that was used to call + * `SavedObjectsClient.resolve()` (A) and the `alias_target_id` value in the response (B). For example... + * + * A is `workpad-123` and B is `workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e`. + * + * Full legacy URL: `https://localhost:5601/app/canvas#/workpad/workpad-123/page/1` + * + * New URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1` + */ + getLegacyUrlConflict: LazyComponentFn; + /** + * Displays an avatar for the given space. + */ + getSpaceAvatar: LazyComponentFn; +} diff --git a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts index c3393da770de..13be8398da48 100644 --- a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts +++ b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts @@ -7,10 +7,10 @@ import type { Capabilities, CoreSetup } from 'src/core/server'; import { coreMock, httpServerMock, loggingSystemMock } from 'src/core/server/mocks'; -import type { Space } from 'src/plugins/spaces_oss/common'; import type { KibanaFeature } from '../../../features/server'; import { featuresPluginMock } from '../../../features/server/mocks'; +import type { Space } from '../../common'; import type { PluginsStart } from '../plugin'; import { spacesServiceMock } from '../spaces_service/spaces_service.mock'; import { setupCapabilitiesSwitcher } from './capabilities_switcher'; diff --git a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts index 1f6249d9b322..ac2ff735de79 100644 --- a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts +++ b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts @@ -8,9 +8,9 @@ import _ from 'lodash'; import type { Capabilities, CapabilitiesSwitcher, CoreSetup, Logger } from 'src/core/server'; -import type { Space } from 'src/plugins/spaces_oss/common'; import type { KibanaFeature } from '../../../features/server'; +import type { Space } from '../../common'; import type { PluginsStart } from '../plugin'; import type { SpacesServiceStart } from '../spaces_service'; diff --git a/x-pack/plugins/spaces/server/index.ts b/x-pack/plugins/spaces/server/index.ts index 4765b06f5a02..31714df958d4 100644 --- a/x-pack/plugins/spaces/server/index.ts +++ b/x-pack/plugins/spaces/server/index.ts @@ -23,16 +23,14 @@ export { SpacesPluginSetup, SpacesPluginStart } from './plugin'; export { SpacesServiceSetup, SpacesServiceStart } from './spaces_service'; export { ISpacesClient, SpacesClientRepositoryFactory, SpacesClientWrapper } from './spaces_client'; -export { +export type { + Space, GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult, LegacyUrlAliasTarget, } from '../common'; -// re-export types from oss definition -export type { Space } from 'src/plugins/spaces_oss/common'; - export const config: PluginConfigDescriptor = { schema: ConfigSchema, deprecations: spacesConfigDeprecationProvider, diff --git a/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts b/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts index ff81960185b6..f5b41786d247 100644 --- a/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts +++ b/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts @@ -6,8 +6,8 @@ */ import type { CoreSetup, Logger } from 'src/core/server'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; import { addSpaceIdToPath } from '../../../common'; import { DEFAULT_SPACE_ID, ENTER_SPACE_PATH } from '../../../common/constants'; import type { PluginsSetup } from '../../plugin'; diff --git a/x-pack/plugins/spaces/server/routes/api/external/get_all.ts b/x-pack/plugins/spaces/server/routes/api/external/get_all.ts index 7f0bd3231c6d..09a4ac5a843a 100644 --- a/x-pack/plugins/spaces/server/routes/api/external/get_all.ts +++ b/x-pack/plugins/spaces/server/routes/api/external/get_all.ts @@ -6,8 +6,8 @@ */ import { schema } from '@kbn/config-schema'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../../common'; import { wrapError } from '../../../lib/errors'; import { createLicensedRouteHandler } from '../../lib'; import type { ExternalRouteDeps } from './'; diff --git a/x-pack/plugins/spaces/server/routes/api/external/put.ts b/x-pack/plugins/spaces/server/routes/api/external/put.ts index b58601c8c7e7..196f7c11932e 100644 --- a/x-pack/plugins/spaces/server/routes/api/external/put.ts +++ b/x-pack/plugins/spaces/server/routes/api/external/put.ts @@ -6,9 +6,9 @@ */ import { schema } from '@kbn/config-schema'; -import type { Space } from 'src/plugins/spaces_oss/common'; import { SavedObjectsErrorHelpers } from '../../../../../../../src/core/server'; +import type { Space } from '../../../../common'; import { wrapError } from '../../../lib/errors'; import { spaceSchema } from '../../../lib/space_schema'; import { createLicensedRouteHandler } from '../../lib'; diff --git a/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts b/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts index 6a90d367fc4a..53969d3984bd 100644 --- a/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts +++ b/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../../common'; export function convertSavedObjectToSpace(savedObject: any): Space { return { diff --git a/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.test.ts b/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.test.ts index 62a3d9866293..e07050fe97d7 100644 --- a/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.test.ts +++ b/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.test.ts @@ -5,8 +5,7 @@ * 2.0. */ -import type { Space } from 'src/plugins/spaces_oss/common'; - +import type { Space } from '../../../common'; import { migrateTo660 } from './space_migrations'; describe('migrateTo660', () => { diff --git a/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.ts b/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.ts index d88db2b0181d..c26983e84de5 100644 --- a/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.ts +++ b/x-pack/plugins/spaces/server/saved_objects/migrations/space_migrations.ts @@ -6,7 +6,8 @@ */ import type { SavedObjectUnsanitizedDoc } from 'src/core/server'; -import type { Space } from 'src/plugins/spaces_oss/common'; + +import type { Space } from '../../../common'; export const migrateTo660 = (doc: SavedObjectUnsanitizedDoc) => { if (!doc.attributes.hasOwnProperty('disabledFeatures')) { diff --git a/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts b/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts index d893d2b089f8..a4e209ff11d3 100644 --- a/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts +++ b/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts @@ -5,8 +5,7 @@ * 2.0. */ -import type { Space } from 'src/plugins/spaces_oss/common'; - +import type { Space } from '../../common'; import { DEFAULT_SPACE_ID } from '../../common/constants'; import type { SpacesClient } from './spaces_client'; diff --git a/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts b/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts index 824d6e28b992..0a91c7aff1a0 100644 --- a/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts +++ b/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts @@ -9,13 +9,13 @@ import Boom from '@hapi/boom'; import { omit } from 'lodash'; import type { ISavedObjectsRepository, SavedObject } from 'src/core/server'; -import type { Space } from 'src/plugins/spaces_oss/common'; import type { GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult, LegacyUrlAliasTarget, + Space, } from '../../common'; import { isReservedSpace } from '../../common'; import type { ConfigType } from '../config'; diff --git a/x-pack/plugins/spaces/server/spaces_service/spaces_service.ts b/x-pack/plugins/spaces/server/spaces_service/spaces_service.ts index e951ed38072d..2ffe77a4c9a8 100644 --- a/x-pack/plugins/spaces/server/spaces_service/spaces_service.ts +++ b/x-pack/plugins/spaces/server/spaces_service/spaces_service.ts @@ -6,8 +6,8 @@ */ import type { IBasePath, KibanaRequest } from 'src/core/server'; -import type { Space } from 'src/plugins/spaces_oss/common'; +import type { Space } from '../../common'; import { getSpaceIdFromPath } from '../../common'; import { DEFAULT_SPACE_ID } from '../../common/constants'; import { namespaceToSpaceId, spaceIdToNamespace } from '../lib/utils/namespace'; diff --git a/x-pack/plugins/spaces/tsconfig.json b/x-pack/plugins/spaces/tsconfig.json index 4cc95504a158..bf2c6e7fc869 100644 --- a/x-pack/plugins/spaces/tsconfig.json +++ b/x-pack/plugins/spaces/tsconfig.json @@ -15,8 +15,6 @@ { "path": "../../../src/plugins/home/tsconfig.json" }, { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../../src/plugins/management/tsconfig.json" }, - { "path": "../../../src/plugins/saved_objects_management/tsconfig.json" }, - { "path": "../../../src/plugins/spaces_oss/tsconfig.json" }, { "path": "../../../src/plugins/usage_collection/tsconfig.json" } ] } diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index cc2770359758..fb263af2cc5e 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -23238,8 +23238,6 @@ "xpack.spaces.management.confirmDeleteModal.errorMessage": "スペース'{name}'を削除できませんでした", "xpack.spaces.management.confirmDeleteModal.successMessage": "スペース'{name}'が削除されました", "xpack.spaces.management.confirmDeleteModal.title": "スペース'{name}'を削除しますか?", - "xpack.spaces.management.copyToSpace.actionDescription": "1つ以上のスペースでこの保存されたオブジェクトのコピーを作成します", - "xpack.spaces.management.copyToSpace.actionTitle": "スペースにコピー", "xpack.spaces.management.copyToSpace.cancelButton": "キャンセル", "xpack.spaces.management.copyToSpace.copyDetail.overwriteSwitch": "上書きしますか?", "xpack.spaces.management.copyToSpace.copyDetail.selectControlLabel": "オブジェクトID", @@ -23348,13 +23346,9 @@ "xpack.spaces.navControl.spacesMenu.changeCurrentSpaceTitle": "現在のスペースの変更", "xpack.spaces.navControl.spacesMenu.findSpacePlaceholder": "スペースを検索", "xpack.spaces.navControl.spacesMenu.noSpacesFoundTitle": " スペースが見つかりません ", - "xpack.spaces.shareToSpace.actionDescription": "この保存されたオブジェクトを1つ以上のスペースと共有します。", - "xpack.spaces.shareToSpace.actionTitle": "スペースと共有", "xpack.spaces.shareToSpace.aliasTableCalloutTitle": "レガシーURL競合", "xpack.spaces.shareToSpace.allSpacesTarget": "すべてのスペース", "xpack.spaces.shareToSpace.cancelButton": "キャンセル", - "xpack.spaces.shareToSpace.columnDescription": "このオブジェクトが現在共有されている他のスペース", - "xpack.spaces.shareToSpace.columnTitle": "共有されているスペース", "xpack.spaces.shareToSpace.continueButton": "続行", "xpack.spaces.shareToSpace.currentSpaceBadge": "現在", "xpack.spaces.shareToSpace.featureIsDisabledTooltip": "この機能はこのスペースでは無効です。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 92c2d78ceaeb..286e179e020c 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -23780,8 +23780,6 @@ "xpack.spaces.management.confirmDeleteModal.errorMessage": "无法删除工作区“{name}”", "xpack.spaces.management.confirmDeleteModal.successMessage": "已删除工作区“{name}”", "xpack.spaces.management.confirmDeleteModal.title": "删除工作区“{name}”?", - "xpack.spaces.management.copyToSpace.actionDescription": "在一个或多个工作区中创建此已保存对象的副本", - "xpack.spaces.management.copyToSpace.actionTitle": "复制到工作区", "xpack.spaces.management.copyToSpace.cancelButton": "取消", "xpack.spaces.management.copyToSpace.copyDetail.overwriteSwitch": "覆盖?", "xpack.spaces.management.copyToSpace.copyDetail.selectControlLabel": "对象 ID", @@ -23891,14 +23889,10 @@ "xpack.spaces.navControl.spacesMenu.changeCurrentSpaceTitle": "更改当前空间", "xpack.spaces.navControl.spacesMenu.findSpacePlaceholder": "查找工作区", "xpack.spaces.navControl.spacesMenu.noSpacesFoundTitle": " 未找到工作区 ", - "xpack.spaces.shareToSpace.actionDescription": "将此已保存对象共享到一个或多个工作区", - "xpack.spaces.shareToSpace.actionTitle": "共享到工作区", "xpack.spaces.shareToSpace.aliasTableCalloutBody": "将禁用 {aliasesToDisableCount, plural, other {# 个旧版 URL}}。", "xpack.spaces.shareToSpace.aliasTableCalloutTitle": "旧版 URL 冲突", "xpack.spaces.shareToSpace.allSpacesTarget": "所有工作区", "xpack.spaces.shareToSpace.cancelButton": "取消", - "xpack.spaces.shareToSpace.columnDescription": "目前将此对象共享到的其他工作区", - "xpack.spaces.shareToSpace.columnTitle": "共享工作区", "xpack.spaces.shareToSpace.continueButton": "继续", "xpack.spaces.shareToSpace.currentSpaceBadge": "当前", "xpack.spaces.shareToSpace.featureIsDisabledTooltip": "此功能在此工作区中已禁用。", diff --git a/x-pack/plugins/triggers_actions_ui/kibana.json b/x-pack/plugins/triggers_actions_ui/kibana.json index 9e9af347af2a..4033889d9811 100644 --- a/x-pack/plugins/triggers_actions_ui/kibana.json +++ b/x-pack/plugins/triggers_actions_ui/kibana.json @@ -8,7 +8,7 @@ "server": true, "ui": true, "optionalPlugins": ["alerting", "features", "home", "spaces"], - "requiredPlugins": ["management", "charts", "data", "kibanaReact", "kibanaUtils", "savedObjects", "spacesOss"], + "requiredPlugins": ["management", "charts", "data", "kibanaReact", "kibanaUtils", "savedObjects"], "configPath": ["xpack", "trigger_actions_ui"], "extraPublicDirs": ["public/common", "public/common/constants"], "requiredBundles": ["home", "alerting", "esUiShared", "kibanaReact", "kibanaUtils"] diff --git a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx index cc34f1beaf6b..9786f5dcb949 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx @@ -18,7 +18,6 @@ import { ChartsPluginStart } from '../../../../../src/plugins/charts/public'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { PluginStartContract as AlertingStart } from '../../../alerting/public'; import type { SpacesPluginStart } from '../../../spaces/public'; -import type { SpacesOssPluginStart } from '../../../../../src/plugins/spaces_oss/public'; import { suspendedComponentWithProps } from './lib/suspended_component_with_props'; import { Storage } from '../../../../../src/plugins/kibana_utils/public'; @@ -37,7 +36,6 @@ export interface TriggersAndActionsUiServices extends CoreStart { charts: ChartsPluginStart; alerting?: AlertingStart; spaces?: SpacesPluginStart; - spacesOss: SpacesOssPluginStart; storage?: Storage; setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void; actionTypeRegistry: ActionTypeRegistryContract; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx index 441daad1a50b..9ecaa3d91555 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx @@ -15,7 +15,7 @@ import { ToastsApi } from 'kibana/public'; import { AlertDetailsRoute, getRuleData } from './alert_details_route'; import { Alert } from '../../../../types'; import { CenterJustifiedSpinner } from '../../../components/center_justified_spinner'; -import { spacesOssPluginMock } from 'src/plugins/spaces_oss/public/mocks'; +import { spacesPluginMock } from '../../../../../../spaces/public/mocks'; import { useKibana } from '../../../../common/lib/kibana'; jest.mock('../../../../common/lib/kibana'); @@ -38,11 +38,11 @@ describe('alert_details_route', () => { jest.clearAllMocks(); }); - const spacesOssMock = spacesOssPluginMock.createStartContract(); + const spacesMock = spacesPluginMock.createStartContract(); async function setup() { const useKibanaMock = useKibana as jest.Mocked; // eslint-disable-next-line react-hooks/rules-of-hooks - useKibanaMock().services.spacesOss = spacesOssMock; + useKibanaMock().services.spaces = spacesMock; } it('render a loader while fetching data', () => { @@ -82,7 +82,7 @@ describe('alert_details_route', () => { expect(loadAlert).toHaveBeenCalledWith(rule.id); expect(resolveRule).toHaveBeenCalledWith(rule.id); - expect((spacesOssMock as any).ui.redirectLegacyUrl).toHaveBeenCalledWith( + expect((spacesMock as any).ui.redirectLegacyUrl).toHaveBeenCalledWith( `insightsAndAlerting/triggersActions/rule/new_id`, `rule` ); @@ -122,7 +122,7 @@ describe('alert_details_route', () => { expect(loadAlert).toHaveBeenCalledWith(rule.id); expect(resolveRule).toHaveBeenCalledWith(rule.id); - expect((spacesOssMock as any).ui.components.getLegacyUrlConflict).toHaveBeenCalledWith({ + expect((spacesMock as any).ui.components.getLegacyUrlConflict).toHaveBeenCalledWith({ currentObjectId: 'new_id', objectNoun: 'rule', otherObjectId: rule.id, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.tsx index b6279d7fca10..123d60bb9fea 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.tsx @@ -42,7 +42,7 @@ export const AlertDetailsRoute: React.FunctionComponent const { http, notifications: { toasts }, - spacesOss, + spaces: spacesApi, } = useKibana().services; const { basePath } = http; @@ -68,10 +68,10 @@ export const AlertDetailsRoute: React.FunctionComponent useEffect(() => { if (alert) { const outcome = (alert as ResolvedRule).outcome; - if (outcome === 'aliasMatch' && spacesOss.isSpacesAvailable) { + if (spacesApi && outcome === 'aliasMatch') { // This rule has been resolved from a legacy URL - redirect the user to the new URL and display a toast. const path = basePath.prepend(`insightsAndAlerting/triggersActions/rule/${alert.id}`); - spacesOss.ui.redirectLegacyUrl( + spacesApi.ui.redirectLegacyUrl( path, i18n.translate('xpack.triggersActionsUI.sections.alertDetails.redirectObjectNoun', { defaultMessage: 'rule', @@ -84,8 +84,8 @@ export const AlertDetailsRoute: React.FunctionComponent const getLegacyUrlConflictCallout = () => { const outcome = (alert as ResolvedRule).outcome; - const aliasTargetId = (alert as ResolvedRule).alias_target_id; - if (outcome === 'conflict' && aliasTargetId && spacesOss.isSpacesAvailable) { + if (spacesApi && outcome === 'conflict') { + const aliasTargetId = (alert as ResolvedRule).alias_target_id!; // This is always defined if outcome === 'conflict' // We have resolved to one rule, but there is another one with a legacy URL associated with this page. Display a // callout with a warning for the user, and provide a way for them to navigate to the other rule. const otherRulePath = basePath.prepend( @@ -94,7 +94,7 @@ export const AlertDetailsRoute: React.FunctionComponent return ( <> - {spacesOss.ui.components.getLegacyUrlConflict({ + {spacesApi.ui.components.getLegacyUrlConflict({ objectNoun: i18n.translate( 'xpack.triggersActionsUI.sections.alertDetails.redirectObjectNoun', { diff --git a/x-pack/plugins/triggers_actions_ui/public/common/lib/kibana/kibana_react.mock.ts b/x-pack/plugins/triggers_actions_ui/public/common/lib/kibana/kibana_react.mock.ts index f8aa483711c3..2985a5306ed5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/common/lib/kibana/kibana_react.mock.ts +++ b/x-pack/plugins/triggers_actions_ui/public/common/lib/kibana/kibana_react.mock.ts @@ -8,7 +8,6 @@ import React from 'react'; import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks'; import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks'; -import { spacesOssPluginMock } from '../../../../../../../src/plugins/spaces_oss/public/mocks'; import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks'; import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; import { TriggersAndActionsUiServices } from '../../../application/app'; @@ -45,7 +44,6 @@ export const createStartServicesMock = (): TriggersAndActionsUiServices => { element: ({ style: { cursor: 'pointer' }, } as unknown) as HTMLElement, - spacesOss: spacesOssPluginMock.createStartContract(), } as TriggersAndActionsUiServices; }; diff --git a/x-pack/plugins/triggers_actions_ui/public/plugin.ts b/x-pack/plugins/triggers_actions_ui/public/plugin.ts index 36d6964ce775..7661eefba7f6 100644 --- a/x-pack/plugins/triggers_actions_ui/public/plugin.ts +++ b/x-pack/plugins/triggers_actions_ui/public/plugin.ts @@ -26,7 +26,6 @@ import { PluginStartContract as AlertingStart } from '../../alerting/public'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import { Storage } from '../../../../src/plugins/kibana_utils/public'; import type { SpacesPluginStart } from '../../spaces/public'; -import type { SpacesOssPluginStart } from '../../../../src/plugins/spaces_oss/public'; import { getAddConnectorFlyoutLazy } from './common/get_add_connector_flyout'; import { getEditConnectorFlyoutLazy } from './common/get_edit_connector_flyout'; @@ -74,7 +73,6 @@ interface PluginsStart { charts: ChartsPluginStart; alerting?: AlertingStart; spaces?: SpacesPluginStart; - spacesOss: SpacesOssPluginStart; navigateToApp: CoreStart['application']['navigateToApp']; features: FeaturesPluginStart; } @@ -150,7 +148,6 @@ export class Plugin charts: pluginsStart.charts, alerting: pluginsStart.alerting, spaces: pluginsStart.spaces, - spacesOss: pluginsStart.spacesOss, element: params.element, storage: new Storage(window.localStorage), setBreadcrumbs: params.setBreadcrumbs, diff --git a/x-pack/plugins/triggers_actions_ui/tsconfig.json b/x-pack/plugins/triggers_actions_ui/tsconfig.json index e3c8b77d2c1d..ac36780f10c0 100644 --- a/x-pack/plugins/triggers_actions_ui/tsconfig.json +++ b/x-pack/plugins/triggers_actions_ui/tsconfig.json @@ -24,6 +24,6 @@ { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../../../src/plugins/management/tsconfig.json" }, - { "path": "../../../src/plugins/spaces_oss/tsconfig.json" }, + { "path": "../spaces/tsconfig.json" }, ] }