mirror of
https://github.com/grafana/grafana.git
synced 2026-08-13 06:34:55 -05:00
[Dashboard] Revert feature toggle trimdefaults (#34888)
* Revert "solve comments and retrigger the test" This reverts commitf08d2d9eca. * Revert "update api doc" This reverts commitcc09ceb853. * Revert "remove post trim" This reverts commit46fe8ed596. * Revert "fix typo" This reverts commit3b3ceee16e. * Revert "Apply suggestions from code review" This reverts commit3b7f3b8e15. * Revert "update comments" This reverts commitb9c6260876. * Revert "update doc" This reverts commit8e4c4d7c93. * Revert "remove feature toggle + add libraryPaneldefinition" This reverts commitd01cfcc2ed. * fix some typos * Update public/app/features/dashboard/components/ShareModal/ShareExport.tsx Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> * Update docs/sources/dashboards/export-import.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * fix comments Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
achatterjee-grafana
parent
f16b2c40c1
commit
b391e43472
@@ -51,9 +51,12 @@ func (hs *HTTPServer) TrimDashboard(c *models.ReqContext, cmd models.TrimDashboa
|
||||
dash := cmd.Dashboard
|
||||
meta := cmd.Meta
|
||||
|
||||
trimedResult, err := hs.LoadSchemaService.DashboardTrimDefaults(*dash)
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while trim default value from dashboard json", err)
|
||||
trimedResult := *dash
|
||||
if !hs.LoadSchemaService.IsDisabled() {
|
||||
trimedResult, err = hs.LoadSchemaService.DashboardTrimDefaults(*dash)
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while exporting with default values removed", err)
|
||||
}
|
||||
}
|
||||
|
||||
dto := dtos.TrimDashboardFullWithMeta{
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ func (hs *HTTPServer) ImportDashboard(c *models.ReqContext, apiCmd dtos.ImportDa
|
||||
}
|
||||
|
||||
trimDefaults := c.QueryBoolWithDefault("trimdefaults", true)
|
||||
if trimDefaults {
|
||||
if trimDefaults && !hs.LoadSchemaService.IsDisabled() {
|
||||
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,6 +50,12 @@ 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()
|
||||
|
||||
@@ -397,6 +397,11 @@ 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