mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 15:49:24 +08:00
ReturnToPrevious: make href
optional (#81691)
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
import React, { useContext } from 'react';
|
||||
import React, { useCallback, useContext } from 'react';
|
||||
|
||||
import { GrafanaConfig } from '@grafana/data';
|
||||
import { LocationService } from '@grafana/runtime/src/services/LocationService';
|
||||
import { BackendSrv } from '@grafana/runtime/src/services/backendSrv';
|
||||
import { LocationService, locationService, BackendSrv } from '@grafana/runtime';
|
||||
|
||||
import { AppChromeService } from '../components/AppChrome/AppChromeService';
|
||||
import { NewFrontendAssetsChecker } from '../services/NewFrontendAssetsChecker';
|
||||
@ -31,5 +30,14 @@ export function useGrafana(): GrafanaContextType {
|
||||
// @grafana/runtime
|
||||
export function useReturnToPreviousInternal() {
|
||||
const { chrome } = useGrafana();
|
||||
return chrome.setReturnToPrevious;
|
||||
return useCallback(
|
||||
(title: string, href?: string) => {
|
||||
const { pathname, search } = locationService.getLocation();
|
||||
chrome.setReturnToPrevious({
|
||||
title: title,
|
||||
href: href ?? pathname + search,
|
||||
});
|
||||
},
|
||||
[chrome]
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user