fix delete plugin dashboard (#44055)

This commit is contained in:
Will Browne 2022-01-17 10:33:42 +01:00 committed by GitHub
parent f75e4d1a4f
commit a65ce992c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package plugins package plugins
type PluginDashboardInfoDTO struct { type PluginDashboardInfoDTO struct {
UID string `json:"uid"`
PluginId string `json:"pluginId"` PluginId string `json:"pluginId"`
Title string `json:"title"` Title string `json:"title"`
Imported bool `json:"imported"` Imported bool `json:"imported"`

View File

@ -41,6 +41,7 @@ func (m *PluginManager) GetPluginDashboards(ctx context.Context, orgID int64, pl
} }
res := &plugins.PluginDashboardInfoDTO{} res := &plugins.PluginDashboardInfoDTO{}
res.UID = dashboard.Uid
res.Path = include.Path res.Path = include.Path
res.PluginId = plugin.ID res.PluginId = plugin.ID
res.Title = dashboard.Title res.Title = dashboard.Title
@ -49,6 +50,7 @@ func (m *PluginManager) GetPluginDashboards(ctx context.Context, orgID int64, pl
// find existing dashboard // find existing dashboard
for _, existingDash := range query.Result { for _, existingDash := range query.Result {
if existingDash.Slug == dashboard.Slug { if existingDash.Slug == dashboard.Slug {
res.UID = existingDash.Uid
res.DashboardId = existingDash.Id res.DashboardId = existingDash.Id
res.Imported = true res.Imported = true
res.ImportedUri = "db/" + existingDash.Slug res.ImportedUri = "db/" + existingDash.Slug
@ -65,6 +67,7 @@ func (m *PluginManager) GetPluginDashboards(ctx context.Context, orgID int64, pl
for _, dash := range query.Result { for _, dash := range query.Result {
if _, exists := existingMatches[dash.Id]; !exists { if _, exists := existingMatches[dash.Id]; !exists {
result = append(result, &plugins.PluginDashboardInfoDTO{ result = append(result, &plugins.PluginDashboardInfoDTO{
UID: dash.Uid,
Slug: dash.Slug, Slug: dash.Slug,
DashboardId: dash.Id, DashboardId: dash.Id,
Removed: true, Removed: true,
@ -177,6 +180,7 @@ func (m *PluginManager) ImportDashboard(ctx context.Context, pluginID, path stri
} }
return plugins.PluginDashboardInfoDTO{ return plugins.PluginDashboardInfoDTO{
UID: savedDash.Uid,
PluginId: pluginID, PluginId: pluginID,
Title: savedDash.Title, Title: savedDash.Title,
Path: path, Path: path,

View File

@ -87,7 +87,7 @@ export class PluginDashboards extends PureComponent<Props, State> {
remove = (dash: PluginDashboard) => { remove = (dash: PluginDashboard) => {
getBackendSrv() getBackendSrv()
.delete('/api/dashboards/' + dash.importedUri) .delete('/api/dashboards/uid/' + dash.uid)
.then(() => { .then(() => {
dash.imported = false; dash.imported = false;
this.setState({ dashboards: [...this.state.dashboards] }); this.setState({ dashboards: [...this.state.dashboards] });

View File

@ -15,6 +15,7 @@ export interface PluginDashboard {
revision: number; revision: number;
slug: string; slug: string;
title: string; title: string;
uid: string;
} }
export interface PanelPluginsIndex { export interface PanelPluginsIndex {