dashboards: use new *url* prop from dashboard search for linking to dashboards

#7883
This commit is contained in:
Marcus Efraimsson 2018-01-31 00:42:17 +01:00
parent 8009307c16
commit f2014223b4

View File

@ -41,10 +41,7 @@ export class SearchSrv {
.map(orderId => { .map(orderId => {
return _.find(result, { id: orderId }); return _.find(result, { id: orderId });
}) })
.filter(hit => hit && !hit.isStarred) .filter(hit => hit && !hit.isStarred);
.map(hit => {
return this.transformToViewModel(hit);
});
}); });
} }
@ -81,17 +78,12 @@ export class SearchSrv {
score: -2, score: -2,
expanded: this.starredIsOpen, expanded: this.starredIsOpen,
toggle: this.toggleStarred.bind(this), toggle: this.toggleStarred.bind(this),
items: result.map(this.transformToViewModel), items: result,
}; };
} }
}); });
} }
private transformToViewModel(hit) {
hit.url = 'dashboard/db/' + hit.slug;
return hit;
}
search(options) { search(options) {
let sections: any = {}; let sections: any = {};
let promises = []; let promises = [];
@ -181,7 +173,7 @@ export class SearchSrv {
} }
section.expanded = true; section.expanded = true;
section.items.push(this.transformToViewModel(hit)); section.items.push(hit);
} }
} }
@ -198,7 +190,7 @@ export class SearchSrv {
}; };
return this.backendSrv.search(query).then(results => { return this.backendSrv.search(query).then(results => {
section.items = _.map(results, this.transformToViewModel); section.items = results;
return Promise.resolve(section); return Promise.resolve(section);
}); });
} }