Skip to content

Commit

Permalink
feat: add config for topRightNavigation
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed May 3, 2024
1 parent b5121d3 commit 53a67c8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/core/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function pluginInitializerContextConfigMock<T>(config: T) {
configIndex: '.opensearch_dashboards_config_tests',
autocompleteTerminateAfter: duration(100000),
autocompleteTimeout: duration(1000),
topRightNavigation: false,
},
opensearch: {
shardTimeout: duration('30s'),
Expand Down
1 change: 1 addition & 0 deletions src/core/server/opensearch_dashboards_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const config = {
defaultValue: 'https://survey.opensearch.org',
}),
}),
topRightNavigation: schema.boolean({ defaultValue: false }),
}),
deprecations,
};
1 change: 1 addition & 0 deletions src/core/server/plugins/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export const SharedGlobalConfigKeys = {
'configIndex',
'autocompleteTerminateAfter',
'autocompleteTimeout',
'topRightNavigation',
] as const,
opensearch: ['shardTimeout', 'requestTimeout', 'pingTimeout'] as const,
path: ['data'] as const,
Expand Down
1 change: 1 addition & 0 deletions src/legacy/server/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export default () =>
survey: Joi.object({
url: Joi.any().default('/'),
}),
topRightNavigation: Joi.boolean().default(true),
}).default(),

savedObjects: HANDLED_IN_NEW_PLATFORM,
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/console/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ export class ConsoleServerPlugin implements Plugin<ConsoleSetup, ConsoleStart> {
}

async setup({ http, capabilities, opensearch, security }: CoreSetup) {
const config = await this.ctx.config.create().pipe(first()).toPromise();
const globalConfig = await this.ctx.config.legacy.globalConfig$.pipe(first()).toPromise();
const proxyPathFilters = config.proxyFilter.map((str: string) => new RegExp(str));

capabilities.registerProvider(() => ({
dev_tools: {
show: true,
save: true,
topRightNavigation: globalConfig.opensearchDashboards.topRightNavigation,
},
}));

Expand All @@ -66,10 +71,6 @@ export class ConsoleServerPlugin implements Plugin<ConsoleSetup, ConsoleStart> {
});
});

const config = await this.ctx.config.create().pipe(first()).toPromise();
const globalConfig = await this.ctx.config.legacy.globalConfig$.pipe(first()).toPromise();
const proxyPathFilters = config.proxyFilter.map((str: string) => new RegExp(str));

this.opensearchLegacyConfigService.setup(opensearch.legacy.config$);

const router = http.createRouter();
Expand Down
30 changes: 17 additions & 13 deletions src/plugins/dev_tools/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,23 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup> {
if (this.getSortedDevTools().length === 0) {
this.appStateUpdater.next(() => ({ navLinkStatus: AppNavLinkStatus.hidden }));
} else {
// Register right navigation for dev tool only when console is enabled.
core.chrome.navControls.registerRight({
order: RightNavigationOrder.DevTool,
mount: toMountPoint(
React.createElement(RightNavigationButton, {
appId: this.id,
iconType: 'consoleApp',
title: this.title,
application: core.application,
http: core.http,
})
),
});
// Register right navigation for dev tool only when console and topRightNavigation are both enabled.
const topRightNavigationEnabled =
core.application.capabilities?.dev_tools?.topRightNavigation;
if (topRightNavigationEnabled) {
core.chrome.navControls.registerRight({
order: RightNavigationOrder.DevTool,
mount: toMountPoint(
React.createElement(RightNavigationButton, {
appId: this.id,
iconType: 'consoleApp',
title: this.title,
application: core.application,
http: core.http,
})
),
});
}
}
}

Expand Down

0 comments on commit 53a67c8

Please sign in to comment.