Explore: prevent direct access to explore if disabled via feature toggle (#47714)

* Explore: prevent explore route to be registered if explore is disabled

* add feature toggle page
This commit is contained in:
Giordano Ricci 2022-04-22 09:03:24 +01:00 committed by GitHub
parent f2814046d1
commit 6899f23a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,30 @@
import React from 'react';
import Page from 'app/core/components/Page/Page';
import { css } from '@emotion/css';
import { useStyles2 } from '@grafana/ui';
import { GrafanaTheme2 } from '@grafana/data';
export default function FeatureTogglePage() {
const styles = useStyles2(
(theme: GrafanaTheme2) =>
css`
margin-top: ${theme.spacing(2)};
`
);
return (
<Page className={styles}>
<Page.Contents>
<h1>Explore is disabled</h1>
To enable Explore, enable it in the Grafana config:
<div>
<pre>
{`[explore]
enable = true
`}
</pre>
</div>
</Page.Contents>
</Page>
);
}

View File

@ -161,7 +161,11 @@ export function getAppRoutes(): RouteDescriptor[] {
() => (config.viewersCanEdit ? [] : ['Editor', 'Admin']), () => (config.viewersCanEdit ? [] : ['Editor', 'Admin']),
[AccessControlAction.DataSourcesExplore] [AccessControlAction.DataSourcesExplore]
), ),
component: SafeDynamicImport(() => import(/* webpackChunkName: "explore" */ 'app/features/explore/Wrapper')), component: SafeDynamicImport(() =>
config.exploreEnabled
? import(/* webpackChunkName: "explore" */ 'app/features/explore/Wrapper')
: import(/* webpackChunkName: "explore-feature-toggle-page" */ 'app/features/explore/FeatureTogglePage')
),
}, },
{ {
path: '/a/:pluginId/', path: '/a/:pluginId/',