Previews: check feature flag on dashboard manage page (#43632)

This commit is contained in:
Ryan McKinley 2022-01-03 17:15:50 -05:00 committed by GitHub
parent 56d088c441
commit a3d2c79d06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { useLocalStorage } from 'react-use';
import { css } from '@emotion/css';
import { stylesFactory, useTheme, Spinner, FilterInput } from '@grafana/ui';
import { GrafanaTheme } from '@grafana/data';
import { config } from '@grafana/runtime';
import { contextSrv } from 'app/core/services/context_srv';
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
import { FolderDTO } from 'app/types';
@ -23,6 +24,7 @@ export interface Props {
const { isEditor } = contextSrv;
export const ManageDashboards: FC<Props> = memo(({ folder }) => {
const previewsEnabled = Boolean(config.featureToggles.dashboardPreviews);
const [showPreviews, setShowPreviews] = useLocalStorage<boolean>(PREVIEWS_LOCAL_STORAGE_KEY, true);
const onShowPreviewsChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setShowPreviews(event.target.checked);
@ -118,7 +120,7 @@ export const ManageDashboards: FC<Props> = memo(({ folder }) => {
onSortChange={onSortChange}
onTagFilterChange={onTagFilterChange}
query={query}
showPreviews={showPreviews}
showPreviews={previewsEnabled && showPreviews}
hideLayout={!!folderUid}
onLayoutChange={onLayoutChange}
editable={hasEditPermissionInFolders}
@ -131,7 +133,7 @@ export const ManageDashboards: FC<Props> = memo(({ folder }) => {
onToggleSection={onToggleSection}
onToggleChecked={onToggleChecked}
layout={query.layout}
showPreviews={showPreviews}
showPreviews={previewsEnabled && showPreviews}
/>
</div>
<ConfirmDeleteModal