PublicDashboards: Add setting to disable the feature (#78894)

* Replace feature toggle with configuration setting

* Fix permission alert

* Update documentation

* Add back feature toggle

* revert unwanted commited changes

* fix tests

* run prettier

* Update SharePublicDashboard.test.tsx

* fix linter and frontend tests

* Update api.go

* Apply docs edit from code review

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>

* Update index.md

* Update docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* add isPublicDashboardsEnabled + test

* fix test

* update ff description in registry

* move isPublicDashboardsEnabled

* revert getConfig() update

---------

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
This commit is contained in:
Agnès Toulet
2023-12-19 11:43:54 +01:00
committed by GitHub
co-authored by Isabel Christopher Moyer
parent ef60c90dfa
commit fdaf6e3f2e
30 changed files with 159 additions and 137 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ func (hs *HTTPServer) registerRoutes() {
r.Get("/d-embed", reqSignedIn, middleware.AddAllowEmbeddingHeader(), hs.Index)
}
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) {
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && hs.Cfg.PublicDashboardsEnabled {
// list public dashboards
r.Get("/public-dashboards/list", reqSignedIn, hs.Index)
+2 -3
View File
@@ -90,9 +90,8 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
err error
)
// If public dashboards is enabled and we have a public dashboard, update meta
// values
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) {
// If public dashboards is enabled and we have a public dashboard, update meta values
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && hs.Cfg.PublicDashboardsEnabled {
publicDashboard, err := hs.PublicDashboardsApi.PublicDashboardService.FindByDashboardUid(c.Req.Context(), c.SignedInUser.GetOrgID(), dash.UID)
if err != nil && !errors.Is(err, publicdashboardModels.ErrPublicDashboardNotFound) {
return response.Error(http.StatusInternalServerError, "Error while retrieving public dashboards", err)
+1 -1
View File
@@ -272,7 +272,7 @@ func TestHTTPServer_DeleteDashboardByUID_AccessControl(t *testing.T) {
pubDashService := publicdashboards.NewFakePublicDashboardService(t)
pubDashService.On("DeleteByDashboard", mock.Anything, mock.Anything).Return(nil).Maybe()
middleware := publicdashboards.NewFakePublicDashboardMiddleware(t)
hs.PublicDashboardsApi = api.ProvideApi(pubDashService, nil, hs.AccessControl, featuremgmt.WithFeatures(), middleware)
hs.PublicDashboardsApi = api.ProvideApi(pubDashService, nil, hs.AccessControl, featuremgmt.WithFeatures(), middleware, hs.Cfg)
guardian.InitAccessControlGuardian(hs.Cfg, hs.AccessControl, hs.DashboardService)
})
+1
View File
@@ -238,6 +238,7 @@ type FrontendSettingsDTO struct {
GeomapDisableCustomBaseLayer bool `json:"geomapDisableCustomBaseLayer"`
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
PublicDashboardsEnabled bool `json:"publicDashboardsEnabled"`
DateFormats setting.DateFormats `json:"dateFormats,omitempty"`
+1
View File
@@ -158,6 +158,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
SecureSocksDSProxyEnabled: hs.Cfg.SecureSocksDSProxy.Enabled && hs.Cfg.SecureSocksDSProxy.ShowUI,
DisableFrontendSandboxForPlugins: hs.Cfg.DisableFrontendSandboxForPlugins,
PublicDashboardAccessToken: c.PublicDashboardAccessToken,
PublicDashboardsEnabled: hs.Cfg.PublicDashboardsEnabled,
SharedWithMeFolderUID: folder.SharedWithMeFolderUID,
BuildInfo: dtos.FrontendSettingsBuildInfoDTO{