Skip to content

Commit

Permalink
update nav coditionally and set breadcrumbs
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 committed Jul 19, 2024
1 parent ebd8a3b commit b3d94ac
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 24 deletions.
25 changes: 23 additions & 2 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { AsyncApiResponse, AsyncQueryStatus } from '../../../common/types';
import { executeAsyncQuery } from '../../../common/utils/async_query_helpers';
import { fetchDataSources } from '../../../common/utils/fetch_datasources';
import * as pluginManifest from '../../../opensearch_dashboards.json';
import { coreRefs } from '../../framework/core_refs';
import { MESSAGE_TAB_LABEL } from '../../utils/constants';
import {
Tree,
Expand Down Expand Up @@ -302,9 +303,29 @@ export class Main extends React.Component<MainProps, MainState> {
}

componentDidMount() {
if (coreRefs?.chrome?.navGroup.getNavGroupEnabled()) {
this.props.setBreadcrumbs([
{
text: 'Dev Tools',
href: '#/console',
},
{
text: 'Query Workbench',
href: '#/opensearch-query-workbench',
},
]);
} else {
this.props.setBreadcrumbs([
{
text: 'Query Workbench',
href: '#',
},
]);
}

this.fetchFlintDataSources();
}

fetchFlintDataSources = () => {
fetchDataSources(
this.httpClient,
Expand Down Expand Up @@ -1196,4 +1217,4 @@ export class Main extends React.Component<MainProps, MainState> {
</>
);
}
}
}
72 changes: 50 additions & 22 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,57 @@ export class WorkbenchPlugin implements Plugin<WorkbenchPluginSetup, WorkbenchPl
core: CoreSetup,
{ dataSource, dataSourceManagement, devTools }: WorkbenchPluginSetupDependencies
): WorkbenchPluginSetup {
devTools.register({
id: 'opensearch-query-workbench',
title: PLUGIN_NAME,
enableRouting: true,
order: 2,
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in opensearch_dashboards.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(
coreStart,
depsStart as AppPluginStartDependencies,
params,
dataSourceManagement
);
},
});
const isNavGroupEnabled = core.chrome.navGroup.getNavGroupEnabled();

// redirect legacy workbench URL to current URL under dev-tools
if (window.location.pathname.includes('app/opensearch-query-workbench')) {
window.location.assign(convertLegacyWorkbenchUrl(window.location));
if (isNavGroupEnabled) {
devTools.register({
id: 'opensearch-query-workbench',
title: PLUGIN_NAME,
enableRouting: true,
order: 2,
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in opensearch_dashboards.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(
coreStart,
depsStart as AppPluginStartDependencies,
params,
dataSourceManagement
);
},
});

// redirect legacy workbench URL to current URL under dev-tools
if (window.location.pathname.includes('app/opensearch-query-workbench')) {
window.location.assign(convertLegacyWorkbenchUrl(window.location));
}
} else {
core.application.register({
id: 'opensearch-query-workbench',
title: PLUGIN_NAME,
category: {
id: 'opensearch',
label: 'OpenSearch Plugins',
order: 2000,
},
order: 1000,
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in opensearch_dashboards.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(
coreStart,
depsStart as AppPluginStartDependencies,
params,
dataSourceManagement
);
},
});
}

// Return methods that should be available to other plugins
Expand Down

0 comments on commit b3d94ac

Please sign in to comment.