diff --git a/src/plugins/workspace/public/workspace_client.test.ts b/src/plugins/workspace/public/workspace_client.test.ts index ef5ba154e94f..c18ed3db64e7 100644 --- a/src/plugins/workspace/public/workspace_client.test.ts +++ b/src/plugins/workspace/public/workspace_client.test.ts @@ -53,7 +53,7 @@ describe('#WorkspaceClient', () => { success: true, }); await workspaceClient.enterWorkspace('foo'); - expect(await workspaceClient.getCurrentWorkspaceId()).toEqual({ + expect(workspaceClient.getCurrentWorkspaceId()).toEqual({ success: true, result: 'foo', }); diff --git a/src/plugins/workspace/public/workspace_client.ts b/src/plugins/workspace/public/workspace_client.ts index 31a7545db023..3e988f38b265 100644 --- a/src/plugins/workspace/public/workspace_client.ts +++ b/src/plugins/workspace/public/workspace_client.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { i18n } from '@osd/i18n'; import { HttpFetchError, HttpFetchOptions, @@ -145,12 +146,14 @@ export class WorkspaceClient { /** * A bypass layer to get current workspace id */ - public async getCurrentWorkspaceId(): Promise> { + public getCurrentWorkspaceId(): IResponse { const currentWorkspaceId = this.workspaces.currentWorkspaceId$.getValue(); if (!currentWorkspaceId) { return { success: false, - error: 'You are not in any workspace yet.', + error: i18n.translate('workspace.error.notInWorkspace', { + defaultMessage: 'You are not in any workspace yet.', + }), }; } @@ -164,7 +167,7 @@ export class WorkspaceClient { * Do a find in the latest workspace list with current workspace id */ public async getCurrentWorkspace(): Promise> { - const currentWorkspaceIdResp = await this.getCurrentWorkspaceId(); + const currentWorkspaceIdResp = this.getCurrentWorkspaceId(); if (currentWorkspaceIdResp.success) { const currentWorkspaceResp = await this.get(currentWorkspaceIdResp.result); return currentWorkspaceResp;