From bf349dbc94c5695e22241eabe252cb19a092913b Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Mon, 23 Aug 2021 09:10:09 -0400 Subject: [PATCH] Remove spacesOss plugin (#109258) # Conflicts: # .eslintrc.js # .github/CODEOWNERS # src/plugins/dashboard/kibana.json --- .eslintrc.js | 1 - api_docs/spaces_oss.json | 1320 ----------------- api_docs/spaces_oss.mdx | 41 - docs/developer/plugin-list.asciidoc | 4 - packages/kbn-optimizer/limits.yml | 1 - src/plugins/dashboard/kibana.json | 6 +- .../public/application/dashboard_router.tsx | 2 +- src/plugins/dashboard/public/plugin.tsx | 4 +- .../dashboard/public/services/spaces.ts | 2 +- src/plugins/dashboard/tsconfig.json | 2 +- .../saved_objects_management/kibana.json | 2 +- .../management_section/mount_section.tsx | 4 +- .../saved_objects_table_page.tsx | 7 +- .../saved_objects_management/public/plugin.ts | 10 +- .../public/services/action_service.test.ts | 13 +- .../public/services/action_service.ts | 18 +- .../copy_saved_objects_to_space_action.tsx | 77 + .../public/services/actions/index.ts} | 7 +- ...are_saved_objects_to_space_action.test.tsx | 12 +- .../share_saved_objects_to_space_action.tsx | 18 +- .../public/services/column_service.test.ts | 9 +- .../public/services/column_service.ts | 15 +- .../public/services/columns}/index.ts | 2 +- .../share_saved_objects_to_space_column.tsx | 14 +- .../saved_objects_management/tsconfig.json | 2 +- src/plugins/spaces_oss/README.md | 3 - src/plugins/spaces_oss/common/types.ts | 62 - src/plugins/spaces_oss/kibana.json | 13 - src/plugins/spaces_oss/public/api.ts | 302 ---- src/plugins/spaces_oss/public/index.ts | 31 - src/plugins/spaces_oss/public/mocks/index.ts | 24 - src/plugins/spaces_oss/public/plugin.test.ts | 54 - src/plugins/spaces_oss/public/plugin.ts | 42 - src/plugins/spaces_oss/public/types.ts | 48 - src/plugins/spaces_oss/tsconfig.json | 16 - x-pack/plugins/maps/tsconfig.json | 17 + .../job_spaces_list/job_spaces_list.tsx | 3 +- .../jobs_list_page/jobs_list_page.tsx | 3 +- .../roles/edit_role/edit_role_page.tsx | 3 +- .../kibana/kibana_privileges_region.tsx | 3 +- .../privilege_summary/privilege_summary.tsx | 3 +- .../privilege_summary_table.tsx | 3 +- .../privilege_summary/space_column_header.tsx | 3 +- .../space_aware_privilege_section.tsx | 3 +- .../spaces_popover_list.test.tsx | 2 +- .../spaces_popover_list.tsx | 3 +- x-pack/plugins/spaces/common/index.ts | 1 + .../spaces/common/is_reserved_space.test.ts | 3 +- .../spaces/common/is_reserved_space.ts | 2 +- x-pack/plugins/spaces/common/types.ts | 55 +- x-pack/plugins/spaces/kibana.json | 6 +- .../advanced_settings_service.tsx | 2 +- .../advanced_settings_subtitle.tsx | 3 +- .../advanced_settings_title.tsx | 2 +- .../copy_status_summary_indicator.tsx | 4 +- .../components/copy_to_space_flyout.tsx | 2 +- .../copy_to_space_flyout_footer.tsx | 9 +- .../copy_to_space_flyout_internal.test.tsx | 6 +- .../copy_to_space_flyout_internal.tsx | 44 +- .../components/copy_to_space_form.tsx | 8 +- .../components/index.ts | 1 - .../components/processing_copy_to_space.tsx | 12 +- .../components/selectable_spaces_control.tsx | 4 +- .../components/space_result.tsx | 5 +- .../components/space_result_details.tsx | 4 +- .../copy_saved_objects_to_space_action.tsx | 91 -- ...opy_saved_objects_to_space_service.test.ts | 32 - .../copy_saved_objects_to_space_service.ts | 24 - .../copy_saved_objects_to_space/index.ts | 2 +- .../copy_saved_objects_to_space/lib/index.ts | 3 + .../lib/process_import_response.ts | 46 + .../lib/summarize_copy_result.test.ts | 21 +- .../lib/summarize_copy_result.ts | 9 +- .../copy_saved_objects_to_space/types.ts | 19 +- x-pack/plugins/spaces/public/index.ts | 24 +- .../confirm_delete_modal.tsx | 2 +- .../edit_space/delete_spaces_button.tsx | 2 +- .../enabled_features/enabled_features.tsx | 2 +- .../enabled_features/feature_table.tsx | 2 +- .../edit_space/manage_space_page.tsx | 2 +- .../edit_space/reserved_space_badge.tsx | 2 +- .../public/management/lib/feature_utils.ts | 3 +- .../spaces_grid/spaces_grid_page.tsx | 2 +- .../management/spaces_management_app.tsx | 2 +- .../plugins/spaces/public/mocks.ts | 17 +- .../nav_control/components/spaces_menu.tsx | 2 +- .../nav_control/nav_control_popover.tsx | 2 +- x-pack/plugins/spaces/public/plugin.test.ts | 14 +- x-pack/plugins/spaces/public/plugin.tsx | 22 +- .../components/alias_table.tsx | 9 +- .../components/legacy_url_conflict.tsx | 3 +- .../legacy_url_conflict_internal.tsx | 2 +- .../components/relatives_footer.tsx | 3 +- .../components/selectable_spaces_control.tsx | 12 +- .../components/share_mode_control.tsx | 4 +- .../components/share_to_space_flyout.tsx | 2 +- .../share_to_space_flyout_internal.test.tsx | 2 +- .../share_to_space_flyout_internal.tsx | 28 +- .../components/share_to_space_form.tsx | 4 +- .../share_saved_objects_to_space/index.ts | 6 +- ...are_saved_objects_to_space_service.test.ts | 38 - .../share_saved_objects_to_space_service.ts | 27 - .../share_saved_objects_to_space/types.ts | 123 ++ .../utils/redirect_legacy_url.ts | 2 +- .../spaces/public/space_avatar/index.ts | 1 + .../public/space_avatar/space_attributes.ts | 3 +- .../public/space_avatar/space_avatar.tsx | 2 +- .../space_avatar/space_avatar_internal.tsx | 18 +- .../spaces/public/space_avatar/types.ts | 36 + .../plugins/spaces/public/space_list/index.ts | 1 + .../spaces/public/space_list/space_list.tsx | 2 +- .../space_list/space_list_internal.test.tsx | 4 +- .../public/space_list/space_list_internal.tsx | 19 +- .../plugins/spaces/public/space_list/types.ts | 31 + .../space_selector/components/space_card.tsx | 3 +- .../space_selector/components/space_cards.tsx | 3 +- .../space_selector/space_selector.test.tsx | 2 +- .../public/space_selector/space_selector.tsx | 2 +- .../spaces/public/spaces_context/context.tsx | 24 +- .../spaces/public/spaces_context/index.ts | 1 + .../spaces/public/spaces_context/types.ts | 24 +- .../spaces/public/spaces_context/wrapper.tsx | 4 +- .../spaces_context/wrapper_internal.tsx | 28 +- .../spaces_manager/spaces_manager.mock.ts | 3 +- .../public/spaces_manager/spaces_manager.ts | 8 +- x-pack/plugins/spaces/public/types.ts | 39 +- .../spaces/public/ui_api/components.tsx | 4 +- x-pack/plugins/spaces/public/ui_api/index.ts | 6 +- x-pack/plugins/spaces/public/ui_api/mocks.ts | 29 - x-pack/plugins/spaces/public/ui_api/types.ts | 112 ++ .../capabilities_switcher.test.ts | 2 +- .../capabilities/capabilities_switcher.ts | 2 +- x-pack/plugins/spaces/server/index.ts | 6 +- .../on_post_auth_interceptor.ts | 2 +- .../server/routes/api/external/get_all.ts | 2 +- .../spaces/server/routes/api/external/put.ts | 2 +- .../lib/convert_saved_object_to_space.ts | 2 +- .../migrations/space_migrations.test.ts | 3 +- .../migrations/space_migrations.ts | 3 +- .../spaces_client/spaces_client.mock.ts | 3 +- .../server/spaces_client/spaces_client.ts | 2 +- .../server/spaces_service/spaces_service.ts | 2 +- x-pack/plugins/spaces/tsconfig.json | 2 - .../translations/translations/ja-JP.json | 6 - .../translations/translations/zh-CN.json | 6 - .../plugins/triggers_actions_ui/kibana.json | 2 +- .../public/application/app.tsx | 2 - .../components/alert_details_route.test.tsx | 10 +- .../components/alert_details_route.tsx | 12 +- .../common/lib/kibana/kibana_react.mock.ts | 2 - .../triggers_actions_ui/public/plugin.ts | 3 - .../plugins/triggers_actions_ui/tsconfig.json | 2 +- 152 files changed, 912 insertions(+), 2594 deletions(-) delete mode 100644 api_docs/spaces_oss.json delete mode 100644 api_docs/spaces_oss.mdx create mode 100644 src/plugins/saved_objects_management/public/services/actions/copy_saved_objects_to_space_action.tsx rename src/plugins/{spaces_oss/jest.config.js => saved_objects_management/public/services/actions/index.ts} (64%) rename {x-pack/plugins/spaces/public/share_saved_objects_to_space => src/plugins/saved_objects_management/public/services/actions}/share_saved_objects_to_space_action.test.tsx (86%) rename {x-pack/plugins/spaces/public/share_saved_objects_to_space => src/plugins/saved_objects_management/public/services/actions}/share_saved_objects_to_space_action.tsx (79%) rename src/plugins/{spaces_oss/common => saved_objects_management/public/services/columns}/index.ts (78%) rename {x-pack/plugins/spaces/public/share_saved_objects_to_space => src/plugins/saved_objects_management/public/services/columns}/share_saved_objects_to_space_column.tsx (69%) delete mode 100644 src/plugins/spaces_oss/README.md delete mode 100644 src/plugins/spaces_oss/common/types.ts delete mode 100644 src/plugins/spaces_oss/kibana.json delete mode 100644 src/plugins/spaces_oss/public/api.ts delete mode 100644 src/plugins/spaces_oss/public/index.ts delete mode 100644 src/plugins/spaces_oss/public/mocks/index.ts delete mode 100644 src/plugins/spaces_oss/public/plugin.test.ts delete mode 100644 src/plugins/spaces_oss/public/plugin.ts delete mode 100644 src/plugins/spaces_oss/public/types.ts delete mode 100644 src/plugins/spaces_oss/tsconfig.json delete mode 100644 x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx delete mode 100644 x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts delete mode 100644 x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts create mode 100644 x-pack/plugins/spaces/public/copy_saved_objects_to_space/lib/process_import_response.ts rename src/plugins/spaces_oss/public/api.mock.ts => x-pack/plugins/spaces/public/mocks.ts (68%) delete mode 100644 x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.test.ts delete mode 100644 x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_service.ts create mode 100644 x-pack/plugins/spaces/public/space_avatar/types.ts create mode 100644 x-pack/plugins/spaces/public/space_list/types.ts delete mode 100644 x-pack/plugins/spaces/public/ui_api/mocks.ts create mode 100644 x-pack/plugins/spaces/public/ui_api/types.ts diff --git a/.eslintrc.js b/.eslintrc.js index 88000a6b0fc80..8a981f07dcd35 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1571,7 +1571,6 @@ module.exports = { { files: [ 'src/plugins/security_oss/**/*.{js,mjs,ts,tsx}', - 'src/plugins/spaces_oss/**/*.{js,mjs,ts,tsx}', 'x-pack/plugins/encrypted_saved_objects/**/*.{js,mjs,ts,tsx}', 'x-pack/plugins/security/**/*.{js,mjs,ts,tsx}', 'x-pack/plugins/spaces/**/*.{js,mjs,ts,tsx}', diff --git a/api_docs/spaces_oss.json b/api_docs/spaces_oss.json deleted file mode 100644 index cd59756b548b6..0000000000000 --- 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 d166a37a9373a..0000000000000 --- 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 8199a5995d368..44940d0141186 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -223,10 +223,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 b405fbbe8fafc..81195e520b447 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -102,7 +102,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 54eaf461b73d7..969dbcae4cefd 100644 --- a/src/plugins/dashboard/kibana.json +++ b/src/plugins/dashboard/kibana.json @@ -14,11 +14,7 @@ "presentationUtil", "visualizations" ], - "optionalPlugins": [ - "home", - "spacesOss", - "savedObjectsTaggingOss", - "usageCollection"], + "optionalPlugins": ["home", "spaces", "savedObjectsTaggingOss", "usageCollection"], "server": true, "ui": true, "requiredBundles": [ diff --git a/src/plugins/dashboard/public/application/dashboard_router.tsx b/src/plugins/dashboard/public/application/dashboard_router.tsx index cb40b30542869..7c538c0f3bf97 100644 --- a/src/plugins/dashboard/public/application/dashboard_router.tsx +++ b/src/plugins/dashboard/public/application/dashboard_router.tsx @@ -79,6 +79,7 @@ export async function mountApp({ urlForwarding, data: dataStart, share: shareStart, + spaces: spacesApi, embeddable: embeddableStart, kibanaLegacy: { dashboardConfig }, savedObjectsTaggingOss, @@ -86,7 +87,6 @@ export async function mountApp({ 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 3da299bb20095..1973fd4dbe394 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 e6d2c6400818f..89a0acaf611bd 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 4febb8b5555cf..7558ade4705be 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 48e61eb9e4da5..b8207e0627b81 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 b855850ed185d..6e5a30b046e6c 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 fd938abd2704b..f22f0333ec229 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 f4578c4c4b8e1..cc6bd83005463 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 609cd5e5d3a04..7a2536611f58a 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 015a4953fe238..b72ca3d2535de 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 0000000000000..5773f64a1e628 --- /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 8be5bf6e0fb54..39cde652fd54f 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 9c3a56aac20ad..235f8d4508a64 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 90dda8ad0b013..e36c13bd8fd8b 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 3e18cdaec0c47..581a55fa0066d 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 fb919af2b4028..74c06a3d33218 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 a499a06983e63..f93c603f9011d 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 609811cd6b7ce..736b656f15d93 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 0f26da69acd17..545d4697ca2cd 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 73de736d6fb4e..0000000000000 --- 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 b5c418cf3177e..0000000000000 --- 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 10127634618f1..0000000000000 --- 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 7492142f0d792..0000000000000 --- 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 9c4d5fd17700c..0000000000000 --- 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 dc7b9e34fe822..0000000000000 --- 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 fcbe1c7d86ce5..0000000000000 --- 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 2531453257e3e..0000000000000 --- 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 df20e9be6eaa1..0000000000000 --- 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 35942863c1f1b..0000000000000 --- 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 5245b374b9fec..3f6e1fdbe8475 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 a405f0486430c..8f17591fdd64b 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 a1528b91d5abb..8dccbe973318b 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 ef1338ab9d971..3a66b6d80c615 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 486b1c8bc1d03..c9c7df222df29 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 48a0d18653053..27bf246c0596f 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 582a7d6c5427e..56c841f68f504 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 fd535d20de557..38c122ba10086 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 9ca41a018cd33..6492ca6e01af0 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 2925866a5752f..fb21fac3006b8 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 9861b008beb9f..e715cb217ae67 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 003a0c068a166..3af87c44f8e0f 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 0128a7483f166..630d4a000f3e5 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 f78fe7bbdac1b..92b9a0a99ddbb 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 55bd1c137f8cf..39864447310b4 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 e01224d03bfc3..090e5d0894480 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 5658f95b62854..28d64e41fcbe4 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 75a27a3738e61..613cd9fdaebce 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 9bec9e32ca736..a5af84bd33948 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 b04450ae4febd..8d9c2f17bdec6 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 3fee2fdfa975d..f1472032fffa1 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 c021d8bdf69a1..998b202a8d6b3 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 cb821061b9251..2bad5757613e0 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 8f219b7154def..7697780c352c9 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 e28e95ed42d25..1b92936816e52 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 f3173e14aa794..6001920f34c11 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 1fba249e5410a..91ee2acf6bb42 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 2f96646844a35..57b55ac5a2618 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 6d14584ac21a9..932b8bc9254f6 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 e2db8e7fb7480..d58490a86b7f5 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 7818e648dd1cf..0000000000000 --- 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 f55a7d8054608..0000000000000 --- 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 17bb26cbf7f11..0000000000000 --- 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 abbbc8ba1368f..2443c8443c091 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 882ee234ca5dc..70a5cadd527bc 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 0000000000000..cf402b0dd4ec2 --- /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 6a3d82aaef59c..298b89050b637 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 68baba12d8b98..206952774ff9a 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 60a4e176f40bb..732d779c6f616 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 08dda35a6eb10..d13f8f48e6719 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 f3ed578a94962..4c808f9a47582 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 92b68426d172e..dc78441c3ba02 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 7481676430307..9860d701ee4ab 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 78ea73741a8ad..2371a97370b53 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 5a7ae701e97e0..bd0621e539ed0 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 da32ea79724ad..6415444a05620 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 d332b3e34c0a6..7598e18d6680c 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 200b868a1b103..e40f92bd54486 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 f1d0d7b55a5d6..00df0efe6b84c 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 9ad7599b5ae61..897f58e1d649c 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 392a95c445921..5fafe151dade9 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 1653506c550f6..41a05a38fa305 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 39478ca2fd9be..43b701c48b2c2 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 1ba1cd1a1f3d4..782cb3ba708a3 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 f053c081ab589..8aaf455204c9b 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 1ebde52a734c6..95bf7b404db34 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 ea3f29724e0d5..97318ea5312be 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 fad819d35e18a..4e45487a20562 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 7151f72583d6a..07439542bf839 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 dc2a358a653ab..e0f25277c50fe 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 f02cae7674058..8b435865c760f 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 712adeb26bccb..076825e7c70aa 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 7f8c659805c45..1841d634c6482 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 beed0fd9d592a..fe90ee8d6a8a9 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 eb973a48ef879..0000000000000 --- 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 bc70347760465..0000000000000 --- 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 be8165e822736..1beccaa546282 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 338b2e8c94e0d..d427b1bc05242 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 86d94738f2c79..a8d67b3964665 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 682a61c6f23a5..047e544f94056 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 a2d58a12c5eaa..2bd86effcc656 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 91b4dbf8a964e..b8fd5ed77f488 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 0000000000000..365c71eeeea73 --- /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 1570ad123b9ab..9d367f3739c70 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 efd8b367bcd45..86e6432d1e210 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 8109444fc1271..39ae339fb7e18 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 ac7e6446f2ccd..bfe4486fafa76 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 0000000000000..2e7e813a48a2f --- /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 0628f79990af6..214659169e72d 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 e7bef5f646036..c13a3a53fbe8f 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 b4417d98bcace..e17c3e0078d42 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 cee304408495d..00ad39bf0027f 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 e38a2f17151a9..64df17bed5768 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 0187131b02b93..5b5ff829b3800 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 e73da7cb26b68..d3a6859875b9c 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 6de14290abb74..8fae6e78d1bb2 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 dd6408e9550ee..83ad69b1017d5 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 5282163f93b15..3f3cc3f4d7801 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 845373bf22299..d0406d744b72a 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 e999e332b9884..fd926621b72da 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 a277e3a1dd119..a33480712ffae 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 4bfb482b41407..e0749b04de139 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 fe3826a58fccc..0000000000000 --- 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 0000000000000..5048e5a9b9652 --- /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 c3393da770ded..13be8398da480 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 1f6249d9b3220..ac2ff735de797 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 4765b06f5a02a..31714df958d49 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 ff81960185b62..f5b41786d2478 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 7f0bd3231c6dd..09a4ac5a843a6 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 b58601c8c7e77..196f7c11932eb 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 6a90d367fc4a7..53969d3984bda 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 62a3d98662939..e07050fe97d73 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 d88db2b0181dd..c26983e84de57 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 d893d2b089f89..a4e209ff11d32 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 824d6e28b9923..0a91c7aff1a08 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 e951ed38072d7..2ffe77a4c9a89 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 4cc95504a158e..bf2c6e7fc8694 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 90c2913f3cd98..334d382b6cf58 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -23505,8 +23505,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", @@ -23615,13 +23613,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 fae942e60c39b..18083f6a70a06 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -23895,8 +23895,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", @@ -24006,14 +24004,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 9e9af347af2a2..4033889d9811e 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 cc34f1beaf6b9..9786f5dcb949d 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 441daad1a50bd..9ecaa3d915551 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 b6279d7fca100..123d60bb9fea3 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 f8aa483711c30..2985a5306ed51 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 36d6964ce7753..7661eefba7f65 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 e3c8b77d2c1d4..ac36780f10c01 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" }, ] }