PublicDashboards: Remove publicDashboards FF (#96578)

This commit is contained in:
Juan Cabanas
2024-11-20 11:36:19 -03:00
committed by GitHub
parent 9f53362e3c
commit b8e92aacd2
19 changed files with 78 additions and 121 deletions
+1 -1
View File
@@ -165,7 +165,7 @@ func (hs *HTTPServer) registerRoutes() {
r.Get("/dashboards/*", reqSignedIn, hs.Index)
r.Get("/goto/:uid", reqSignedIn, hs.redirectFromShortURL, hs.Index)
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && hs.Cfg.PublicDashboardsEnabled {
if hs.Cfg.PublicDashboardsEnabled {
// list public dashboards
r.Get("/public-dashboards/list", reqSignedIn, hs.Index)
+1 -1
View File
@@ -101,7 +101,7 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
)
// If public dashboards is enabled and we have a public dashboard, update meta values
if hs.Features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && hs.Cfg.PublicDashboardsEnabled {
if hs.Cfg.PublicDashboardsEnabled {
publicDashboard, err := hs.PublicDashboardsApi.PublicDashboardService.FindByDashboardUid(ctx, c.SignedInUser.GetOrgID(), dash.UID)
if err != nil && !errors.Is(err, publicdashboardModels.ErrPublicDashboardNotFound) {
return response.Error(http.StatusInternalServerError, "Error while retrieving public dashboards", err)
-8
View File
@@ -48,14 +48,6 @@ var (
Owner: grafanaSearchAndStorageSquad,
HideFromAdminPage: true,
},
{
Name: "publicDashboards",
Description: "[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.",
Stage: FeatureStageGeneralAvailability,
Owner: grafanaSharingSquad,
Expression: "true", // enabled by default
AllowSelfServe: true,
},
{
Name: "publicDashboardsEmailSharing",
Description: "Enables public dashboard sharing to be restricted to only allowed emails",
-1
View File
@@ -3,7 +3,6 @@ disableEnvelopeEncryption,GA,@grafana/grafana-as-code,false,false,false
live-service-web-worker,experimental,@grafana/dashboards-squad,false,false,true
queryOverLive,experimental,@grafana/dashboards-squad,false,false,true
panelTitleSearch,preview,@grafana/search-and-storage,false,false,false
publicDashboards,GA,@grafana/sharing-squad,false,false,false
publicDashboardsEmailSharing,preview,@grafana/sharing-squad,false,false,false
publicDashboardsScene,GA,@grafana/sharing-squad,false,false,true
lokiExperimentalStreaming,experimental,@grafana/observability-logs,false,false,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
3 live-service-web-worker experimental @grafana/dashboards-squad false false true
4 queryOverLive experimental @grafana/dashboards-squad false false true
5 panelTitleSearch preview @grafana/search-and-storage false false false
publicDashboards GA @grafana/sharing-squad false false false
6 publicDashboardsEmailSharing preview @grafana/sharing-squad false false false
7 publicDashboardsScene GA @grafana/sharing-squad false false true
8 lokiExperimentalStreaming experimental @grafana/observability-logs false false false
-4
View File
@@ -23,10 +23,6 @@ const (
// Search for dashboards using panel title
FlagPanelTitleSearch = "panelTitleSearch"
// FlagPublicDashboards
// [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.
FlagPublicDashboards = "publicDashboards"
// FlagPublicDashboardsEmailSharing
// Enables public dashboard sharing to be restricted to only allowed emails
FlagPublicDashboardsEmailSharing = "publicDashboardsEmailSharing"
@@ -2833,6 +2833,7 @@
"name": "publicDashboards",
"resourceVersion": "1720021873452",
"creationTimestamp": "2022-04-07T18:30:19Z",
"deletionTimestamp": "2024-11-15T16:38:53Z",
"annotations": {
"grafana.app/updatedTimestamp": "2024-07-03 15:51:13.452477 +0000 UTC"
}
+1 -1
View File
@@ -380,7 +380,7 @@ func (s *ServiceImpl) buildDashboardNavLinks(c *contextmodel.ReqContext) []*navt
Icon: "library-panel",
})
if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagPublicDashboards) && s.cfg.PublicDashboardsEnabled {
if s.cfg.PublicDashboardsEnabled {
dashboardChildNavs = append(dashboardChildNavs, &navtree.NavLink{
Text: "Public dashboards",
Id: "dashboards/public",
+1 -5
View File
@@ -55,14 +55,10 @@ func ProvideApi(
}
// register endpoints if the feature is enabled
if features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) && cfg.PublicDashboardsEnabled {
if cfg.PublicDashboardsEnabled {
api.RegisterAPIEndpoints()
}
if !features.IsEnabledGlobally(featuremgmt.FlagPublicDashboards) {
api.log.Warn("[Deprecated] The publicDashboards feature toggle will be removed in Grafana v11. To disable the public dashboards feature, use the public_dashboards.enabled setting.")
}
return api
}
+6 -13
View File
@@ -74,14 +74,7 @@ func TestAPIFeatureDisabled(t *testing.T) {
cfg := setting.NewCfg()
cfg.PublicDashboardsEnabled = false
service := publicdashboards.NewFakePublicDashboardService(t)
testServer := setupTestServer(t, cfg, service, userAdmin, true)
response := callAPI(testServer, test.Method, test.Path, nil, t)
assert.Equal(t, http.StatusNotFound, response.Code)
})
t.Run(test.Name+" - feature flag disabled", func(t *testing.T) {
service := publicdashboards.NewFakePublicDashboardService(t)
testServer := setupTestServer(t, nil, service, userAdmin, false)
testServer := setupTestServer(t, cfg, service, userAdmin)
response := callAPI(testServer, test.Method, test.Path, nil, t)
assert.Equal(t, http.StatusNotFound, response.Code)
})
@@ -136,7 +129,7 @@ func TestAPIListPublicDashboard(t *testing.T) {
service.On("FindAllWithPagination", mock.Anything, mock.Anything, mock.Anything).
Return(test.Response, test.ResponseErr).Maybe()
testServer := setupTestServer(t, nil, service, test.User, true)
testServer := setupTestServer(t, nil, service, test.User)
response := callAPI(testServer, http.MethodGet, "/api/dashboards/public-dashboards", nil, t)
assert.Equal(t, test.ExpectedHttpResponse, response.Code)
@@ -263,7 +256,7 @@ func TestAPIDeletePublicDashboard(t *testing.T) {
Return(test.ResponseErr)
}
testServer := setupTestServer(t, nil, service, test.User, true)
testServer := setupTestServer(t, nil, service, test.User)
response := callAPI(testServer, http.MethodDelete, fmt.Sprintf("/api/dashboards/uid/%s/public-dashboards/%s", test.DashboardUid, test.PublicDashboardUid), nil, t)
assert.Equal(t, test.ExpectedHttpResponse, response.Code)
@@ -345,7 +338,7 @@ func TestAPIGetPublicDashboard(t *testing.T) {
Return(test.PublicDashboardResult, test.PublicDashboardErr)
}
testServer := setupTestServer(t, nil, service, test.User, true)
testServer := setupTestServer(t, nil, service, test.User)
response := callAPI(
testServer,
@@ -463,7 +456,7 @@ func TestApiCreatePublicDashboard(t *testing.T) {
Return(&PublicDashboard{IsEnabled: true}, test.SaveDashboardErr)
}
testServer := setupTestServer(t, nil, service, test.User, true)
testServer := setupTestServer(t, nil, service, test.User)
response := callAPI(
testServer,
@@ -597,7 +590,7 @@ func TestAPIUpdatePublicDashboard(t *testing.T) {
Return(test.ExpectedResponse, test.ExpectedError)
}
testServer := setupTestServer(t, nil, service, test.User, true)
testServer := setupTestServer(t, nil, service, test.User)
url := fmt.Sprintf("/api/dashboards/uid/%s/public-dashboards/%s", test.DashboardUid, test.PublicDashboardUid)
body := strings.NewReader(test.Body)
@@ -50,7 +50,6 @@ func setupTestServer(
cfg *setting.Cfg,
service publicdashboards.Service,
user *user.SignedInUser,
ffEnabled bool,
) *web.Mux {
t.Helper()
@@ -66,9 +65,6 @@ func setupTestServer(
m.Use(contextProvider(&testContext{user}))
features := featuremgmt.WithFeatures()
if ffEnabled {
features = featuremgmt.WithFeatures(featuremgmt.FlagPublicDashboards)
}
if cfg == nil {
cfg = setting.NewCfg()
@@ -104,7 +104,7 @@ func TestAPIViewPublicDashboard(t *testing.T) {
service.On("GetPublicDashboardForView", mock.Anything, mock.AnythingOfType("string")).
Return(test.DashboardResult, test.Err).Maybe()
testServer := setupTestServer(t, nil, service, anonymousUser, true)
testServer := setupTestServer(t, nil, service, anonymousUser)
response := callAPI(testServer, http.MethodGet,
fmt.Sprintf("/api/public/dashboards/%s", test.AccessToken),
@@ -193,7 +193,7 @@ func TestAPIQueryPublicDashboard(t *testing.T) {
setup := func(enabled bool) (*web.Mux, *publicdashboards.FakePublicDashboardService) {
service := publicdashboards.NewFakePublicDashboardService(t)
testServer := setupTestServer(t, nil, service, anonymousUser, true)
testServer := setupTestServer(t, nil, service, anonymousUser)
return testServer, service
}
@@ -337,7 +337,7 @@ func TestIntegrationUnauthenticatedUserCanGetPubdashPanelQueryData(t *testing.T)
require.NoError(t, err)
// setup test server
server := setupTestServer(t, cfg, pds, anonymousUser, true)
server := setupTestServer(t, cfg, pds, anonymousUser)
resp := callAPI(server, http.MethodPost,
fmt.Sprintf("/api/public/dashboards/%s/panels/1/query", pubdash.AccessToken),
@@ -420,7 +420,7 @@ func TestAPIGetAnnotations(t *testing.T) {
Return(test.Annotations, test.ServiceError).Once()
}
testServer := setupTestServer(t, nil, service, anonymousUser, true)
testServer := setupTestServer(t, nil, service, anonymousUser)
path := fmt.Sprintf("/api/public/dashboards/%s/annotations?from=%s&to=%s", test.AccessToken, test.From, test.To)
response := callAPI(testServer, http.MethodGet, path, nil, t)