Skip to content

Commit

Permalink
[Bug][Workspace]fix: revert new home page ui setting for workspace de…
Browse files Browse the repository at this point in the history
…fault route (opensearch-project#7858)

* revert new home page ui setting for workspace default route

Signed-off-by: yubonluo <yubonluo@amazon.com>

* Changeset file for PR opensearch-project#7858 created/updated

---------

Signed-off-by: yubonluo <yubonluo@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
yubonluo and opensearch-changeset-bot[bot] authored Aug 29, 2024
1 parent 07504f6 commit a0365d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 51 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7858.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace] Revert new home page ui setting for workspace default route ([#7858](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7858))
42 changes: 0 additions & 42 deletions src/plugins/workspace/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,6 @@ describe('Workspace server plugin', () => {
describe('#setUpRedirectPage', () => {
const setupMock = coreMock.createSetup();
const uiSettingsMock = uiSettingsServiceMock.createClient();
setupMock.getStartServices.mockResolvedValue([
{
...coreMock.createStart(),
uiSettings: {
asScopedToClient: () => ({
...uiSettingsMock,
get: jest.fn().mockImplementation((key) => {
if (key === 'home:useNewHomePage') {
return Promise.resolve(true);
}
}),
}),
},
},
{},
{},
]);
const initializerContextConfigMock = coreMock.createPluginInitializerContext({
enabled: true,
permission: {
Expand Down Expand Up @@ -304,8 +287,6 @@ describe('Workspace server plugin', () => {
get: jest.fn().mockImplementation((key) => {
if (key === 'defaultWorkspace') {
return Promise.resolve('defaultWorkspace');
} else if (key === 'home:useNewHomePage') {
return Promise.resolve('true');
}
}),
}),
Expand Down Expand Up @@ -337,29 +318,6 @@ describe('Workspace server plugin', () => {
},
});
});

it('with / request path and home:useNewHomePage is false', async () => {
const request = httpServerMock.createOpenSearchDashboardsRequest({
path: '/',
});
setupMock.getStartServices.mockResolvedValue([
{
...coreMock.createStart(),
uiSettings: {
asScopedToClient: () => ({
...uiSettingsMock,
get: jest.fn().mockResolvedValue(false),
}),
},
},
{},
{},
]);
const toolKitMock = httpServerMock.createToolkit();

await registerOnPostAuthFn(request, response, toolKitMock);
expect(toolKitMock.next).toBeCalledTimes(1);
});
});

it('#start', async () => {
Expand Down
13 changes: 4 additions & 9 deletions src/plugins/workspace/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ export class WorkspacePlugin implements Plugin<WorkspacePluginSetup, WorkspacePl
core.http.registerOnPostAuth(async (request, response, toolkit) => {
const path = request.url.pathname;
if (path === '/') {
const [coreStart] = await core.getStartServices();
const uiSettings = coreStart.uiSettings.asScopedToClient(
coreStart.savedObjects.getScopedClient(request)
);
const useNewHomePage = await uiSettings.get('home:useNewHomePage');
if (!useNewHomePage) {
return toolkit.next();
}

const workspaceListResponse = await this.client?.list(
{ request, logger: this.logger },
{ page: 1, perPage: 100 }
Expand All @@ -139,6 +130,10 @@ export class WorkspacePlugin implements Plugin<WorkspacePluginSetup, WorkspacePl
},
});
}
const [coreStart] = await core.getStartServices();
const uiSettings = coreStart.uiSettings.asScopedToClient(
coreStart.savedObjects.getScopedClient(request)
);
// Temporarily use defaultWorkspace as a placeholder
const defaultWorkspaceId = await uiSettings.get('defaultWorkspace');
const defaultWorkspace = workspaceList.find(
Expand Down

0 comments on commit a0365d8

Please sign in to comment.