Commit 9948e929 by Peter Holmberg Committed by GitHub

Fix: Redirect to correct url after creating a folder (#26160)

parent 2ac1bfcc
import { AppEvents } from '@grafana/data'; import { AppEvents, locationUtil } from '@grafana/data';
import { getBackendSrv } from '@grafana/runtime';
import { backendSrv } from 'app/core/services/backend_srv'; import { backendSrv } from 'app/core/services/backend_srv';
import { FolderState, ThunkResult } from 'app/types'; import { FolderState, ThunkResult } from 'app/types';
import { DashboardAcl, DashboardAclUpdateDTO, NewDashboardAclItem, PermissionLevel } from 'app/types/acl'; import { DashboardAcl, DashboardAclUpdateDTO, NewDashboardAclItem, PermissionLevel } from 'app/types/acl';
import { updateLocation, updateNavIndex } from 'app/core/actions'; import { updateLocation, updateNavIndex } from 'app/core/actions';
import { buildNavModel } from './navModel'; import { buildNavModel } from './navModel';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import { loadFolder, loadFolderPermissions } from './reducers'; import { loadFolder, loadFolderPermissions } from './reducers';
import { getBackendSrv } from '@grafana/runtime';
export function getFolderByUid(uid: string): ThunkResult<void> { export function getFolderByUid(uid: string): ThunkResult<void> {
return async dispatch => { return async dispatch => {
...@@ -122,9 +121,8 @@ export function addFolderPermission(newItem: NewDashboardAclItem): ThunkResult<v ...@@ -122,9 +121,8 @@ export function addFolderPermission(newItem: NewDashboardAclItem): ThunkResult<v
export function createNewFolder(folderName: string): ThunkResult<void> { export function createNewFolder(folderName: string): ThunkResult<void> {
return async dispatch => { return async dispatch => {
// @ts-ignore const newFolder = await getBackendSrv().post('/api/folders', { title: folderName });
const newFolder = await getBackendSrv().createFolder({ title: folderName });
appEvents.emit(AppEvents.alertSuccess, ['Folder Created', 'OK']); appEvents.emit(AppEvents.alertSuccess, ['Folder Created', 'OK']);
dispatch(updateLocation({ path: newFolder.url })); dispatch(updateLocation({ path: locationUtil.stripBaseFromUrl(newFolder.url) }));
}; };
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment