Skip to content

Commit

Permalink
fix workbench routes to support modal mounting (#401)
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 authored Oct 11, 2024
1 parent e707880 commit 8190b1f
Showing 1 changed file with 24 additions and 49 deletions.
73 changes: 24 additions & 49 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,69 +44,44 @@ export const WorkbenchApp = ({
const isNavGroupEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled();
const basePath = isNavGroupEnabled ? '/opensearch-query-workbench' : '';

const renderMain = (props: any, isAccelerationFlyoutOpen: boolean, urlDataSource: string) => {
return (
<Main
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
isAccelerationFlyoutOpen={isAccelerationFlyoutOpen}
urlDataSource={urlDataSource}
notifications={notifications}
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceMDSId={dataSourceId}
setActionMenu={setActionMenu}
/>
);
};

return (
<HashRouter>
<I18nProvider>
<div>
<EuiPage>
<EuiPageBody>
<Switch>
<Route
exact
path={isNavGroupEnabled ? [`${basePath}`, `/`] : `/${basePath}`}
render={(props) => (
<Main
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
isAccelerationFlyoutOpen={false}
urlDataSource=""
notifications={notifications}
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceMDSId={dataSourceId}
setActionMenu={setActionMenu}
/>
)}
/>
<Route
exact
path={`${basePath}/:dataSource`}
render={(props) => (
<Main
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
isAccelerationFlyoutOpen={false}
urlDataSource={props.match.params.dataSource}
notifications={notifications}
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceMDSId={dataSourceId}
setActionMenu={setActionMenu}
/>
)}
render={(props) => renderMain(props, false, props.match.params.dataSource)}
/>
<Route
exact
path={`${basePath}/accelerate/:dataSource`}
render={(props) => (
<Main
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
isAccelerationFlyoutOpen={true}
urlDataSource={props.match.params.dataSource}
notifications={notifications}
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceMDSId={dataSourceId}
setActionMenu={setActionMenu}
/>
)}
render={(props) => renderMain(props, true, props.match.params.dataSource)}
/>
<Route
path={isNavGroupEnabled ? [`${basePath}`, `/`] : `/${basePath}`}
render={(props) => renderMain(props, false, '')}
/>
</Switch>
</EuiPageBody>
Expand Down

0 comments on commit 8190b1f

Please sign in to comment.