From 645d6056f7f8869551f91d244c329b3b0cb7d4e5 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Tue, 5 Mar 2024 10:29:06 +0800 Subject: [PATCH] revert: saved object management changes Signed-off-by: SuZhou-Joe --- .../lib/fetch_export_by_type_and_search.ts | 4 +- .../public/lib/fetch_export_objects.test.ts | 34 -------- .../public/lib/fetch_export_objects.ts | 4 +- .../public/lib/get_saved_object_counts.ts | 1 - .../public/lib/import_file.test.ts | 46 ----------- .../public/lib/import_file.ts | 4 +- .../public/lib/resolve_import_errors.test.ts | 65 --------------- .../public/lib/resolve_import_errors.ts | 10 +-- .../saved_objects_table.test.tsx.snap | 3 - .../__snapshots__/flyout.test.tsx.snap | 1 - .../objects_table/components/flyout.test.tsx | 24 ------ .../objects_table/components/flyout.tsx | 15 +--- .../components/import_mode_control.tsx | 1 - .../saved_objects_table.test.tsx | 81 +------------------ .../objects_table/saved_objects_table.tsx | 60 ++------------ .../saved_objects_table_page.tsx | 1 - .../server/routes/find.ts | 4 - .../server/routes/scroll_count.ts | 7 -- src/plugins/workspace/server/plugin.test.ts | 29 ------- src/plugins/workspace/server/plugin.ts | 2 - 20 files changed, 21 insertions(+), 375 deletions(-) delete mode 100644 src/plugins/saved_objects_management/public/lib/fetch_export_objects.test.ts delete mode 100644 src/plugins/saved_objects_management/public/lib/import_file.test.ts delete mode 100644 src/plugins/workspace/server/plugin.test.ts diff --git a/src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts b/src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts index 1af8ac210696..e5f716347a76 100644 --- a/src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts +++ b/src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts @@ -34,12 +34,10 @@ export async function fetchExportByTypeAndSearch( http: HttpStart, types: string[], search: string | undefined, - includeReferencesDeep: boolean = false, - body?: Record + includeReferencesDeep: boolean = false ): Promise { return http.post('/api/saved_objects/_export', { body: JSON.stringify({ - ...body, type: types, search, includeReferencesDeep, diff --git a/src/plugins/saved_objects_management/public/lib/fetch_export_objects.test.ts b/src/plugins/saved_objects_management/public/lib/fetch_export_objects.test.ts deleted file mode 100644 index d37db062540c..000000000000 --- a/src/plugins/saved_objects_management/public/lib/fetch_export_objects.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { fetchExportObjects } from './fetch_export_objects'; -import { httpServiceMock } from '../../../../core/public/mocks'; - -describe('fetchExportObjects', () => { - it('make http call with body provided', async () => { - const httpClient = httpServiceMock.createStartContract(); - await fetchExportObjects(httpClient, [], false, { - workspaces: ['foo'], - }); - expect(httpClient.post).toMatchInlineSnapshot(` - [MockFunction] { - "calls": Array [ - Array [ - "/api/saved_objects/_export", - Object { - "body": "{\\"workspaces\\":[\\"foo\\"],\\"objects\\":[],\\"includeReferencesDeep\\":false}", - }, - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], - } - `); - }); -}); diff --git a/src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts b/src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts index 43afcfec3056..b2e2ea0f9165 100644 --- a/src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts +++ b/src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts @@ -33,12 +33,10 @@ import { HttpStart } from 'src/core/public'; export async function fetchExportObjects( http: HttpStart, objects: any[], - includeReferencesDeep: boolean = false, - body?: Record + includeReferencesDeep: boolean = false ): Promise { return http.post('/api/saved_objects/_export', { body: JSON.stringify({ - ...body, objects, includeReferencesDeep, }), diff --git a/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts b/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts index 9039dae2be53..6eaaac7d35f2 100644 --- a/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts +++ b/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts @@ -34,7 +34,6 @@ export interface SavedObjectCountOptions { typesToInclude: string[]; namespacesToInclude?: string[]; searchString?: string; - workspaces?: string[]; } export async function getSavedObjectCounts( diff --git a/src/plugins/saved_objects_management/public/lib/import_file.test.ts b/src/plugins/saved_objects_management/public/lib/import_file.test.ts deleted file mode 100644 index e17494ba2b20..000000000000 --- a/src/plugins/saved_objects_management/public/lib/import_file.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { importFile } from './import_file'; -import { httpServiceMock } from '../../../../core/public/mocks'; - -describe('importFile', () => { - it('make http call with body provided', async () => { - const httpClient = httpServiceMock.createStartContract(); - const blob = new Blob(['']); - await importFile(httpClient, new File([blob], 'foo.ndjson'), { - overwrite: true, - createNewCopies: false, - workspaces: ['foo'], - }); - expect(httpClient.post).toMatchInlineSnapshot(` - [MockFunction] { - "calls": Array [ - Array [ - "/api/saved_objects/_import", - Object { - "body": FormData {}, - "headers": Object { - "Content-Type": undefined, - }, - "query": Object { - "overwrite": true, - "workspaces": Array [ - "foo", - ], - }, - }, - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], - } - `); - }); -}); diff --git a/src/plugins/saved_objects_management/public/lib/import_file.ts b/src/plugins/saved_objects_management/public/lib/import_file.ts index bcf1b6911b0f..3753a8251e10 100644 --- a/src/plugins/saved_objects_management/public/lib/import_file.ts +++ b/src/plugins/saved_objects_management/public/lib/import_file.ts @@ -40,12 +40,12 @@ interface ImportResponse { export async function importFile( http: HttpStart, file: File, - { createNewCopies, overwrite, workspaces }: ImportMode, + { createNewCopies, overwrite }: ImportMode, selectedDataSourceId?: string ) { const formData = new FormData(); formData.append('file', file); - const query = createNewCopies ? { createNewCopies, workspaces } : { overwrite, workspaces }; + const query = createNewCopies ? { createNewCopies } : { overwrite }; if (selectedDataSourceId) { query.dataSourceId = selectedDataSourceId; } diff --git a/src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts index ee4a684d5702..428a1c56c50e 100644 --- a/src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts +++ b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts @@ -303,69 +303,4 @@ describe('resolveImportErrors', () => { } `); }); - - test('make http calls with workspaces', async () => { - httpMock.post.mockResolvedValueOnce({ - success: false, - successCount: 0, - errors: [{ type: 'a', id: '1', error: { type: 'conflict' } }], - }); - httpMock.post.mockResolvedValueOnce({ - success: true, - successCount: 1, - successResults: [{ type: 'a', id: '1' }], - }); - getConflictResolutions.mockResolvedValueOnce({}); - getConflictResolutions.mockResolvedValueOnce({ - 'a:1': { retry: true, options: { overwrite: true } }, - }); - await resolveImportErrors({ - http: httpMock, - getConflictResolutions, - state: { - importCount: 0, - unmatchedReferences: [{ existingIndexPatternId: '2', newIndexPatternId: '3', list: [] }], - failedImports: [ - { - obj: { type: 'a', id: '1', meta: {} }, - error: { type: 'missing_references', references: [{ type: 'index-pattern', id: '2' }] }, - }, - ], - importMode: { createNewCopies: false, overwrite: false }, - }, - workspaces: ['foo'], - }); - expect(httpMock.post.mock.calls).toMatchInlineSnapshot(` - Array [ - Array [ - "/api/saved_objects/_resolve_import_errors", - Object { - "body": FormData {}, - "headers": Object { - "Content-Type": undefined, - }, - "query": Object { - "workspaces": Array [ - "foo", - ], - }, - }, - ], - Array [ - "/api/saved_objects/_resolve_import_errors", - Object { - "body": FormData {}, - "headers": Object { - "Content-Type": undefined, - }, - "query": Object { - "workspaces": Array [ - "foo", - ], - }, - }, - ], - ] - `); - }); }); diff --git a/src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts index 2bcaf6e9f6cf..585102ee5b8e 100644 --- a/src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts +++ b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts @@ -90,13 +90,12 @@ async function callResolveImportErrorsApi( file: File, retries: any, createNewCopies: boolean, - selectedDataSourceId?: string, - workspaces?: string[] + selectedDataSourceId?: string ): Promise { const formData = new FormData(); formData.append('file', file); formData.append('retries', JSON.stringify(retries)); - const query = createNewCopies ? { createNewCopies, workspaces } : { workspaces }; + const query = createNewCopies ? { createNewCopies } : {}; if (selectedDataSourceId) { query.dataSourceId = selectedDataSourceId; } @@ -173,7 +172,6 @@ export async function resolveImportErrors({ getConflictResolutions, state, selectedDataSourceId, - workspaces, }: { http: HttpStart; getConflictResolutions: ( @@ -188,7 +186,6 @@ export async function resolveImportErrors({ importMode: { createNewCopies: boolean; overwrite: boolean }; }; selectedDataSourceId: string; - workspaces?: string[]; }) { const retryDecisionCache = new Map(); const replaceReferencesCache = new Map(); @@ -278,8 +275,7 @@ export async function resolveImportErrors({ file!, retries, createNewCopies, - selectedDataSourceId, - workspaces + selectedDataSourceId ); importCount = response.successCount; // reset the success count since we retry all successful results each time failedImports = []; 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 e872e970a7f6..d18762f4912f 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 @@ -231,9 +231,6 @@ exports[`SavedObjectsTable should render normally 1`] = ` "edit": false, "read": true, }, - "workspaces": Object { - "enabled": false, - }, }, "currentAppId$": Observable { "_isScalar": 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 43b9e123e304..e15e72d6a2cb 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 @@ -246,7 +246,6 @@ exports[`Flyout conflicts should allow conflict resolution 2`] = ` }, ], }, - "workspaces": undefined, }, ], ], diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx index e5c6732cb5f5..575741708f1e 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx @@ -184,29 +184,6 @@ describe('Flyout', () => { ); }); - it('should call importFile / resolveImportErrors with workspaces', async () => { - const component = shallowRender({ ...defaultProps, workspaces: ['foo'] }); - - // Ensure all promises resolve - await new Promise((resolve) => process.nextTick(resolve)); - // Ensure the state changes are reflected - component.update(); - - await component.instance().import(); - expect(importFileMock.mock.calls[0][2]).toMatchInlineSnapshot(` - Object { - "createNewCopies": true, - "overwrite": true, - "workspaces": Array [ - "foo", - ], - } - `); - - await component.instance().resolveImportErrors(); - expect(resolveImportErrorsMock.mock.calls[0][0].workspaces).toEqual(['foo']); - }); - describe('conflicts', () => { beforeEach(() => { importFileMock.mockImplementation(() => ({ @@ -229,7 +206,6 @@ describe('Flyout', () => { }, ], })); - resolveImportErrorsMock.mockClear(); resolveImportErrorsMock.mockImplementation(() => ({ status: 'success', importCount: 1, diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx index 245fec387a20..f170713e0238 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx @@ -97,7 +97,6 @@ export interface FlyoutProps { hideLocalCluster: boolean; savedObjects: SavedObjectsClientContract; notifications: NotificationsStart; - workspaces?: string[]; } export interface FlyoutState { @@ -190,21 +189,13 @@ export class Flyout extends Component { * Does the initial import of a file, resolveImportErrors then handles errors and retries */ import = async () => { - const { http, workspaces } = this.props; + const { http } = this.props; const { file, importMode, selectedDataSourceId } = this.state; this.setState({ status: 'loading', error: undefined }); // Import the file try { - const response = await importFile( - http, - file!, - { - ...importMode, - workspaces, - }, - selectedDataSourceId - ); + const response = await importFile(http, file!, importMode, selectedDataSourceId); this.setState(processImportResponse(response), () => { // Resolve import errors right away if there's no index patterns to match // This will ask about overwriting each object, etc @@ -260,7 +251,6 @@ export class Flyout extends Component { status: 'loading', loadingMessage: undefined, }); - const { workspaces } = this.props; try { const updatedState = await resolveImportErrors({ @@ -268,7 +258,6 @@ export class Flyout extends Component { state: this.state, getConflictResolutions: this.getConflictResolutions, selectedDataSourceId: this.state.selectedDataSourceId, - workspaces, }); this.setState(updatedState); } catch (e) { diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx index 49974c53b3d7..d0c800553996 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx @@ -52,7 +52,6 @@ export interface ImportModeControlProps { export interface ImportMode { createNewCopies: boolean; overwrite: boolean; - workspaces?: string[]; } const createNewCopiesDisabled = { diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx index a0a6329ac5e0..5a6bf0713d95 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx @@ -48,7 +48,6 @@ import { notificationServiceMock, savedObjectsServiceMock, applicationServiceMock, - workspacesServiceMock, } from '../../../../../core/public/mocks'; import { dataPluginMock } from '../../../../data/public/mocks'; import { serviceRegistryMock } from '../../services/service_registry.mock'; @@ -103,7 +102,6 @@ describe('SavedObjectsTable', () => { let notifications: ReturnType; let savedObjects: ReturnType; let search: ReturnType['search']; - let workspaces: ReturnType; const shallowRender = (overrides: Partial = {}) => { return (shallowWithI18nProvider( @@ -123,7 +121,6 @@ describe('SavedObjectsTable', () => { notifications = notificationServiceMock.createStartContract(); savedObjects = savedObjectsServiceMock.createStartContract(); search = dataPluginMock.createStartContract().search; - workspaces = workspacesServiceMock.createStartContract(); const applications = applicationServiceMock.createStartContract(); applications.capabilities = { @@ -135,9 +132,6 @@ describe('SavedObjectsTable', () => { edit: false, delete: false, }, - workspaces: { - enabled: false, - }, }; http.post.mockResolvedValue([]); @@ -160,7 +154,6 @@ describe('SavedObjectsTable', () => { savedObjectsClient: savedObjects.client, indexPatterns: dataPluginMock.createStartContract().indexPatterns, http, - workspaces, overlays, notifications, applications, @@ -286,7 +279,7 @@ describe('SavedObjectsTable', () => { await component.instance().onExport(true); - expect(fetchExportObjectsMock).toHaveBeenCalledWith(http, mockSelectedSavedObjects, true, {}); + expect(fetchExportObjectsMock).toHaveBeenCalledWith(http, mockSelectedSavedObjects, true); expect(notifications.toasts.addSuccess).toHaveBeenCalledWith({ title: 'Your file is downloading in the background', }); @@ -329,7 +322,7 @@ describe('SavedObjectsTable', () => { await component.instance().onExport(true); - expect(fetchExportObjectsMock).toHaveBeenCalledWith(http, mockSelectedSavedObjects, true, {}); + expect(fetchExportObjectsMock).toHaveBeenCalledWith(http, mockSelectedSavedObjects, true); expect(notifications.toasts.addWarning).toHaveBeenCalledWith({ title: 'Your file is downloading in the background. ' + @@ -370,8 +363,7 @@ describe('SavedObjectsTable', () => { http, allowedTypes, undefined, - true, - {} + true ); expect(saveAsMock).toHaveBeenCalledWith(blob, 'export.ndjson'); expect(notifications.toasts.addSuccess).toHaveBeenCalledWith({ @@ -401,78 +393,13 @@ describe('SavedObjectsTable', () => { http, allowedTypes, 'test*', - true, - {} + true ); expect(saveAsMock).toHaveBeenCalledWith(blob, 'export.ndjson'); expect(notifications.toasts.addSuccess).toHaveBeenCalledWith({ title: 'Your file is downloading in the background', }); }); - - it('should make modules call with workspace', async () => { - getSavedObjectCountsMock.mockClear(); - findObjectsMock.mockClear(); - // @ts-expect-error - defaultProps.applications.capabilities.workspaces.enabled = true; - const mockSelectedSavedObjects = [ - { id: '1', type: 'index-pattern' }, - { id: '3', type: 'dashboard' }, - ] as SavedObjectWithMetadata[]; - - const mockSavedObjects = mockSelectedSavedObjects.map((obj) => ({ - _id: obj.id, - _type: obj.type, - _source: {}, - })); - - const mockSavedObjectsClient = { - ...defaultProps.savedObjectsClient, - bulkGet: jest.fn().mockImplementation(() => ({ - savedObjects: mockSavedObjects, - })), - }; - - const workspacesStart = workspacesServiceMock.createStartContract(); - workspacesStart.currentWorkspaceId$.next('foo'); - - const component = shallowRender({ - savedObjectsClient: mockSavedObjectsClient, - workspaces: workspacesStart, - }); - - // Ensure all promises resolve - await new Promise((resolve) => process.nextTick(resolve)); - // Ensure the state changes are reflected - component.update(); - - // Set some as selected - component.instance().onSelectionChanged(mockSelectedSavedObjects); - - await component.instance().onExport(true); - await component.instance().onExportAll(); - - expect(fetchExportObjectsMock).toHaveBeenCalledWith(http, mockSelectedSavedObjects, true, { - workspaces: ['foo'], - }); - expect(fetchExportByTypeAndSearchMock).toHaveBeenCalledWith( - http, - ['index-pattern', 'visualization', 'dashboard', 'search'], - undefined, - true, - { - workspaces: ['foo'], - } - ); - expect( - getSavedObjectCountsMock.mock.calls.every((item) => item[1].workspaces[0] === 'foo') - ).toEqual(true); - expect(findObjectsMock.mock.calls.every((item) => item[1].workspaces[0] === 'foo')).toEqual( - true - ); - // @ts-expect-error - defaultProps.applications.capabilities.workspaces.enabled = false; - }); }); describe('import', () => { diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx index 8f45c5fe3946..955482cc0676 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx @@ -61,7 +61,6 @@ import { FormattedMessage } from '@osd/i18n/react'; import { SavedObjectsClientContract, SavedObjectsFindOptions, - WorkspacesStart, HttpStart, OverlayStart, NotificationsStart, @@ -107,7 +106,6 @@ export interface SavedObjectsTableProps { savedObjectsClient: SavedObjectsClientContract; indexPatterns: IndexPatternsContract; http: HttpStart; - workspaces: WorkspacesStart; search: DataPublicPluginStart['search']; overlays: OverlayStart; notifications: NotificationsStart; @@ -139,8 +137,6 @@ export interface SavedObjectsTableState { exportAllOptions: ExportAllOption[]; exportAllSelectedOptions: Record; isIncludeReferencesDeepChecked: boolean; - currentWorkspaceId: string | null; - workspaceEnabled: boolean; } export class SavedObjectsTable extends Component { @@ -171,35 +167,9 @@ export class SavedObjectsTable extends Component( - obj: T - ): T | Omit { - const { workspaces, ...others } = obj; - if (workspaces) { - return obj; - } - return others; - } - componentDidMount() { this._isMounted = true; this.fetchSavedObjects(); @@ -219,11 +189,10 @@ export class SavedObjectsTable extends Component ns.id) || []; - const filteredCountOptions: SavedObjectCountOptions = this.formatWorkspaceIdParams({ + const filteredCountOptions: SavedObjectCountOptions = { typesToInclude: filteredTypes, searchString: queryText, - workspaces: this.workspaceIdQuery, - }); + }; if (availableNamespaces.length) { const filteredNamespaces = filterQuery(availableNamespaces, visibleNamespaces); @@ -252,11 +221,10 @@ export class SavedObjectsTable extends Component ns.id) || []; if (availableNamespaces.length) { @@ -438,14 +405,7 @@ export class SavedObjectsTable extends Component().concat(req.query.workspaces) : undefined, }); const savedObjects = await Promise.all( diff --git a/src/plugins/saved_objects_management/server/routes/scroll_count.ts b/src/plugins/saved_objects_management/server/routes/scroll_count.ts index 221d39392842..63233748a896 100644 --- a/src/plugins/saved_objects_management/server/routes/scroll_count.ts +++ b/src/plugins/saved_objects_management/server/routes/scroll_count.ts @@ -41,7 +41,6 @@ export const registerScrollForCountRoute = (router: IRouter) => { typesToInclude: schema.arrayOf(schema.string()), namespacesToInclude: schema.maybe(schema.arrayOf(schema.string())), searchString: schema.maybe(schema.string()), - workspaces: schema.maybe(schema.arrayOf(schema.string())), }), }, }, @@ -56,8 +55,6 @@ export const registerScrollForCountRoute = (router: IRouter) => { perPage: 1000, }; - const requestHasWorkspaces = Array.isArray(req.body.workspaces) && req.body.workspaces.length; - const requestHasNamespaces = Array.isArray(req.body.namespacesToInclude) && req.body.namespacesToInclude.length; @@ -66,10 +63,6 @@ export const registerScrollForCountRoute = (router: IRouter) => { findOptions.namespaces = req.body.namespacesToInclude; } - if (requestHasWorkspaces) { - findOptions.workspaces = req.body.workspaces; - } - if (req.body.searchString) { findOptions.search = `${req.body.searchString}*`; findOptions.searchFields = ['title']; diff --git a/src/plugins/workspace/server/plugin.test.ts b/src/plugins/workspace/server/plugin.test.ts deleted file mode 100644 index 32b4b23a9f59..000000000000 --- a/src/plugins/workspace/server/plugin.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { coreMock } from '../../../core/server/mocks'; -import { WorkspacePlugin } from './plugin'; - -describe('Workspace server plugin', () => { - it('#setup', async () => { - let value; - const setupMock = coreMock.createSetup(); - const initializerContextConfigMock = coreMock.createPluginInitializerContext({ - workspace: { - enabled: true, - }, - }); - setupMock.capabilities.registerProvider.mockImplementationOnce((fn) => (value = fn())); - const workspacePlugin = new WorkspacePlugin(initializerContextConfigMock); - await workspacePlugin.setup(setupMock); - expect(value).toMatchInlineSnapshot(` - Object { - "workspaces": Object { - "enabled": true, - }, - } - `); - }); -}); diff --git a/src/plugins/workspace/server/plugin.ts b/src/plugins/workspace/server/plugin.ts index a09e4468a120..e4ed75bad615 100644 --- a/src/plugins/workspace/server/plugin.ts +++ b/src/plugins/workspace/server/plugin.ts @@ -46,8 +46,6 @@ export class WorkspacePlugin implements Plugin<{}, {}> { client: this.client as IWorkspaceClientImpl, }); - core.capabilities.registerProvider(() => ({ workspaces: { enabled: true } })); - return { client: this.client, };