mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 15:27:01 -06:00
fix delete plugin dashboard (#44055)
This commit is contained in:
parent
f75e4d1a4f
commit
a65ce992c1
@ -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"`
|
||||
|
@ -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,
|
||||
|
@ -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] });
|
||||
|
@ -15,6 +15,7 @@ export interface PluginDashboard {
|
||||
revision: number;
|
||||
slug: string;
|
||||
title: string;
|
||||
uid: string;
|
||||
}
|
||||
|
||||
export interface PanelPluginsIndex {
|
||||
|
Loading…
Reference in New Issue
Block a user