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
type PluginDashboardInfoDTO struct {
UID string `json:"uid"`
PluginId string `json:"pluginId"`
Title string `json:"title"`
Imported bool `json:"imported"`

View File

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

View File

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

View File

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