remove feature toggle + add libraryPaneldefinition (#34488)
* remove feature toggle + add libraryPaneldefinition * update doc * update comments * Apply suggestions from code review Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * fix typo * remove post trim * update api doc * solve comments and retrigger the test Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
This commit is contained in:
co-authored by
Diana Payton
parent
dbef103fb9
commit
c59a2e1bcf
+3
-12
@@ -52,11 +52,9 @@ func (hs *HTTPServer) TrimDashboard(c *models.ReqContext, cmd models.TrimDashboa
|
||||
meta := cmd.Meta
|
||||
|
||||
trimedResult := *dash
|
||||
if !hs.LoadSchemaService.IsDisabled() {
|
||||
trimedResult, err = hs.LoadSchemaService.DashboardTrimDefaults(*dash)
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while trim default value from dashboard json", err)
|
||||
}
|
||||
trimedResult, err = hs.LoadSchemaService.DashboardTrimDefaults(*dash)
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while trim default value from dashboard json", err)
|
||||
}
|
||||
|
||||
dto := dtos.TrimDashboardFullWithMeta{
|
||||
@@ -279,13 +277,6 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
|
||||
var err error
|
||||
cmd.OrgId = c.OrgId
|
||||
cmd.UserId = c.UserId
|
||||
trimDefaults := c.QueryBoolWithDefault("trimdefaults", false)
|
||||
if trimDefaults && !hs.LoadSchemaService.IsDisabled() {
|
||||
cmd.Dashboard, err = hs.LoadSchemaService.DashboardApplyDefaults(cmd.Dashboard)
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while applying default value to the dashboard json", err)
|
||||
}
|
||||
}
|
||||
if cmd.FolderUid != "" {
|
||||
folders := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
|
||||
folder, err := folders.GetFolderByUID(cmd.FolderUid)
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ func (hs *HTTPServer) ImportDashboard(c *models.ReqContext, apiCmd dtos.ImportDa
|
||||
}
|
||||
|
||||
trimDefaults := c.QueryBoolWithDefault("trimdefaults", true)
|
||||
if trimDefaults && !hs.LoadSchemaService.IsDisabled() {
|
||||
if trimDefaults {
|
||||
apiCmd.Dashboard, err = hs.LoadSchemaService.DashboardApplyDefaults(apiCmd.Dashboard)
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while applying default value to the dashboard json", err)
|
||||
|
||||
@@ -50,12 +50,6 @@ func (rs *SchemaLoaderService) Init() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (rs *SchemaLoaderService) IsDisabled() bool {
|
||||
if rs.Cfg == nil {
|
||||
return true
|
||||
}
|
||||
return !rs.Cfg.IsTrimDefaultsEnabled()
|
||||
}
|
||||
|
||||
func (rs *SchemaLoaderService) DashboardApplyDefaults(input *simplejson.Json) (*simplejson.Json, error) {
|
||||
val, _ := input.Map()
|
||||
|
||||
@@ -391,11 +391,6 @@ func (cfg Cfg) IsNgAlertEnabled() bool {
|
||||
return cfg.FeatureToggles["ngalert"]
|
||||
}
|
||||
|
||||
// IsTrimDefaultsEnabled returns whether the standalone trim dashboard default feature is enabled.
|
||||
func (cfg Cfg) IsTrimDefaultsEnabled() bool {
|
||||
return cfg.FeatureToggles["trimDefaults"]
|
||||
}
|
||||
|
||||
// IsDatabaseMetricsEnabled returns whether the database instrumentation feature is enabled.
|
||||
func (cfg Cfg) IsDatabaseMetricsEnabled() bool {
|
||||
return cfg.FeatureToggles["database_metrics"]
|
||||
|
||||
Reference in New Issue
Block a user