mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DashboardScene: Fix issue with url sync after saving title change (#81851)
DashboardScene: Fix issue with url sycn after saving title change
This commit is contained in:
parent
dd0ca1263b
commit
ba7e0d5c2e
@ -10,7 +10,7 @@ import { DashboardScene } from '../scene/DashboardScene';
|
||||
|
||||
import { SaveDashboardDrawer } from './SaveDashboardDrawer';
|
||||
import { DashboardChangeInfo, NameAlreadyExistsError, SaveButton, isNameExistsError } from './shared';
|
||||
import { useDashboardSave } from './useSaveDashboard';
|
||||
import { useSaveDashboard } from './useSaveDashboard';
|
||||
|
||||
interface SaveDashboardAsFormDTO {
|
||||
firstName?: string;
|
||||
@ -45,7 +45,7 @@ export function SaveDashboardAsForm({ dashboard, drawer, changeInfo }: Props) {
|
||||
const { errors, isValid, defaultValues } = formState;
|
||||
const formValues = watch();
|
||||
|
||||
const { state, onSaveDashboard } = useDashboardSave(false);
|
||||
const { state, onSaveDashboard } = useSaveDashboard(false);
|
||||
|
||||
const onSave = async (overwrite: boolean) => {
|
||||
const data = getValues();
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
isPluginDashboardError,
|
||||
isVersionMismatchError,
|
||||
} from './shared';
|
||||
import { useDashboardSave } from './useSaveDashboard';
|
||||
import { useSaveDashboard } from './useSaveDashboard';
|
||||
|
||||
export interface Props {
|
||||
dashboard: DashboardScene;
|
||||
@ -26,7 +26,7 @@ export interface Props {
|
||||
export function SaveDashboardForm({ dashboard, drawer, changeInfo }: Props) {
|
||||
const { changedSaveModel, hasChanges } = changeInfo;
|
||||
|
||||
const { state, onSaveDashboard } = useDashboardSave(false);
|
||||
const { state, onSaveDashboard } = useSaveDashboard(false);
|
||||
const [options, setOptions] = useState<SaveDashboardOptions>({
|
||||
folderUid: dashboard.state.meta.folderUid,
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ import { DashboardSavedEvent } from 'app/types/events';
|
||||
import { updateDashboardUidLastUsedDatasource } from '../../dashboard/utils/dashboard';
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
|
||||
export function useDashboardSave(isCopy = false) {
|
||||
export function useSaveDashboard(isCopy = false) {
|
||||
const dispatch = useDispatch();
|
||||
const notifyApp = useAppNotification();
|
||||
const [saveDashboardRtkQuery] = useSaveDashboardMutation();
|
||||
@ -60,7 +60,12 @@ export function useDashboardSave(isCopy = false) {
|
||||
const newUrl = locationUtil.stripBaseFromUrl(resultData.url);
|
||||
|
||||
if (newUrl !== currentLocation.pathname) {
|
||||
setTimeout(() => locationService.replace({ pathname: newUrl, search: currentLocation.search }));
|
||||
setTimeout(() => {
|
||||
// Because the path changes we need to stop and restart url sync
|
||||
scene.stopUrlSync();
|
||||
locationService.push({ pathname: newUrl, search: currentLocation.search });
|
||||
scene.startUrlSync();
|
||||
});
|
||||
}
|
||||
|
||||
if (scene.state.meta.isStarred) {
|
||||
|
Loading…
Reference in New Issue
Block a user