diff --git a/conf/defaults.ini b/conf/defaults.ini index 29cb40206c5..f14739c2d41 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -1533,6 +1533,8 @@ public_key_retrieval_on_startup = false disable_plugins = # Auth token for plugin installations and removal in managed instances install_token = +# Comma separated list of plugin ids for which angular deprecation UI should be disabled +hide_angular_deprecation = #################################### Grafana Live ########################################## [live] diff --git a/pkg/plugins/config/config.go b/pkg/plugins/config/config.go index 905349bfb81..c7f3ac61742 100644 --- a/pkg/plugins/config/config.go +++ b/pkg/plugins/config/config.go @@ -45,13 +45,14 @@ type Cfg struct { Features plugins.FeatureToggles - AngularSupportEnabled bool + AngularSupportEnabled bool + HideAngularDeprecation []string } func NewCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSettings, pluginsAllowUnsigned []string, awsAllowedAuthProviders []string, awsAssumeRoleEnabled bool, awsExternalId string, azure *azsettings.AzureSettings, secureSocksDSProxy setting.SecureSocksDSProxySettings, grafanaVersion string, logDatasourceRequests bool, pluginsCDNURLTemplate string, appURL string, appSubURL string, tracing Tracing, features plugins.FeatureToggles, angularSupportEnabled bool, - grafanaComURL string, disablePlugins []string) *Cfg { + grafanaComURL string, disablePlugins []string, hideAngularDeprecation []string) *Cfg { return &Cfg{ log: log.New("plugin.cfg"), PluginsPath: pluginsPath, @@ -73,5 +74,6 @@ func NewCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSetti GrafanaAppSubURL: appSubURL, Features: features, AngularSupportEnabled: angularSupportEnabled, + HideAngularDeprecation: hideAngularDeprecation, } } diff --git a/pkg/plugins/manager/pipeline/validation/steps.go b/pkg/plugins/manager/pipeline/validation/steps.go index 502f17140a4..5efe0b4bb29 100644 --- a/pkg/plugins/manager/pipeline/validation/steps.go +++ b/pkg/plugins/manager/pipeline/validation/steps.go @@ -3,6 +3,7 @@ package validation import ( "context" "errors" + "slices" "time" "github.com/grafana/grafana/pkg/plugins" @@ -108,6 +109,6 @@ func (a *AngularDetector) Validate(ctx context.Context, p *plugins.Plugin) error return errors.New("angular plugins are not supported") } } - p.Angular.HideDeprecation = a.cfg.PluginSettings[p.ID]["hide_angular_deprecation"] == "true" + p.Angular.HideDeprecation = slices.Contains(a.cfg.HideAngularDeprecation, p.ID) return nil } diff --git a/pkg/services/pluginsintegration/config/config.go b/pkg/services/pluginsintegration/config/config.go index 823e8f89ebf..bd3ebe14f00 100644 --- a/pkg/services/pluginsintegration/config/config.go +++ b/pkg/services/pluginsintegration/config/config.go @@ -47,6 +47,7 @@ func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg, fe grafanaCfg.AngularSupportEnabled, grafanaCfg.GrafanaComURL, grafanaCfg.DisablePlugins, + grafanaCfg.HideAngularDeprecation, ), nil } diff --git a/pkg/services/pluginsintegration/loader/loader_test.go b/pkg/services/pluginsintegration/loader/loader_test.go index 7377280758e..1f3386851ee 100644 --- a/pkg/services/pluginsintegration/loader/loader_test.go +++ b/pkg/services/pluginsintegration/loader/loader_test.go @@ -1303,25 +1303,21 @@ func TestLoader_HideAngularDeprecation(t *testing.T) { cfg *config.Cfg expHideAngularDeprecation bool }{ - {name: `without "hide_angular_deprecation" setting`, cfg: &config.Cfg{ - AngularSupportEnabled: true, - PluginSettings: setting.PluginSettings{}, - Features: featuremgmt.WithFeatures(), - }}, - {name: `with "hide_angular_deprecation" = true`, cfg: &config.Cfg{ - AngularSupportEnabled: true, - PluginSettings: setting.PluginSettings{ - "plugin-id": map[string]string{"hide_angular_deprecation": "true"}, - }, - Features: featuremgmt.WithFeatures(), - }}, - {name: `with "hide_angular_deprecation" = false`, cfg: &config.Cfg{ - AngularSupportEnabled: true, - PluginSettings: setting.PluginSettings{ - "plugin-id": map[string]string{"hide_angular_deprecation": "false"}, - }, - Features: featuremgmt.WithFeatures(), - }}, + {name: "with plugin id in HideAngularDeprecation list", cfg: &config.Cfg{ + AngularSupportEnabled: true, + HideAngularDeprecation: []string{"one-app", "two-panel", "test-datasource", "three-datasource"}, + Features: featuremgmt.WithFeatures(), + }, expHideAngularDeprecation: true}, + {name: "without plugin id in HideAngularDeprecation list", cfg: &config.Cfg{ + AngularSupportEnabled: true, + HideAngularDeprecation: []string{"one-app", "two-panel", "three-datasource"}, + Features: featuremgmt.WithFeatures(), + }, expHideAngularDeprecation: false}, + {name: "with empty HideAngularDeprecation", cfg: &config.Cfg{ + AngularSupportEnabled: true, + HideAngularDeprecation: nil, + Features: featuremgmt.WithFeatures(), + }, expHideAngularDeprecation: false}, } { t.Run(tc.name, func(t *testing.T) { l := newLoaderWithOpts(t, tc.cfg, loaderDepOpts{ diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 45d9e2ae608..85f9cd767f8 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -246,6 +246,7 @@ type Cfg struct { PluginForcePublicKeyDownload bool PluginSkipPublicKeyDownload bool DisablePlugins []string + HideAngularDeprecation []string PluginInstallToken string PluginsCDNURLTemplate string diff --git a/pkg/setting/setting_plugins.go b/pkg/setting/setting_plugins.go index de2e047289f..0bf677d34c2 100644 --- a/pkg/setting/setting_plugins.go +++ b/pkg/setting/setting_plugins.go @@ -48,6 +48,15 @@ func (cfg *Cfg) readPluginSettings(iniFile *ini.File) error { } } + hideAngularDeprecation := pluginsSection.Key("hide_angular_deprecation").MustString("") + for _, id := range strings.Split(hideAngularDeprecation, ",") { + id = strings.TrimSpace(id) + if id == "" { + continue + } + cfg.HideAngularDeprecation = append(cfg.HideAngularDeprecation, id) + } + cfg.PluginCatalogURL = pluginsSection.Key("plugin_catalog_url").MustString("https://grafana.com/grafana/plugins/") cfg.PluginAdminEnabled = pluginsSection.Key("plugin_admin_enabled").MustBool(true) cfg.PluginAdminExternalManageEnabled = pluginsSection.Key("plugin_admin_external_manage_enabled").MustBool(false) diff --git a/pkg/setting/setting_plugins_test.go b/pkg/setting/setting_plugins_test.go index 781cdfbb05e..018e877da00 100644 --- a/pkg/setting/setting_plugins_test.go +++ b/pkg/setting/setting_plugins_test.go @@ -43,18 +43,23 @@ func TestPluginSettings(t *testing.T) { } func Test_readPluginSettings(t *testing.T) { - t.Run("should parse disable_plugins", func(t *testing.T) { + t.Run("should parse plugin ids", func(t *testing.T) { cfg := NewCfg() sec, err := cfg.Raw.NewSection("plugins") require.NoError(t, err) _, err = sec.NewKey("disable_plugins", "plugin1,plugin2") require.NoError(t, err) + _, err = sec.NewKey("plugin_catalog_hidden_plugins", "plugin3") require.NoError(t, err) + _, err = sec.NewKey("hide_angular_deprecation", "a,b,c") + require.NoError(t, err) + err = cfg.readPluginSettings(cfg.Raw) require.NoError(t, err) require.Equal(t, []string{"plugin1", "plugin2"}, cfg.DisablePlugins) require.Equal(t, []string{"plugin3", "plugin1", "plugin2"}, cfg.PluginCatalogHiddenPlugins) + require.Equal(t, []string{"a", "b", "c"}, cfg.HideAngularDeprecation) }) }