Skip to content

Commit

Permalink
fix tests and add comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <[email protected]>
  • Loading branch information
ruanyl committed Oct 10, 2023
1 parent a0f45da commit 3400f81
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const createStartContractMock = (): jest.Mocked<CapabilitiesStart> => ({
catalogue: {},
management: {},
navLinks: {},
workspaces: {},
}),
});

Expand Down
7 changes: 1 addition & 6 deletions src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,4 @@ export {

export { __osdBootstrap__ } from './osd_bootstrap';

export {
WorkspacesStart,
WorkspacesSetup,
WorkspacesService,
WorkspaceObservables,
} from './workspace';
export { WorkspacesStart, WorkspacesSetup, WorkspacesService } from './workspace';
8 changes: 2 additions & 6 deletions src/core/public/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
export {
WorkspacesStart,
WorkspacesService,
WorkspacesSetup,
WorkspaceObservables,
} from './workspaces_service';

export { WorkspacesStart, WorkspacesService, WorkspacesSetup } from './workspaces_service';
23 changes: 22 additions & 1 deletion src/core/public/workspace/workspaces_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,31 @@ import { CoreService, WorkspaceAttribute } from '../../types';

type WorkspaceObject = WorkspaceAttribute & { readonly?: boolean };

export interface WorkspaceObservables {
interface WorkspaceObservables {
/**
* Indicates the current activated workspace id, the value should be changed every time
* when switching to a different workspace
*/
currentWorkspaceId$: BehaviorSubject<string>;

/**
* The workspace that is derived from `currentWorkspaceId` and `workspaceList`, if
* `currentWorkspaceId` cannot be found from `workspaceList`, it will return an error
*
* This value MUST NOT set manually from outside of WorkspacesService
*/
currentWorkspace$: BehaviorSubject<WorkspaceObject | null>;

/**
* The list of available workspaces. This workspace list should be set by whoever
* the workspace functionalities
*/
workspaceList$: BehaviorSubject<WorkspaceObject[]>;

/**
* This is a flag which indicates the WorkspacesService module is initialized and ready
* for consuming by others. For example, the `workspaceList` has been set, etc
*/
initialized$: BehaviorSubject<boolean>;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/server/capabilities/capabilities_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const createCapabilitiesMock = (): Capabilities => {
navLinks: {},
management: {},
catalogue: {},
workspaces: {},
};
};

Expand Down
1 change: 1 addition & 0 deletions src/core/server/capabilities/capabilities_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const defaultCapabilities: Capabilities = {
navLinks: {},
management: {},
catalogue: {},
workspaces: {},
};

/** @internal */
Expand Down
1 change: 1 addition & 0 deletions src/core/server/capabilities/resolve_capabilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('resolveCapabilities', () => {
navLinks: {},
catalogue: {},
management: {},
workspaces: {},
};
request = httpServerMock.createOpenSearchDashboardsRequest();
});
Expand Down

0 comments on commit 3400f81

Please sign in to comment.