mirror of https://github.com/grafana/grafana.git
Dashboards: Ensure initial datasource is reset when user leaves
CodeQL checks / Detect whether code changed (push) Waiting to run
Details
CodeQL checks / Analyze (actions) (push) Blocked by required conditions
Details
CodeQL checks / Analyze (go) (push) Blocked by required conditions
Details
CodeQL checks / Analyze (javascript) (push) Blocked by required conditions
Details
CodeQL checks / Detect whether code changed (push) Waiting to run
Details
CodeQL checks / Analyze (actions) (push) Blocked by required conditions
Details
CodeQL checks / Analyze (go) (push) Blocked by required conditions
Details
CodeQL checks / Analyze (javascript) (push) Blocked by required conditions
Details
This commit is contained in:
parent
d45fe838e3
commit
cc00a28e3e
|
@ -1,12 +1,14 @@
|
|||
import { css } from '@emotion/css';
|
||||
import { useCallback } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Button, useStyles2, Text, Box, Stack, TextLink } from '@grafana/ui';
|
||||
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
import { setInitialDatasource } from 'app/features/dashboard/state/reducers';
|
||||
import { DashboardScene } from 'app/features/dashboard-scene/scene/DashboardScene';
|
||||
import { useDispatch } from 'app/types/store';
|
||||
|
||||
import { DashboardEmptyExtensionPoint } from './DashboardEmptyExtensionPoint';
|
||||
import {
|
||||
|
@ -128,6 +130,15 @@ const DashboardEmpty = (props: Props) => {
|
|||
const onAddLibraryPanel = useOnAddLibraryPanel({ ...props, isReadOnlyRepo, initialDatasource });
|
||||
const onImportDashboard = useOnImportDashboard({ ...props, isReadOnlyRepo, initialDatasource });
|
||||
|
||||
// Ensure that if the user leaves the dashboard empty screen, we clear the initial datasource
|
||||
// We don't want to show UI related to the initial datasource if the user comes back later
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
dispatch(setInitialDatasource(undefined));
|
||||
};
|
||||
}, [dispatch]);
|
||||
|
||||
return (
|
||||
<DashboardEmptyExtensionPoint
|
||||
renderDefaultUI={useCallback(
|
||||
|
|
Loading…
Reference in New Issue