Skip to content

Commit fdaf6e3

Browse files
AgnesTouletimatwawanachri2547
authored
PublicDashboards: Add setting to disable the feature (grafana#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 <[email protected]> * Update index.md * Update docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md Co-authored-by: Agnès Toulet <[email protected]> * Update docs/sources/setup-grafana/configure-grafana/_index.md Co-authored-by: Agnès Toulet <[email protected]> * add isPublicDashboardsEnabled + test * fix test * update ff description in registry * move isPublicDashboardsEnabled * revert getConfig() update --------- Co-authored-by: Isabel <[email protected]> Co-authored-by: Christopher Moyer <[email protected]>
1 parent ef60c90 commit fdaf6e3

File tree

30 files changed

+159
-137
lines changed

30 files changed

+159
-137
lines changed

conf/defaults.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,3 +1762,8 @@ hidden_toggles =
17621762

17631763
# Disables updating specific feature toggles in the feature management page
17641764
read_only_toggles =
1765+
1766+
#################################### Public Dashboards #####################################
1767+
[public_dashboards]
1768+
# Set to false to disable public dashboards
1769+
enabled = true

conf/sample.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,3 +1615,9 @@
16151615
;hidden_toggles =
16161616
# Disable updating specific feature toggles in the feature management page
16171617
;read_only_toggles =
1618+
1619+
#################################### Public Dashboards #####################################
1620+
[public_dashboards]
1621+
# Set to false to disable public dashboards
1622+
;enabled = true
1623+

docs/sources/dashboards/assess-dashboard-usage/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Dashboard insights show the following information:
6262

6363
{{% admonition type="note" %}}
6464

65-
If you've enabled the `publicDashboards` feature toggle, you'll also see a Public dashboards tab in your analytics.
65+
If public dashboards are [enabled]({{< relref "../../setup-grafana/configure-grafana/#public_dashboards" >}}), you'll also see a **Public dashboards** tab in your analytics.
6666

6767
{{% /admonition %}}
6868

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,3 +2538,11 @@ Move an app plugin (referenced by its id), including all its pages, to a specifi
25382538

25392539
Move an individual app plugin page (referenced by its `path` field) to a specific navigation section.
25402540
Format: `<pageUrl> = <sectionId> <sortWeight>`
2541+
2542+
## [public_dashboards]
2543+
2544+
This section configures the [public dashboards]({{< relref "../../dashboards/dashboard-public" >}}) feature.
2545+
2546+
### enabled
2547+
2548+
Set this to `false` to disable the public dashboards feature. This prevents users from creating new public dashboards and disables existing ones.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Some features are enabled by default. You can disable these feature by setting t
2222
| Feature toggle name | Description | Enabled by default |
2323
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
2424
| `disableEnvelopeEncryption` | Disable envelope encryption (emergency only) | |
25-
| `publicDashboards` | Enables public access to dashboards | Yes |
25+
| `publicDashboards` | [Deprecated] Public dashboards are now enabled by default; to disable them, use the configuration setting. This feature toggle will be removed in the next major version. | Yes |
2626
| `featureHighlights` | Highlight Grafana Enterprise features | |
2727
| `exploreContentOutline` | Content outline sidebar | Yes |
2828
| `newVizTooltips` | New visualizations tooltips UX | |

docs/sources/setup-grafana/installation/docker/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ docker run -d -p 3000:3000 --name=grafana \
117117
Grafana supports specifying custom configuration settings using [environment variables]({{< relref "../../../setup-grafana/configure-grafana#override-configuration-with-environment-variables" >}}).
118118

119119
```bash
120-
# enabling public dashboard feature
120+
# enable debug logs
121121

122122
docker run -d -p 3000:3000 --name=grafana \
123-
-e "GF_FEATURE_TOGGLES_ENABLE=publicDashboards" \
123+
-e "GF_LOG_LEVEL=debug" \
124124
grafana/grafana-enterprise
125125
```
126126

packages/grafana-data/src/types/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export interface BootData {
148148
*/
149149
export interface GrafanaConfig {
150150
publicDashboardAccessToken?: string;
151+
publicDashboardsEnabled: boolean;
151152
snapshotEnabled: boolean;
152153
datasources: { [str: string]: DataSourceInstanceSettings };
153154
panels: { [key: string]: PanelPluginMeta };

packages/grafana-runtime/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export type AppPluginConfig = {
3636

3737
export class GrafanaBootConfig implements GrafanaConfig {
3838
publicDashboardAccessToken?: string;
39+
publicDashboardsEnabled = true;
3940
snapshotEnabled = true;
4041
datasources: { [str: string]: DataSourceInstanceSettings } = {};
4142
panels: { [key: string]: PanelPluginMeta } = {};

pkg/api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (hs *HTTPServer) registerRoutes() {
161161
r.Get("/d-embed", reqSignedIn, middleware.AddAllowEmbeddingHeader(), hs.Index)
162162
}
163163

164-
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) {
164+
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && hs.Cfg.PublicDashboardsEnabled {
165165
// list public dashboards
166166
r.Get("/public-dashboards/list", reqSignedIn, hs.Index)
167167

pkg/api/dashboard.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
9090
err error
9191
)
9292

93-
// If public dashboards is enabled and we have a public dashboard, update meta
94-
// values
95-
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) {
93+
// If public dashboards is enabled and we have a public dashboard, update meta values
94+
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && hs.Cfg.PublicDashboardsEnabled {
9695
publicDashboard, err := hs.PublicDashboardsApi.PublicDashboardService.FindByDashboardUid(c.Req.Context(), c.SignedInUser.GetOrgID(), dash.UID)
9796
if err != nil && !errors.Is(err, publicdashboardModels.ErrPublicDashboardNotFound) {
9897
return response.Error(http.StatusInternalServerError, "Error while retrieving public dashboards", err)

0 commit comments

Comments
 (0)