Dashboard Library: Display datasource plugin dashboards in empty page (#111279)

This commit is contained in:
Juan Cabanas
2025-10-15 09:05:02 -03:00
committed by GitHub
parent 89b3f64479
commit b7a6e1ca53
31 changed files with 972 additions and 47 deletions
@@ -34,7 +34,7 @@ func ProvideService(routeRegister routing.RouteRegister,
features: features,
}
dashboardImportAPI := api.New(s, quotaService, pluginStore, ac)
dashboardImportAPI := api.New(s, quotaService, pluginStore, ac, features)
dashboardImportAPI.RegisterAPIEndpoints(routeRegister)
return s
@@ -48,7 +48,7 @@ type ImportDashboardService struct {
features featuremgmt.FeatureToggles
}
func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashboardimport.ImportDashboardRequest) (*dashboardimport.ImportDashboardResponse, error) {
func (s *ImportDashboardService) InterpolateDashboard(ctx context.Context, req *dashboardimport.ImportDashboardRequest) (*simplejson.Json, error) {
var draftDashboard *dashboards.Dashboard
if req.PluginId != "" {
loadReq := &plugindashboards.LoadPluginDashboardRequest{
@@ -70,6 +70,15 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
return nil, err
}
return generatedDash, nil
}
func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashboardimport.ImportDashboardRequest) (*dashboardimport.ImportDashboardResponse, error) {
generatedDash, err := s.InterpolateDashboard(ctx, req)
if err != nil {
return nil, err
}
// Maintain backwards compatibility by transforming array of library elements to map
libraryElements := generatedDash.Get("__elements")
libElementsArr, err := libraryElements.Array()