diff --git a/src/core/public/saved_objects/saved_objects_client.ts b/src/core/public/saved_objects/saved_objects_client.ts index 2ddc776ffdf1..6c68d314acd7 100644 --- a/src/core/public/saved_objects/saved_objects_client.ts +++ b/src/core/public/saved_objects/saved_objects_client.ts @@ -42,6 +42,7 @@ import { import { SimpleSavedObject } from './simple_saved_object'; import { HttpFetchOptions, HttpSetup } from '../http'; +import { PUBLIC_WORKSPACE } from '../../utils'; type SavedObjectsFindOptions = Omit< SavedObjectFindOptionsServer, @@ -367,7 +368,7 @@ export class SavedObjectsClient { const workspaces = [ ...(options.workspaces || [await this._getCurrentWorkspace()]), - 'public', + PUBLIC_WORKSPACE, ].filter((item) => item); const renamedQuery = renameKeys(renameMap, { diff --git a/src/core/public/utils/index.ts b/src/core/public/utils/index.ts index ad363c53bd42..a6d76a87e313 100644 --- a/src/core/public/utils/index.ts +++ b/src/core/public/utils/index.ts @@ -32,4 +32,4 @@ export { shareWeakReplay } from './share_weak_replay'; export { Sha256 } from './crypto'; export { MountWrapper, mountReactNode } from './mount'; export { getWorkspaceIdFromUrl, WORKSPACE_TYPE } from './workspace'; -export { WORKSPACE_PATH_PREFIX } from '../../utils'; +export { WORKSPACE_PATH_PREFIX, PUBLIC_WORKSPACE } from '../../utils'; 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 5a2aae5943a6..c964e3f48dca 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 @@ -34,6 +34,7 @@ type KueryNode = any; import { ISavedObjectTypeRegistry } from '../../../saved_objects_type_registry'; import { ALL_NAMESPACES_STRING, DEFAULT_NAMESPACE_STRING } from '../utils'; +import { PUBLIC_WORKSPACE } from '../../../../../utils'; /** * Gets the types based on the type. Uses mappings to support @@ -142,7 +143,7 @@ function getClauseForWorkspace(workspace: string) { }; } - if (workspace === 'public') { + if (workspace === PUBLIC_WORKSPACE) { return { bool: { must_not: [{ exists: { field: 'workspaces' } }], diff --git a/src/core/server/workspaces/saved_objects/workspace_saved_objects_client_wrapper.ts b/src/core/server/workspaces/saved_objects/workspace_saved_objects_client_wrapper.ts index 0e4452dc23e3..233a03127a19 100644 --- a/src/core/server/workspaces/saved_objects/workspace_saved_objects_client_wrapper.ts +++ b/src/core/server/workspaces/saved_objects/workspace_saved_objects_client_wrapper.ts @@ -20,7 +20,7 @@ import { } from 'opensearch-dashboards/server'; import { SavedObjectsPermissionControlContract } from '../../saved_objects/permission_control/client'; import { WORKSPACE_TYPE } from '../constants'; -import { PermissionMode } from '../../../utils'; +import { PUBLIC_WORKSPACE, PermissionMode } from '../../../utils'; // Can't throw unauthorized for now, the page will be refreshed if unauthorized const generateWorkspacePermissionError = () => @@ -186,7 +186,7 @@ export class WorkspaceSavedObjectsClientWrapper { ); } else { options.workspaces = [ - 'public', + PUBLIC_WORKSPACE, ...(await this.permissionControl.getPermittedWorkspaceIds(wrapperOptions.request, [ PermissionMode.Read, ])), diff --git a/src/core/utils/constants.ts b/src/core/utils/constants.ts index 5bd25db2c848..efd7a31166ee 100644 --- a/src/core/utils/constants.ts +++ b/src/core/utils/constants.ts @@ -12,3 +12,5 @@ export enum PermissionMode { LibraryRead = 'library_read', LibraryWrite = 'library_write', } + +export const PUBLIC_WORKSPACE = 'public'; diff --git a/src/core/utils/index.ts b/src/core/utils/index.ts index 174152ffd750..ff36fef82ce9 100644 --- a/src/core/utils/index.ts +++ b/src/core/utils/index.ts @@ -38,4 +38,4 @@ export { } from './context'; export { DEFAULT_APP_CATEGORIES } from './default_app_categories'; export { DEFAULT_WORKSPACE_TEMPLATES } from './default_workspace_templates'; -export { WORKSPACE_PATH_PREFIX, PermissionMode } from './constants'; +export { WORKSPACE_PATH_PREFIX, PermissionMode, PUBLIC_WORKSPACE } from './constants'; 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 ca0aad55a0cb..7814ffb9090e 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 @@ -94,6 +94,7 @@ import { import { Header, Table, Flyout, Relationships } from './components'; import { DataPublicPluginStart } from '../../../../../plugins/data/public'; import { SavedObjectsCopyModal } from './components/copy_modal'; +import { PUBLIC_WORKSPACE } from '../../../../../core/public/utils'; interface ExportAllOption { id: string; @@ -179,7 +180,7 @@ export class SavedObjectsTable extends Component{publicWsName}; }