simcha90 commented on a change in pull request #13087:
URL: https://github.com/apache/superset/pull/13087#discussion_r575767590
##########
File path: superset-frontend/src/views/App.tsx
##########
@@ -77,79 +155,81 @@ const App = () => (
ReactRouterRoute={Route}
stringifyOptions={{ encode: false }}
>
- <Menu data={menu} />
- <Switch>
- <Route path="/superset/welcome/">
- <ErrorBoundary>
- <Welcome user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/dashboard/list/">
- <ErrorBoundary>
- <DashboardList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/chart/list/">
- <ErrorBoundary>
- <ChartList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/tablemodelview/list/">
- <ErrorBoundary>
- <DatasetList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/databaseview/list/">
- <ErrorBoundary>
- <DatabaseList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/savedqueryview/list/">
- <ErrorBoundary>
- <SavedQueryList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/csstemplatemodelview/list/">
- <ErrorBoundary>
- <CssTemplatesList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/annotationlayermodelview/list/">
- <ErrorBoundary>
- <AnnotationLayersList user={user} />
- </ErrorBoundary>
- </Route>
- <Route
path="/annotationmodelview/:annotationLayerId/annotation/">
- <ErrorBoundary>
- <AnnotationList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/superset/sqllab/history/">
- <ErrorBoundary>
- <QueryList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/alert/list/">
- <ErrorBoundary>
- <AlertList user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/report/list/">
- <ErrorBoundary>
- <AlertList user={user} isReportEnabled />
- </ErrorBoundary>
- </Route>
- <Route path="/alert/:alertId/log">
- <ErrorBoundary>
- <ExecutionLog user={user} />
- </ErrorBoundary>
- </Route>
- <Route path="/report/:alertId/log">
- <ErrorBoundary>
- <ExecutionLog user={user} isReportEnabled />
- </ErrorBoundary>
- </Route>
- </Switch>
+ <Menu data={menu} frontEndRoutes={frontEndRoutes} />
+ <Suspense fallback={<Loading />}>
+ <Switch>
+ <Route path={routes.welcome}>
+ <ErrorBoundary>
+ <Welcome user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.dashboards}>
+ <ErrorBoundary>
+ <DashboardList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.charts}>
+ <ErrorBoundary>
+ <ChartList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.datasets}>
+ <ErrorBoundary>
+ <DatasetList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.databases}>
+ <ErrorBoundary>
+ <DatabaseList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.savedQueries}>
+ <ErrorBoundary>
+ <SavedQueryList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.cssTemplates}>
+ <ErrorBoundary>
+ <CssTemplatesList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.annotationLayers}>
+ <ErrorBoundary>
+ <AnnotationLayersList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.annotations}>
+ <ErrorBoundary>
+ <AnnotationList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.queries}>
+ <ErrorBoundary>
+ <QueryList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.alerts}>
+ <ErrorBoundary>
+ <AlertList user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.reports}>
+ <ErrorBoundary>
+ <AlertList user={user} isReportEnabled />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.alertLogs}>
+ <ErrorBoundary>
+ <ExecutionLog user={user} />
+ </ErrorBoundary>
+ </Route>
+ <Route path={routes.reportLogs}>
+ <ErrorBoundary>
+ <ExecutionLog user={user} isReportEnabled />
+ </ErrorBoundary>
Review comment:
just proposal to reduce code may be create map like:
```
const pathToRoute = {
[routes.alertLogs]: { Component : ExecutionLog },
[routes. reportLogs]: { Component : ExecutionLog, isReportEnabled: true },
...etc others...
}
```
and then just:
```
<Suspense fallback={<Loading />}>
<Route path="/superset/welcome/">
<Switch>
{Object.values(routes).map(route => {
const { Component, ...otherProps } = pathToRoute[route]
return <Route path={routes.alertLogs}>
<ErrorBoundary>
<Component user={user} {...otherProps}/>
</ErrorBoundary>
</Route>
}) }
...
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]