From d71ced9edf6c3db884adccc48c3872d76f8693c3 Mon Sep 17 00:00:00 2001 From: Nick Peihl Date: Wed, 8 Nov 2023 11:48:01 -0500 Subject: [PATCH 1/2] Make Tags shareable across Spaces --- .../saved_objects_tagging_oss/common/types.ts | 1 + .../common/capabilities.ts | 2 + .../saved_objects_tagging/kibana.jsonc | 3 +- .../management/components/spaces_list.tsx | 70 +++++++++++++++++++ .../public/management/components/table.tsx | 30 ++++++++ .../public/management/mount_section.tsx | 36 ++++++---- .../public/management/tag_management_page.tsx | 5 ++ .../public/plugin.test.ts | 6 +- .../saved_objects_tagging/public/plugin.ts | 15 +++- .../public/ui_api/index.ts | 3 + .../server/services/tags/utils.ts | 1 + .../saved_objects_tagging/tsconfig.json | 1 + 12 files changed, 155 insertions(+), 18 deletions(-) create mode 100644 x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx diff --git a/src/plugins/saved_objects_tagging_oss/common/types.ts b/src/plugins/saved_objects_tagging_oss/common/types.ts index 046e187a6b9d7..e9ba1fc7149c8 100644 --- a/src/plugins/saved_objects_tagging_oss/common/types.ts +++ b/src/plugins/saved_objects_tagging_oss/common/types.ts @@ -8,6 +8,7 @@ export interface Tag { id: string; + namespaces?: string[]; name: string; description: string; color: string; diff --git a/x-pack/plugins/saved_objects_tagging/common/capabilities.ts b/x-pack/plugins/saved_objects_tagging/common/capabilities.ts index f25652960da41..b12caa2436e05 100644 --- a/x-pack/plugins/saved_objects_tagging/common/capabilities.ts +++ b/x-pack/plugins/saved_objects_tagging/common/capabilities.ts @@ -18,6 +18,7 @@ export interface TagsCapabilities { delete: boolean; assign: boolean; viewConnections: boolean; + shareIntoSpace: boolean; } export const getTagsCapabilities = (capabilities: Capabilities): TagsCapabilities => { @@ -29,5 +30,6 @@ export const getTagsCapabilities = (capabilities: Capabilities): TagsCapabilitie delete: (rawTagCapabilities?.delete as boolean) ?? false, assign: (rawTagCapabilities?.assign as boolean) ?? false, viewConnections: (capabilities.savedObjectsManagement?.read as boolean) ?? false, + shareIntoSpace: (capabilities.savedObjectsManagement?.shareIntoSpace as boolean) ?? false, }; }; diff --git a/x-pack/plugins/saved_objects_tagging/kibana.jsonc b/x-pack/plugins/saved_objects_tagging/kibana.jsonc index 7daa89f63ba37..e0bf92503f897 100644 --- a/x-pack/plugins/saved_objects_tagging/kibana.jsonc +++ b/x-pack/plugins/saved_objects_tagging/kibana.jsonc @@ -17,7 +17,8 @@ ], "optionalPlugins": [ "usageCollection", - "security" + "security", + "spaces" ], "requiredBundles": [ "kibanaReact" diff --git a/x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx b/x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx new file mode 100644 index 0000000000000..43268efdaf560 --- /dev/null +++ b/x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx @@ -0,0 +1,70 @@ +/* + * 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, { FC, useState } from 'react'; + +import { i18n } from '@kbn/i18n'; +import type { SpacesPluginStart, ShareToSpaceFlyoutProps } from '@kbn/spaces-plugin/public'; +import { tagSavedObjectTypeName } from '../../../common/constants'; + +interface Props { + spacesApi: SpacesPluginStart; + canShareIntoSpace: boolean; + spaceIds: string[]; + id: string; + title: string; + refresh(): void; +} + +const noun = i18n.translate('indexPatternManagement.indexPatternTable.savedObjectName', { + defaultMessage: 'data view', +}); + +export const SpacesList: FC = ({ + spacesApi, + canShareIntoSpace, + spaceIds, + id, + title, + refresh, +}) => { + const [showFlyout, setShowFlyout] = useState(false); + + function onClose() { + setShowFlyout(false); + } + + const LazySpaceList = spacesApi.ui.components.getSpaceList; + const LazyShareToSpaceFlyout = spacesApi.ui.components.getShareToSpaceFlyout; + + const shareToSpaceFlyoutProps: ShareToSpaceFlyoutProps = { + savedObjectTarget: { + type: tagSavedObjectTypeName, + namespaces: spaceIds, + id, + title, + noun, + }, + onUpdate: refresh, + onClose, + }; + + const clickProperties = canShareIntoSpace + ? { cursorStyle: 'pointer', listOnClick: () => setShowFlyout(true) } + : { cursorStyle: 'not-allowed' }; + return ( + <> + + {showFlyout && } + + ); +}; diff --git a/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx b/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx index 359df30516511..920d975464f52 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx @@ -9,9 +9,11 @@ import React, { useRef, useEffect, FC, ReactNode } from 'react'; import { EuiInMemoryTable, EuiBasicTableColumn, EuiLink, Query } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; +import { SpacesApi } from '@kbn/spaces-plugin/public'; import { TagsCapabilities, TagWithRelations } from '../../../common'; import { TagBadge } from '../../components'; import { TagAction } from '../actions'; +import { SpacesList } from './spaces_list'; interface TagTableProps { loading: boolean; @@ -19,6 +21,7 @@ interface TagTableProps { tags: TagWithRelations[]; initialQuery?: Query; allowSelection: boolean; + reloadTags: () => void; onQueryChange: (query?: Query) => void; selectedTags: TagWithRelations[]; onSelectionChange: (selection: TagWithRelations[]) => void; @@ -26,6 +29,7 @@ interface TagTableProps { onShowRelations: (tag: TagWithRelations) => void; actions: TagAction[]; actionBar: ReactNode; + spaces?: SpacesApi; } const tablePagination = { @@ -49,6 +53,7 @@ export const TagTable: FC = ({ tags, initialQuery, allowSelection, + reloadTags, onQueryChange, selectedTags, onSelectionChange, @@ -56,6 +61,7 @@ export const TagTable: FC = ({ getTagRelationUrl, actionBar, actions, + spaces, }) => { const tableRef = useRef>(null); @@ -65,6 +71,29 @@ export const TagTable: FC = ({ } }, [selectedTags]); + const spacesColumn: EuiBasicTableColumn | undefined = spaces + ? { + field: 'spaces', + name: i18n.translate('xpack.savedObjectsTagging.management.table.columns.spaces', { + defaultMessage: 'Spaces', + }), + width: '20%', + render: (_, tag) => { + return ( + + ); + }, + } + : undefined; + const columns: Array> = [ { field: 'name', @@ -126,6 +155,7 @@ export const TagTable: FC = ({ ); }, }, + ...(spacesColumn ? [spacesColumn] : []), ...(actions.length ? [ { diff --git a/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx b/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx index 72ac1863075f7..58691ec3a73ed 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx @@ -8,10 +8,11 @@ import React, { FC } from 'react'; import ReactDOM from 'react-dom'; import { I18nProvider } from '@kbn/i18n-react'; +import { SpacesApi, SpacesContextProps } from '@kbn/spaces-plugin/public'; import { CoreSetup, ApplicationStart } from '@kbn/core/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { ManagementAppMountParams } from '@kbn/management-plugin/public'; -import { getTagsCapabilities } from '../../common'; +import { getTagsCapabilities, tagFeatureId } from '../../common'; import { SavedObjectTaggingPluginStart } from '../types'; import { ITagInternalClient, ITagAssignmentService, ITagsCache } from '../services'; import { TagManagementPage } from './tag_management_page'; @@ -20,6 +21,7 @@ interface MountSectionParams { tagClient: ITagInternalClient; tagCache: ITagsCache; assignmentService: ITagAssignmentService; + spaces?: SpacesApi; core: CoreSetup<{}, SavedObjectTaggingPluginStart>; mountParams: ManagementAppMountParams; title: string; @@ -36,6 +38,8 @@ const RedirectToHomeIfUnauthorized: FC<{ return children! as React.ReactElement; }; +const getEmptyFunctionComponent: FC = ({ children }) => <>{children}; + export const mountSection = async ({ tagClient, tagCache, @@ -43,6 +47,7 @@ export const mountSection = async ({ core, mountParams, title, + spaces, }: MountSectionParams) => { const [coreStart] = await core.getStartServices(); const { element, setBreadcrumbs, theme$ } = mountParams; @@ -50,20 +55,27 @@ export const mountSection = async ({ const assignableTypes = await assignmentService.getAssignableTypes(); coreStart.chrome.docTitle.change(title); + const SpacesContextWrapper = spaces + ? spaces.ui.components.getSpacesContextProvider + : getEmptyFunctionComponent; + ReactDOM.render( - - - + + + + + , element diff --git a/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx b/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx index 8093d59a29bd2..2e7a7e2d58b1f 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx @@ -12,6 +12,7 @@ import { Query } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ChromeBreadcrumb, CoreStart } from '@kbn/core/public'; import { EuiSpacer } from '@elastic/eui'; +import { SpacesApi } from '@kbn/spaces-plugin/public'; import { TagWithRelations, TagsCapabilities } from '../../common'; import { getCreateModalOpener } from '../components/edition_modal'; import { ITagInternalClient, ITagAssignmentService, ITagsCache } from '../services'; @@ -27,6 +28,7 @@ interface TagManagementPageParams { tagClient: ITagInternalClient; tagCache: ITagsCache; assignmentService: ITagAssignmentService; + spaces?: SpacesApi; capabilities: TagsCapabilities; assignableTypes: string[]; } @@ -39,6 +41,7 @@ export const TagManagementPage: FC = ({ assignmentService, capabilities, assignableTypes, + spaces, }) => { const { overlays, notifications, application, http, theme } = core; const [loading, setLoading] = useState(false); @@ -206,6 +209,7 @@ export const TagManagementPage: FC = ({ setQuery(newQuery); setSelectedTags([]); }} + reloadTags={fetchTags} allowSelection={bulkActions.length > 0} selectedTags={selectedTags} onSelectionChange={(tags) => { @@ -215,6 +219,7 @@ export const TagManagementPage: FC = ({ onShowRelations={(tag) => { showTagRelations(tag); }} + spaces={spaces} /> ); diff --git a/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts b/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts index e38d0ccfceb61..8a35bc8b901cf 100644 --- a/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts +++ b/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts @@ -76,7 +76,7 @@ describe('SavedObjectTaggingPlugin', () => { }); it('creates its cache with correct parameters', () => { - plugin.start(coreMock.createStart()); + plugin.start(coreMock.createStart(), {}); expect(MockedTagsCache).toHaveBeenCalledTimes(1); expect(MockedTagsCache).toHaveBeenCalledWith({ @@ -94,7 +94,7 @@ describe('SavedObjectTaggingPlugin', () => { const coreStart = coreMock.createStart(); coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); - plugin.start(coreStart); + plugin.start(coreStart, {}); expect(MockedTagsCache.mock.instances[0].initialize).not.toHaveBeenCalled(); }); @@ -103,7 +103,7 @@ describe('SavedObjectTaggingPlugin', () => { const coreStart = coreMock.createStart(); coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(true); - plugin.start(coreStart); + plugin.start(coreStart, {}); expect(MockedTagsCache.mock.instances[0].initialize).not.toHaveBeenCalled(); }); diff --git a/x-pack/plugins/saved_objects_tagging/public/plugin.ts b/x-pack/plugins/saved_objects_tagging/public/plugin.ts index e5ad1dfa5095f..c9f07e249ecc3 100644 --- a/x-pack/plugins/saved_objects_tagging/public/plugin.ts +++ b/x-pack/plugins/saved_objects_tagging/public/plugin.ts @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { CoreSetup, CoreStart, PluginInitializerContext, Plugin } from '@kbn/core/public'; +import { SpacesApi, SpacesPluginStart } from '@kbn/spaces-plugin/public'; import { ManagementSetup } from '@kbn/management-plugin/public'; import { SavedObjectTaggingOssPluginSetup } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { tagManagementSectionId } from '../common/constants'; @@ -21,12 +22,17 @@ interface SetupDeps { savedObjectsTaggingOss: SavedObjectTaggingOssPluginSetup; } +interface StartDeps { + spaces?: SpacesPluginStart; +} + export class SavedObjectTaggingPlugin - implements Plugin<{}, SavedObjectTaggingPluginStart, SetupDeps, {}> + implements Plugin<{}, SavedObjectTaggingPluginStart, SetupDeps, StartDeps> { private tagClient?: TagsClient; private tagCache?: TagsCache; private assignmentService?: TagAssignmentService; + private spaces?: SpacesApi; private readonly config: SavedObjectsTaggingClientConfig; constructor(context: PluginInitializerContext) { @@ -56,6 +62,7 @@ export class SavedObjectTaggingPlugin core, mountParams, title, + spaces: this.spaces, }); }, }); @@ -67,13 +74,17 @@ export class SavedObjectTaggingPlugin return {}; } - public start({ http, application, overlays, theme, analytics, notifications }: CoreStart) { + public start( + { http, application, overlays, theme, analytics, notifications }: CoreStart, + { spaces }: StartDeps + ) { this.tagCache = new TagsCache({ refreshHandler: () => this.tagClient!.getAll({ asSystemRequest: true }), refreshInterval: this.config.cacheRefreshInterval, }); this.tagClient = new TagsClient({ analytics, http, changeListener: this.tagCache }); this.assignmentService = new TagAssignmentService({ http }); + this.spaces = spaces; // do not fetch tags on anonymous page if (!http.anonymousPaths.isAnonymous(window.location.pathname)) { diff --git a/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts b/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts index b2dca68d5cc95..e13976683bfc5 100644 --- a/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts +++ b/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts @@ -6,6 +6,7 @@ */ import type { NotificationsStart, OverlayStart, ThemeServiceStart } from '@kbn/core/public'; +import { SpacesApi } from '@kbn/spaces-plugin/public'; import { SavedObjectsTaggingApiUi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { TagsCapabilities } from '../../common'; import { ITagsCache, ITagInternalClient } from '../services'; @@ -30,6 +31,7 @@ interface GetUiApiOptions { cache: ITagsCache; client: ITagInternalClient; notifications: NotificationsStart; + spaces?: SpacesApi; } export const getUiApi = ({ @@ -39,6 +41,7 @@ export const getUiApi = ({ overlays, theme, notifications, + spaces, }: GetUiApiOptions): SavedObjectsTaggingApiUi => { const components = getComponents({ cache, diff --git a/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts b/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts index 7df3ff955ecc8..8011eb8320c81 100644 --- a/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts +++ b/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts @@ -10,6 +10,7 @@ import { Tag, TagSavedObject } from '../../../common/types'; export const savedObjectToTag = (savedObject: TagSavedObject): Tag => { return { id: savedObject.id, + namespaces: savedObject.namespaces, ...savedObject.attributes, }; }; diff --git a/x-pack/plugins/saved_objects_tagging/tsconfig.json b/x-pack/plugins/saved_objects_tagging/tsconfig.json index 1876578728d45..8f99024ffb11e 100644 --- a/x-pack/plugins/saved_objects_tagging/tsconfig.json +++ b/x-pack/plugins/saved_objects_tagging/tsconfig.json @@ -17,6 +17,7 @@ "@kbn/usage-collection-plugin", "@kbn/features-plugin", "@kbn/security-plugin", + "@kbn/spaces-plugin", "@kbn/i18n", "@kbn/utility-types", "@kbn/i18n-react", From 3e6419321ae5628f1844c66e58307b2ce1b5e951 Mon Sep 17 00:00:00 2001 From: Nick Peihl Date: Wed, 8 Nov 2023 11:52:23 -0500 Subject: [PATCH 2/2] Revert "Make Tags shareable across Spaces" This reverts commit d71ced9edf6c3db884adccc48c3872d76f8693c3. --- .../saved_objects_tagging_oss/common/types.ts | 1 - .../common/capabilities.ts | 2 - .../saved_objects_tagging/kibana.jsonc | 3 +- .../management/components/spaces_list.tsx | 70 ------------------- .../public/management/components/table.tsx | 30 -------- .../public/management/mount_section.tsx | 36 ++++------ .../public/management/tag_management_page.tsx | 5 -- .../public/plugin.test.ts | 6 +- .../saved_objects_tagging/public/plugin.ts | 15 +--- .../public/ui_api/index.ts | 3 - .../server/services/tags/utils.ts | 1 - .../saved_objects_tagging/tsconfig.json | 1 - 12 files changed, 18 insertions(+), 155 deletions(-) delete mode 100644 x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx diff --git a/src/plugins/saved_objects_tagging_oss/common/types.ts b/src/plugins/saved_objects_tagging_oss/common/types.ts index e9ba1fc7149c8..046e187a6b9d7 100644 --- a/src/plugins/saved_objects_tagging_oss/common/types.ts +++ b/src/plugins/saved_objects_tagging_oss/common/types.ts @@ -8,7 +8,6 @@ export interface Tag { id: string; - namespaces?: string[]; name: string; description: string; color: string; diff --git a/x-pack/plugins/saved_objects_tagging/common/capabilities.ts b/x-pack/plugins/saved_objects_tagging/common/capabilities.ts index b12caa2436e05..f25652960da41 100644 --- a/x-pack/plugins/saved_objects_tagging/common/capabilities.ts +++ b/x-pack/plugins/saved_objects_tagging/common/capabilities.ts @@ -18,7 +18,6 @@ export interface TagsCapabilities { delete: boolean; assign: boolean; viewConnections: boolean; - shareIntoSpace: boolean; } export const getTagsCapabilities = (capabilities: Capabilities): TagsCapabilities => { @@ -30,6 +29,5 @@ export const getTagsCapabilities = (capabilities: Capabilities): TagsCapabilitie delete: (rawTagCapabilities?.delete as boolean) ?? false, assign: (rawTagCapabilities?.assign as boolean) ?? false, viewConnections: (capabilities.savedObjectsManagement?.read as boolean) ?? false, - shareIntoSpace: (capabilities.savedObjectsManagement?.shareIntoSpace as boolean) ?? false, }; }; diff --git a/x-pack/plugins/saved_objects_tagging/kibana.jsonc b/x-pack/plugins/saved_objects_tagging/kibana.jsonc index e0bf92503f897..7daa89f63ba37 100644 --- a/x-pack/plugins/saved_objects_tagging/kibana.jsonc +++ b/x-pack/plugins/saved_objects_tagging/kibana.jsonc @@ -17,8 +17,7 @@ ], "optionalPlugins": [ "usageCollection", - "security", - "spaces" + "security" ], "requiredBundles": [ "kibanaReact" diff --git a/x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx b/x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx deleted file mode 100644 index 43268efdaf560..0000000000000 --- a/x-pack/plugins/saved_objects_tagging/public/management/components/spaces_list.tsx +++ /dev/null @@ -1,70 +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, { FC, useState } from 'react'; - -import { i18n } from '@kbn/i18n'; -import type { SpacesPluginStart, ShareToSpaceFlyoutProps } from '@kbn/spaces-plugin/public'; -import { tagSavedObjectTypeName } from '../../../common/constants'; - -interface Props { - spacesApi: SpacesPluginStart; - canShareIntoSpace: boolean; - spaceIds: string[]; - id: string; - title: string; - refresh(): void; -} - -const noun = i18n.translate('indexPatternManagement.indexPatternTable.savedObjectName', { - defaultMessage: 'data view', -}); - -export const SpacesList: FC = ({ - spacesApi, - canShareIntoSpace, - spaceIds, - id, - title, - refresh, -}) => { - const [showFlyout, setShowFlyout] = useState(false); - - function onClose() { - setShowFlyout(false); - } - - const LazySpaceList = spacesApi.ui.components.getSpaceList; - const LazyShareToSpaceFlyout = spacesApi.ui.components.getShareToSpaceFlyout; - - const shareToSpaceFlyoutProps: ShareToSpaceFlyoutProps = { - savedObjectTarget: { - type: tagSavedObjectTypeName, - namespaces: spaceIds, - id, - title, - noun, - }, - onUpdate: refresh, - onClose, - }; - - const clickProperties = canShareIntoSpace - ? { cursorStyle: 'pointer', listOnClick: () => setShowFlyout(true) } - : { cursorStyle: 'not-allowed' }; - return ( - <> - - {showFlyout && } - - ); -}; diff --git a/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx b/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx index 920d975464f52..359df30516511 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/management/components/table.tsx @@ -9,11 +9,9 @@ import React, { useRef, useEffect, FC, ReactNode } from 'react'; import { EuiInMemoryTable, EuiBasicTableColumn, EuiLink, Query } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; -import { SpacesApi } from '@kbn/spaces-plugin/public'; import { TagsCapabilities, TagWithRelations } from '../../../common'; import { TagBadge } from '../../components'; import { TagAction } from '../actions'; -import { SpacesList } from './spaces_list'; interface TagTableProps { loading: boolean; @@ -21,7 +19,6 @@ interface TagTableProps { tags: TagWithRelations[]; initialQuery?: Query; allowSelection: boolean; - reloadTags: () => void; onQueryChange: (query?: Query) => void; selectedTags: TagWithRelations[]; onSelectionChange: (selection: TagWithRelations[]) => void; @@ -29,7 +26,6 @@ interface TagTableProps { onShowRelations: (tag: TagWithRelations) => void; actions: TagAction[]; actionBar: ReactNode; - spaces?: SpacesApi; } const tablePagination = { @@ -53,7 +49,6 @@ export const TagTable: FC = ({ tags, initialQuery, allowSelection, - reloadTags, onQueryChange, selectedTags, onSelectionChange, @@ -61,7 +56,6 @@ export const TagTable: FC = ({ getTagRelationUrl, actionBar, actions, - spaces, }) => { const tableRef = useRef>(null); @@ -71,29 +65,6 @@ export const TagTable: FC = ({ } }, [selectedTags]); - const spacesColumn: EuiBasicTableColumn | undefined = spaces - ? { - field: 'spaces', - name: i18n.translate('xpack.savedObjectsTagging.management.table.columns.spaces', { - defaultMessage: 'Spaces', - }), - width: '20%', - render: (_, tag) => { - return ( - - ); - }, - } - : undefined; - const columns: Array> = [ { field: 'name', @@ -155,7 +126,6 @@ export const TagTable: FC = ({ ); }, }, - ...(spacesColumn ? [spacesColumn] : []), ...(actions.length ? [ { diff --git a/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx b/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx index 58691ec3a73ed..72ac1863075f7 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/management/mount_section.tsx @@ -8,11 +8,10 @@ import React, { FC } from 'react'; import ReactDOM from 'react-dom'; import { I18nProvider } from '@kbn/i18n-react'; -import { SpacesApi, SpacesContextProps } from '@kbn/spaces-plugin/public'; import { CoreSetup, ApplicationStart } from '@kbn/core/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { ManagementAppMountParams } from '@kbn/management-plugin/public'; -import { getTagsCapabilities, tagFeatureId } from '../../common'; +import { getTagsCapabilities } from '../../common'; import { SavedObjectTaggingPluginStart } from '../types'; import { ITagInternalClient, ITagAssignmentService, ITagsCache } from '../services'; import { TagManagementPage } from './tag_management_page'; @@ -21,7 +20,6 @@ interface MountSectionParams { tagClient: ITagInternalClient; tagCache: ITagsCache; assignmentService: ITagAssignmentService; - spaces?: SpacesApi; core: CoreSetup<{}, SavedObjectTaggingPluginStart>; mountParams: ManagementAppMountParams; title: string; @@ -38,8 +36,6 @@ const RedirectToHomeIfUnauthorized: FC<{ return children! as React.ReactElement; }; -const getEmptyFunctionComponent: FC = ({ children }) => <>{children}; - export const mountSection = async ({ tagClient, tagCache, @@ -47,7 +43,6 @@ export const mountSection = async ({ core, mountParams, title, - spaces, }: MountSectionParams) => { const [coreStart] = await core.getStartServices(); const { element, setBreadcrumbs, theme$ } = mountParams; @@ -55,27 +50,20 @@ export const mountSection = async ({ const assignableTypes = await assignmentService.getAssignableTypes(); coreStart.chrome.docTitle.change(title); - const SpacesContextWrapper = spaces - ? spaces.ui.components.getSpacesContextProvider - : getEmptyFunctionComponent; - ReactDOM.render( - - - - - + + + , element diff --git a/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx b/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx index 2e7a7e2d58b1f..8093d59a29bd2 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/management/tag_management_page.tsx @@ -12,7 +12,6 @@ import { Query } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ChromeBreadcrumb, CoreStart } from '@kbn/core/public'; import { EuiSpacer } from '@elastic/eui'; -import { SpacesApi } from '@kbn/spaces-plugin/public'; import { TagWithRelations, TagsCapabilities } from '../../common'; import { getCreateModalOpener } from '../components/edition_modal'; import { ITagInternalClient, ITagAssignmentService, ITagsCache } from '../services'; @@ -28,7 +27,6 @@ interface TagManagementPageParams { tagClient: ITagInternalClient; tagCache: ITagsCache; assignmentService: ITagAssignmentService; - spaces?: SpacesApi; capabilities: TagsCapabilities; assignableTypes: string[]; } @@ -41,7 +39,6 @@ export const TagManagementPage: FC = ({ assignmentService, capabilities, assignableTypes, - spaces, }) => { const { overlays, notifications, application, http, theme } = core; const [loading, setLoading] = useState(false); @@ -209,7 +206,6 @@ export const TagManagementPage: FC = ({ setQuery(newQuery); setSelectedTags([]); }} - reloadTags={fetchTags} allowSelection={bulkActions.length > 0} selectedTags={selectedTags} onSelectionChange={(tags) => { @@ -219,7 +215,6 @@ export const TagManagementPage: FC = ({ onShowRelations={(tag) => { showTagRelations(tag); }} - spaces={spaces} /> ); diff --git a/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts b/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts index 8a35bc8b901cf..e38d0ccfceb61 100644 --- a/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts +++ b/x-pack/plugins/saved_objects_tagging/public/plugin.test.ts @@ -76,7 +76,7 @@ describe('SavedObjectTaggingPlugin', () => { }); it('creates its cache with correct parameters', () => { - plugin.start(coreMock.createStart(), {}); + plugin.start(coreMock.createStart()); expect(MockedTagsCache).toHaveBeenCalledTimes(1); expect(MockedTagsCache).toHaveBeenCalledWith({ @@ -94,7 +94,7 @@ describe('SavedObjectTaggingPlugin', () => { const coreStart = coreMock.createStart(); coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); - plugin.start(coreStart, {}); + plugin.start(coreStart); expect(MockedTagsCache.mock.instances[0].initialize).not.toHaveBeenCalled(); }); @@ -103,7 +103,7 @@ describe('SavedObjectTaggingPlugin', () => { const coreStart = coreMock.createStart(); coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(true); - plugin.start(coreStart, {}); + plugin.start(coreStart); expect(MockedTagsCache.mock.instances[0].initialize).not.toHaveBeenCalled(); }); diff --git a/x-pack/plugins/saved_objects_tagging/public/plugin.ts b/x-pack/plugins/saved_objects_tagging/public/plugin.ts index c9f07e249ecc3..e5ad1dfa5095f 100644 --- a/x-pack/plugins/saved_objects_tagging/public/plugin.ts +++ b/x-pack/plugins/saved_objects_tagging/public/plugin.ts @@ -7,7 +7,6 @@ import { i18n } from '@kbn/i18n'; import { CoreSetup, CoreStart, PluginInitializerContext, Plugin } from '@kbn/core/public'; -import { SpacesApi, SpacesPluginStart } from '@kbn/spaces-plugin/public'; import { ManagementSetup } from '@kbn/management-plugin/public'; import { SavedObjectTaggingOssPluginSetup } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { tagManagementSectionId } from '../common/constants'; @@ -22,17 +21,12 @@ interface SetupDeps { savedObjectsTaggingOss: SavedObjectTaggingOssPluginSetup; } -interface StartDeps { - spaces?: SpacesPluginStart; -} - export class SavedObjectTaggingPlugin - implements Plugin<{}, SavedObjectTaggingPluginStart, SetupDeps, StartDeps> + implements Plugin<{}, SavedObjectTaggingPluginStart, SetupDeps, {}> { private tagClient?: TagsClient; private tagCache?: TagsCache; private assignmentService?: TagAssignmentService; - private spaces?: SpacesApi; private readonly config: SavedObjectsTaggingClientConfig; constructor(context: PluginInitializerContext) { @@ -62,7 +56,6 @@ export class SavedObjectTaggingPlugin core, mountParams, title, - spaces: this.spaces, }); }, }); @@ -74,17 +67,13 @@ export class SavedObjectTaggingPlugin return {}; } - public start( - { http, application, overlays, theme, analytics, notifications }: CoreStart, - { spaces }: StartDeps - ) { + public start({ http, application, overlays, theme, analytics, notifications }: CoreStart) { this.tagCache = new TagsCache({ refreshHandler: () => this.tagClient!.getAll({ asSystemRequest: true }), refreshInterval: this.config.cacheRefreshInterval, }); this.tagClient = new TagsClient({ analytics, http, changeListener: this.tagCache }); this.assignmentService = new TagAssignmentService({ http }); - this.spaces = spaces; // do not fetch tags on anonymous page if (!http.anonymousPaths.isAnonymous(window.location.pathname)) { diff --git a/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts b/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts index e13976683bfc5..b2dca68d5cc95 100644 --- a/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts +++ b/x-pack/plugins/saved_objects_tagging/public/ui_api/index.ts @@ -6,7 +6,6 @@ */ import type { NotificationsStart, OverlayStart, ThemeServiceStart } from '@kbn/core/public'; -import { SpacesApi } from '@kbn/spaces-plugin/public'; import { SavedObjectsTaggingApiUi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { TagsCapabilities } from '../../common'; import { ITagsCache, ITagInternalClient } from '../services'; @@ -31,7 +30,6 @@ interface GetUiApiOptions { cache: ITagsCache; client: ITagInternalClient; notifications: NotificationsStart; - spaces?: SpacesApi; } export const getUiApi = ({ @@ -41,7 +39,6 @@ export const getUiApi = ({ overlays, theme, notifications, - spaces, }: GetUiApiOptions): SavedObjectsTaggingApiUi => { const components = getComponents({ cache, diff --git a/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts b/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts index 8011eb8320c81..7df3ff955ecc8 100644 --- a/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts +++ b/x-pack/plugins/saved_objects_tagging/server/services/tags/utils.ts @@ -10,7 +10,6 @@ import { Tag, TagSavedObject } from '../../../common/types'; export const savedObjectToTag = (savedObject: TagSavedObject): Tag => { return { id: savedObject.id, - namespaces: savedObject.namespaces, ...savedObject.attributes, }; }; diff --git a/x-pack/plugins/saved_objects_tagging/tsconfig.json b/x-pack/plugins/saved_objects_tagging/tsconfig.json index 8f99024ffb11e..1876578728d45 100644 --- a/x-pack/plugins/saved_objects_tagging/tsconfig.json +++ b/x-pack/plugins/saved_objects_tagging/tsconfig.json @@ -17,7 +17,6 @@ "@kbn/usage-collection-plugin", "@kbn/features-plugin", "@kbn/security-plugin", - "@kbn/spaces-plugin", "@kbn/i18n", "@kbn/utility-types", "@kbn/i18n-react",