diff --git a/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap b/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap index d6094f78e24b..62f00bee2c74 100644 --- a/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap +++ b/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap @@ -60,7 +60,6 @@ exports[`CollapsibleNav renders links grouped by category 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={Object {}} @@ -2014,7 +2013,6 @@ exports[`CollapsibleNav renders the default nav 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={Object {}} @@ -2319,7 +2317,6 @@ exports[`CollapsibleNav renders the default nav 2`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={Object {}} @@ -2625,7 +2622,6 @@ exports[`CollapsibleNav renders the default nav 3`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={Object {}} @@ -3222,7 +3218,6 @@ exports[`CollapsibleNav with custom branding renders the nav bar in dark mode 1` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={ @@ -4340,7 +4335,6 @@ exports[`CollapsibleNav with custom branding renders the nav bar in default mode "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={ @@ -5457,7 +5451,6 @@ exports[`CollapsibleNav without custom branding renders the nav bar in dark mode "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={ @@ -6567,7 +6560,6 @@ exports[`CollapsibleNav without custom branding renders the nav bar in default m "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={Object {}} diff --git a/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap b/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap index 3d3e5a440c27..790f24bc20e9 100644 --- a/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap +++ b/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap @@ -248,7 +248,6 @@ exports[`Header handles visibility and lock changes 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={Object {}} @@ -5954,7 +5953,6 @@ exports[`Header handles visibility and lock changes 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } closeNav={[Function]} @@ -7018,7 +7016,6 @@ exports[`Header renders condensed header 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } branding={ @@ -11495,7 +11492,6 @@ exports[`Header renders condensed header 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "/test", - "workspaceBasePath": "", } } closeNav={[Function]} diff --git a/src/core/server/saved_objects/routes/resolve_import_errors.ts b/src/core/server/saved_objects/routes/resolve_import_errors.ts index 7d22e35a658d..5d2be7fdfddf 100644 --- a/src/core/server/saved_objects/routes/resolve_import_errors.ts +++ b/src/core/server/saved_objects/routes/resolve_import_errors.ts @@ -132,7 +132,6 @@ export const registerResolveImportErrorsRoute = (router: IRouter, config: SavedO retries: req.body.retries, objectLimit: maxImportExportSize, createNewCopies: req.query.createNewCopies, - workspaces, dataSourceId, dataSourceTitle, workspaces, diff --git a/src/core/server/saved_objects/service/lib/repository.test.js b/src/core/server/saved_objects/service/lib/repository.test.js index 3dfa293c0dc0..68942c0e435f 100644 --- a/src/core/server/saved_objects/service/lib/repository.test.js +++ b/src/core/server/saved_objects/service/lib/repository.test.js @@ -187,7 +187,6 @@ describe('SavedObjectsRepository', () => { _source: { ...(registry.isSingleNamespace(type) && { namespace: namespaceId }), ...(registry.isMultiNamespace(type) && { namespaces: [namespaceId ?? 'default'] }), - workspaces, ...(originId && { originId }), ...(permissions && { permissions }), type, @@ -460,14 +459,6 @@ describe('SavedObjectsRepository', () => { }, }; const workspace = 'foo-workspace'; - const permissions = { - read: { - users: ['user1'], - }, - write: { - groups: ['groups1'], - }, - }; const getMockBulkCreateResponse = (objects, namespace) => { return { @@ -761,18 +752,6 @@ describe('SavedObjectsRepository', () => { expectClientCallArgsAction(objects, { method: 'create', getId }); }); - it(`accepts permissions property when providing permissions info`, async () => { - const objects = [obj1, obj2].map((obj) => ({ ...obj, permissions: permissions })); - await bulkCreateSuccess(objects); - const expected = expect.objectContaining({ permissions }); - const body = [expect.any(Object), expected, expect.any(Object), expected]; - expect(client.bulk).toHaveBeenCalledWith( - expect.objectContaining({ body }), - expect.anything() - ); - client.bulk.mockClear(); - }); - it(`adds workspaces to request body for any types`, async () => { await bulkCreateSuccess([obj1, obj2], { workspaces: [workspace] }); const expected = expect.objectContaining({ workspaces: [workspace] }); @@ -1965,9 +1944,6 @@ describe('SavedObjectsRepository', () => { ...omitWorkspace(obj9), error: { ...createConflictError(obj9.type, obj9.id), - metadata: { - isNotOverwritable: true, - }, }, }, ], diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index 61da059f7839..1b07e751220b 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -598,24 +598,13 @@ export class SavedObjectsRepository { const { type, id, opensearchRequestIndex } = expectedResult.value; const doc = bulkGetResponse?.body.docs[opensearchRequestIndex]; if (doc?.found) { - let workspaceConflict = false; - if (options.workspaces) { - const transformedObject = this._serializer.rawToSavedObject(doc as SavedObjectsRawDoc); - const filteredWorkspaces = SavedObjectsUtils.filterWorkspacesAccordingToBaseWorkspaces( - options.workspaces, - transformedObject.workspaces - ); - if (filteredWorkspaces.length) { - workspaceConflict = true; - } - } errors.push({ id, type, error: { ...errorContent(SavedObjectsErrorHelpers.createConflictError(type, id)), // @ts-expect-error MultiGetHit._source is optional - ...((!this.rawDocExistsInNamespace(doc!, namespace) || workspaceConflict) && { + ...(!this.rawDocExistsInNamespace(doc!, namespace) && { metadata: { isNotOverwritable: true }, }), }, diff --git a/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts b/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts index b8fd28fe46c2..abbef0850dba 100644 --- a/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts +++ b/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts @@ -151,27 +151,6 @@ function getClauseForWorkspace(workspace: string) { }; } -/** - * Gets the clause that will filter for the workspace. - */ -function getClauseForWorkspace(workspace: string) { - if (workspace === '*') { - return { - bool: { - must: { - match_all: {}, - }, - }, - }; - } - - return { - bool: { - must: [{ term: { workspaces: workspace } }], - }, - }; -} - interface HasReferenceQueryParams { type: string; id: string; diff --git a/src/plugins/dashboard/public/application/components/dashboard_listing/__snapshots__/dashboard_listing.test.tsx.snap b/src/plugins/dashboard/public/application/components/dashboard_listing/__snapshots__/dashboard_listing.test.tsx.snap index 1bff186d2634..f1635f41c318 100644 --- a/src/plugins/dashboard/public/application/components/dashboard_listing/__snapshots__/dashboard_listing.test.tsx.snap +++ b/src/plugins/dashboard/public/application/components/dashboard_listing/__snapshots__/dashboard_listing.test.tsx.snap @@ -863,7 +863,6 @@ exports[`dashboard listing hideWriteControls 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -2007,7 +2006,6 @@ exports[`dashboard listing render table listing with initial filters from URL 1` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -3212,7 +3210,6 @@ exports[`dashboard listing renders call to action when no dashboards exist 1`] = "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -4417,7 +4414,6 @@ exports[`dashboard listing renders table rows 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -5622,7 +5618,6 @@ exports[`dashboard listing renders warning when listingLimit is exceeded 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], diff --git a/src/plugins/dashboard/public/application/components/dashboard_top_nav/__snapshots__/dashboard_top_nav.test.tsx.snap b/src/plugins/dashboard/public/application/components/dashboard_top_nav/__snapshots__/dashboard_top_nav.test.tsx.snap index f8b202372235..314d9e449c40 100644 --- a/src/plugins/dashboard/public/application/components/dashboard_top_nav/__snapshots__/dashboard_top_nav.test.tsx.snap +++ b/src/plugins/dashboard/public/application/components/dashboard_top_nav/__snapshots__/dashboard_top_nav.test.tsx.snap @@ -755,7 +755,6 @@ exports[`Dashboard top nav render in embed mode 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -1724,7 +1723,6 @@ exports[`Dashboard top nav render in embed mode, and force hide filter bar 1`] = "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -2693,7 +2691,6 @@ exports[`Dashboard top nav render in embed mode, components can be forced show b "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -3662,7 +3659,6 @@ exports[`Dashboard top nav render in full screen mode with appended URL param bu "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -4631,7 +4627,6 @@ exports[`Dashboard top nav render in full screen mode, no componenets should be "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -5600,7 +5595,6 @@ exports[`Dashboard top nav render with all components 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], diff --git a/src/plugins/dashboard/public/application/embeddable/empty/__snapshots__/dashboard_empty_screen.test.tsx.snap b/src/plugins/dashboard/public/application/embeddable/empty/__snapshots__/dashboard_empty_screen.test.tsx.snap index 8c8043ae7a99..c2c83ff6f356 100644 --- a/src/plugins/dashboard/public/application/embeddable/empty/__snapshots__/dashboard_empty_screen.test.tsx.snap +++ b/src/plugins/dashboard/public/application/embeddable/empty/__snapshots__/dashboard_empty_screen.test.tsx.snap @@ -17,7 +17,6 @@ exports[`DashboardEmptyScreen renders correctly with readonly mode 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -387,7 +386,6 @@ exports[`DashboardEmptyScreen renders correctly with visualize paragraph 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], @@ -767,7 +765,6 @@ exports[`DashboardEmptyScreen renders correctly without visualize paragraph 1`] "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap index 2be5b7c11b8a..2c789f04da12 100644 --- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap @@ -1,5 +1,59 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`DataSourceAggregatedView should render normally with data source filter 1`] = ` + + + Data sources + + + All + + + } + closePopover={[Function]} + display="inlineBlock" + hasArrow={true} + id="dataSourceSViewContextMenuPopover" + isOpen={false} + ownFocus={true} + panelPaddingSize="none" + > + + + +`; + exports[`DataSourceAggregatedView should render normally with local cluster and actice selections 1`] = ` `; -exports[`DataSourceAggregatedView should render normally with local cluster and actice selections 2`] = ` +exports[`DataSourceAggregatedView should render normally with local cluster hidden and all options 1`] = ` + + +`; + +exports[`DataSourceAggregatedView should render normally with local cluster not hidden and all options 1`] = ` + + + Data sources + + + All + + + } + closePopover={[Function]} + display="inlineBlock" + hasArrow={true} + id="dataSourceSViewContextMenuPopover" + isOpen={false} + ownFocus={true} + panelPaddingSize="none" + > + `; -exports[`DataSourceAggregatedView should render normally with local cluster and actice selections 3`] = ` +exports[`DataSourceAggregatedView should render popup when clicking on info icon 1`] = ` Object { "asFragment": [Function], "baseElement": @@ -339,111 +447,3 @@ Object { "unmount": [Function], } `; - -exports[`DataSourceAggregatedView should render normally with local cluster hidden and all options 1`] = ` - - - Data sources - - - All - - - } - closePopover={[Function]} - display="inlineBlock" - hasArrow={true} - id="dataSourceSViewContextMenuPopover" - isOpen={false} - ownFocus={true} - panelPaddingSize="none" - > - - - -`; - -exports[`DataSourceAggregatedView should render normally with local cluster not hidden and all options 1`] = ` - - - Data sources - - - All - - - } - closePopover={[Function]} - display="inlineBlock" - hasArrow={true} - id="dataSourceSViewContextMenuPopover" - isOpen={false} - ownFocus={true} - panelPaddingSize="none" - > - - - -`; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap index ab8a16be5cbe..f527bb7984c9 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap @@ -270,7 +270,6 @@ exports[`SavedObjectsTable should render normally 1`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", } } canDelete={false} diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap index fc58df41524a..45036362e649 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap @@ -174,7 +174,6 @@ exports[`Flyout conflicts should allow conflict resolution 2`] = ` "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], diff --git a/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap b/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap index 7ad1fb8cd938..2761ce16fea3 100644 --- a/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap +++ b/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap @@ -319,7 +319,6 @@ exports[`TelemetryManagementSectionComponent renders null because allowChangingO "prepend": [Function], "remove": [Function], "serverBasePath": "", - "workspaceBasePath": "", }, "delete": [MockFunction], "fetch": [MockFunction], diff --git a/src/plugins/workspace/public/plugin.test.ts b/src/plugins/workspace/public/plugin.test.ts index 5ecdc219fe96..41f79c5b194e 100644 --- a/src/plugins/workspace/public/plugin.test.ts +++ b/src/plugins/workspace/public/plugin.test.ts @@ -36,9 +36,8 @@ describe('Workspace plugin', () => { coreStart.workspaces.currentWorkspaceId$.next('foo'); expect(coreStart.savedObjects.client.setCurrentWorkspace).toHaveBeenCalledWith('foo'); }); - }); - it('#setup when workspace id is in url and enterWorkspace return error', async () => { + it('#setup when workspace id is in url and enterWorkspace return success', async () => { const windowSpy = jest.spyOn(window, 'window', 'get'); windowSpy.mockImplementation( () => @@ -49,17 +48,21 @@ describe('Workspace plugin', () => { } as any) ); workspaceClientMock.enterWorkspace.mockResolvedValue({ - success: false, + success: true, error: 'error', }); const setupMock = coreMock.createSetup(); const applicationStartMock = applicationServiceMock.createStartContract(); - const chromeStartMock = chromeServiceMock.createStartContract(); + let currentAppIdSubscriber: Subscriber | undefined; setupMock.getStartServices.mockImplementation(() => { return Promise.resolve([ { - application: applicationStartMock, - chrome: chromeStartMock, + application: { + ...applicationStartMock, + currentAppId$: new Observable((subscriber) => { + currentAppIdSubscriber = subscriber; + }), + }, }, {}, {}, @@ -70,27 +73,12 @@ describe('Workspace plugin', () => { await workspacePlugin.setup(setupMock, { savedObjectsManagement: savedObjectsManagementPluginMock.createSetupContract(), }); - expect(setupMock.application.register).toBeCalledTimes(3); - expect(WorkspaceClientMock).toBeCalledTimes(1); - expect(workspaceClientMock.enterWorkspace).toBeCalledWith('workspaceId'); - expect(setupMock.getStartServices).toBeCalledTimes(1); - await waitFor( - () => { - expect(applicationStartMock.navigateToApp).toBeCalledWith(WORKSPACE_FATAL_ERROR_APP_ID, { - replace: true, - state: { - error: 'error', - }, - }); - }, - { - container: document.body, - } - ); + currentAppIdSubscriber?.next(WORKSPACE_FATAL_ERROR_APP_ID); + expect(applicationStartMock.navigateToApp).toBeCalledWith(WORKSPACE_OVERVIEW_APP_ID); windowSpy.mockRestore(); }); - it('#setup when workspace id is in url and enterWorkspace return success', async () => { + it('#setup when workspace id is in url and enterWorkspace return error', async () => { const windowSpy = jest.spyOn(window, 'window', 'get'); windowSpy.mockImplementation( () => @@ -101,21 +89,17 @@ describe('Workspace plugin', () => { } as any) ); workspaceClientMock.enterWorkspace.mockResolvedValue({ - success: true, + success: false, error: 'error', }); const setupMock = coreMock.createSetup(); const applicationStartMock = applicationServiceMock.createStartContract(); - let currentAppIdSubscriber: Subscriber | undefined; + const chromeStartMock = chromeServiceMock.createStartContract(); setupMock.getStartServices.mockImplementation(() => { return Promise.resolve([ { - application: { - ...applicationStartMock, - currentAppId$: new Observable((subscriber) => { - currentAppIdSubscriber = subscriber; - }), - }, + application: applicationStartMock, + chrome: chromeStartMock, }, {}, {}, @@ -126,19 +110,26 @@ describe('Workspace plugin', () => { await workspacePlugin.setup(setupMock, { savedObjectsManagement: savedObjectsManagementPluginMock.createSetupContract(), }); - currentAppIdSubscriber?.next(WORKSPACE_FATAL_ERROR_APP_ID); - expect(applicationStartMock.navigateToApp).toBeCalledWith(WORKSPACE_OVERVIEW_APP_ID); + expect(setupMock.application.register).toBeCalledTimes(3); + expect(WorkspaceClientMock).toBeCalledTimes(1); + expect(workspaceClientMock.enterWorkspace).toBeCalledWith('workspaceId'); + expect(setupMock.getStartServices).toBeCalledTimes(1); + await waitFor( + () => { + expect(applicationStartMock.navigateToApp).toBeCalledWith(WORKSPACE_FATAL_ERROR_APP_ID, { + replace: true, + state: { + error: 'error', + }, + }); + }, + { + container: document.body, + } + ); windowSpy.mockRestore(); }); - it('#call savedObjectsClient.setCurrentWorkspace when current workspace id changed', () => { - const workspacePlugin = new WorkspacePlugin(); - const coreStart = coreMock.createStart(); - workspacePlugin.start(coreStart); - coreStart.workspaces.currentWorkspaceId$.next('foo'); - expect(coreStart.savedObjects.client.setCurrentWorkspace).toHaveBeenCalledWith('foo'); - }); - it('#setup register workspace dropdown menu when setup', async () => { const setupMock = coreMock.createSetup(); const workspacePlugin = new WorkspacePlugin(); diff --git a/src/plugins/workspace/public/plugin.ts b/src/plugins/workspace/public/plugin.ts index 24fb61741cc7..1874f1fe2d8b 100644 --- a/src/plugins/workspace/public/plugin.ts +++ b/src/plugins/workspace/public/plugin.ts @@ -35,6 +35,8 @@ interface WorkspacePluginSetupDeps { savedObjectsManagement?: SavedObjectsManagementPluginSetup; } +console.log('run'); + export class WorkspacePlugin implements Plugin<{}, {}, {}> { private coreStart?: CoreStart; private currentWorkspaceIdSubscription?: Subscription;