folders: change the front end route for browsing folders

Change the front end route for folders to /dashboards/f/<uid>/<slug of folder title>.
Use new route for deleting dashboard/folder by uid.
Retrieve dashboard/folder by uid when moving or deleting dashboards/folders.
This commit is contained in:
Marcus Efraimsson
2018-01-31 17:15:00 +01:00
parent b23560ed5a
commit 92a0171a9b
14 changed files with 56 additions and 55 deletions

View File

@@ -91,10 +91,10 @@ export class ManageDashboardsCtrl {
for (const section of this.sections) {
if (section.checked && section.id !== 0) {
selectedDashboards.folders.push(section.slug);
selectedDashboards.folders.push(section.uid);
} else {
const selected = _.filter(section.items, { checked: true });
selectedDashboards.dashboards.push(..._.map(selected, 'slug'));
selectedDashboards.dashboards.push(..._.map(selected, 'uid'));
}
}
@@ -185,7 +185,7 @@ export class ManageDashboardsCtrl {
for (const section of this.sections) {
const selected = _.filter(section.items, { checked: true });
selectedDashboards.push(..._.map(selected, 'slug'));
selectedDashboards.push(..._.map(selected, 'uid'));
}
return selectedDashboards;

View File

@@ -257,11 +257,11 @@ export class BackendSrv {
});
}
deleteDashboard(slug) {
deleteDashboard(uid) {
let deferred = this.$q.defer();
this.getDashboard('db', slug).then(fullDash => {
this.delete(`/api/dashboards/db/${slug}`)
this.getDashboardByUid(uid).then(fullDash => {
this.delete(`/api/dashboards/uid/${uid}`)
.then(() => {
deferred.resolve(fullDash);
})
@@ -273,21 +273,21 @@ export class BackendSrv {
return deferred.promise;
}
deleteDashboards(dashboardSlugs) {
deleteDashboards(dashboardUids) {
const tasks = [];
for (let slug of dashboardSlugs) {
tasks.push(this.createTask(this.deleteDashboard.bind(this), true, slug));
for (let uid of dashboardUids) {
tasks.push(this.createTask(this.deleteDashboard.bind(this), true, uid));
}
return this.executeInOrder(tasks, []);
}
moveDashboards(dashboardSlugs, toFolder) {
moveDashboards(dashboardUids, toFolder) {
const tasks = [];
for (let slug of dashboardSlugs) {
tasks.push(this.createTask(this.moveDashboard.bind(this), true, slug, toFolder));
for (let uid of dashboardUids) {
tasks.push(this.createTask(this.moveDashboard.bind(this), true, uid, toFolder));
}
return this.executeInOrder(tasks, []).then(result => {
@@ -299,10 +299,10 @@ export class BackendSrv {
});
}
private moveDashboard(slug, toFolder) {
private moveDashboard(uid, toFolder) {
let deferred = this.$q.defer();
this.getDashboard('db', slug).then(fullDash => {
this.getDashboardByUid(uid).then(fullDash => {
const model = new DashboardModel(fullDash.dashboard, fullDash.meta);
if ((!fullDash.meta.folderId && toFolder.id === 0) || fullDash.meta.folderId === toFolder.id) {

View File

@@ -128,11 +128,12 @@ export class SearchSrv {
if (hit.type === 'dash-folder') {
sections[hit.id] = {
id: hit.id,
uid: hit.uid,
title: hit.title,
expanded: false,
items: [],
toggle: this.toggleFolder.bind(this),
url: `dashboards/folder/${hit.id}/${hit.slug}`,
url: hit.url,
slug: hit.slug,
icon: 'fa fa-folder',
score: _.keys(sections).length,
@@ -150,8 +151,9 @@ export class SearchSrv {
if (hit.folderId) {
section = {
id: hit.folderId,
uid: hit.uid,
title: hit.folderTitle,
url: `dashboards/folder/${hit.folderId}/${hit.folderSlug}`,
url: hit.url,
slug: hit.slug,
items: [],
icon: 'fa fa-folder-open',

View File

@@ -483,22 +483,22 @@ describe('ManageDashboards', () => {
ctrl.sections = [
{
id: 1,
uid: 'folder',
title: 'folder',
items: [{ id: 2, checked: true, slug: 'folder-dash' }],
items: [{ id: 2, checked: true, uid: 'folder-dash' }],
checked: true,
slug: 'folder',
},
{
id: 3,
title: 'folder-2',
items: [{ id: 3, checked: true, slug: 'folder-2-dash' }],
items: [{ id: 3, checked: true, uid: 'folder-2-dash' }],
checked: false,
slug: 'folder-2',
uid: 'folder-2',
},
{
id: 0,
title: 'Root',
items: [{ id: 3, checked: true, slug: 'root-dash' }],
items: [{ id: 3, checked: true, uid: 'root-dash' }],
checked: true,
},
];
@@ -535,14 +535,14 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
items: [{ id: 2, checked: true, slug: 'dash' }],
items: [{ id: 2, checked: true, uid: 'dash' }],
checked: false,
slug: 'folder',
uid: 'folder',
},
{
id: 0,
title: 'Root',
items: [{ id: 3, checked: true, slug: 'dash-2' }],
items: [{ id: 3, checked: true, uid: 'dash-2' }],
checked: false,
},
];