TopNav: Adds new feature toggle for upcoming nav~ (#51115)

This commit is contained in:
Torkel Ödegaard
2022-06-20 16:25:43 +02:00
committed by GitHub
parent d8d1ca8151
commit 3c3293df78
4 changed files with 29 additions and 11 deletions

View File

@@ -62,4 +62,5 @@ export interface FeatureToggles {
logRequestsInstrumentedAsUnknown?: boolean;
dataConnectionsConsole?: boolean;
internationalization?: boolean;
topnav?: boolean;
}

View File

@@ -258,5 +258,10 @@ var (
Description: "Enables work-in-progress internationalization",
State: FeatureStateAlpha,
},
{
Name: "topnav",
Description: "New top nav and page layouts",
State: FeatureStateAlpha,
},
}
)

View File

@@ -190,4 +190,8 @@ const (
// FlagInternationalization
// Enables work-in-progress internationalization
FlagInternationalization = "internationalization"
// FlagTopnav
// New top nav and page layouts
FlagTopnav = "topnav"
)

View File

@@ -81,6 +81,22 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
return <Switch>{getAppRoutes().map((r) => this.renderRoute(r))}</Switch>;
}
renderNavBar() {
if (config.isPublicDashboardView || !this.state.ready || config.featureToggles.topnav) {
return null;
}
return <NavBar />;
}
commandPaletteEnabled() {
return config.featureToggles.commandPalette && !config.isPublicDashboardView;
}
searchBarEnabled() {
return !config.isPublicDashboardView;
}
render() {
const { ready } = this.state;
@@ -92,14 +108,6 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
});
};
const commandPaletteEnabled = () => !config.isPublicDashboardView && config.featureToggles.commandPalette;
const renderNavBar = () => {
return !config.isPublicDashboardView && ready && <NavBar />;
};
const searchBarEnabled = () => !config.isPublicDashboardView;
return (
<Provider store={store}>
<I18nProvider>
@@ -112,10 +120,10 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
>
<ModalsProvider>
<GlobalStyles />
{commandPaletteEnabled() && <CommandPalette />}
{this.commandPaletteEnabled() && <CommandPalette />}
<div className="grafana-app">
<Router history={locationService.getHistory()}>
{renderNavBar()}
{this.renderNavBar()}
<main className="main-view">
{pageBanners.map((Banner, index) => (
<Banner key={index.toString()} />
@@ -123,7 +131,7 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
<AngularRoot />
<AppNotificationList />
{searchBarEnabled() && <SearchWrapper />}
{this.searchBarEnabled() && <SearchWrapper />}
{ready && this.renderRoutes()}
{bodyRenderHooks.map((Hook, index) => (
<Hook key={index.toString()} />