Dashboards: Remove dummy trim dashboard api (#77249)

Co-authored-by: nikimanoledaki <niki.manoledaki@grafana.com>
This commit is contained in:
Ryan McKinley
2023-11-02 08:35:14 -07:00
committed by GitHub
parent e714c9303e
commit 45d59cf31b
19 changed files with 12 additions and 208 deletions

View File

@@ -471,7 +471,6 @@ func (hs *HTTPServer) registerRoutes() {
dashboardRoute.Post("/calculate-diff", authorize(ac.EvalPermission(dashboards.ActionDashboardsWrite)), routing.Wrap(hs.CalculateDashboardDiff))
dashboardRoute.Post("/validate", authorize(ac.EvalPermission(dashboards.ActionDashboardsWrite)), routing.Wrap(hs.ValidateDashboard))
dashboardRoute.Post("/trim", routing.Wrap(hs.TrimDashboard))
dashboardRoute.Post("/db", authorize(ac.EvalAny(ac.EvalPermission(dashboards.ActionDashboardsCreate), ac.EvalPermission(dashboards.ActionDashboardsWrite))), routing.Wrap(hs.PostDashboard))
dashboardRoute.Get("/home", routing.Wrap(hs.GetHomeDashboard))

View File

@@ -68,32 +68,6 @@ func dashboardGuardianResponse(err error) response.Response {
return response.Error(http.StatusForbidden, "Access denied to this dashboard", nil)
}
// swagger:route POST /dashboards/trim dashboards trimDashboard
//
// Trim defaults from dashboard.
//
// Responses:
// 200: trimDashboardResponse
// 401: unauthorisedError
// 500: internalServerError
func (hs *HTTPServer) TrimDashboard(c *contextmodel.ReqContext) response.Response {
cmd := dashboards.TrimDashboardCommand{}
if err := web.Bind(c.Req, &cmd); err != nil {
return response.Error(http.StatusBadRequest, "bad request data", err)
}
dash := cmd.Dashboard
meta := cmd.Meta
// TODO temporarily just return the input as a no-op while we convert to thema calls
dto := dtos.TrimDashboardFullWithMeta{
Dashboard: dash,
Meta: meta,
}
c.TimeRequest(metrics.MApiDashboardGet)
return response.JSON(http.StatusOK, dto)
}
// swagger:route GET /dashboards/uid/{uid} dashboards getDashboardByUID
//
// Get dashboard by uid.
@@ -1233,13 +1207,6 @@ type CalcDashboardDiffParams struct {
}
}
// swagger:parameters trimDashboard
type TrimDashboardParams struct {
// in:body
// required:true
Body dashboards.TrimDashboardCommand
}
// swagger:response dashboardResponse
type DashboardResponse struct {
// The response message
@@ -1315,12 +1282,6 @@ type CalculateDashboardDiffResponse struct {
Body []byte `json:"body"`
}
// swagger:response trimDashboardResponse
type TrimDashboardResponse struct {
// in: body
Body dtos.TrimDashboardFullWithMeta `json:"body"`
}
// swagger:response getHomeDashboardResponse
type GetHomeDashboardResponse struct {
// in: body

View File

@@ -51,11 +51,6 @@ type DashboardFullWithMeta struct {
Dashboard *simplejson.Json `json:"dashboard"`
}
type TrimDashboardFullWithMeta struct {
Meta *simplejson.Json `json:"meta"`
Dashboard *simplejson.Json `json:"dashboard"`
}
type DashboardRedirect struct {
RedirectUri string `json:"redirectUri"`
}

View File

@@ -9,12 +9,6 @@ package featuremgmt
var (
// Register each toggle here
standardFeatureFlags = []FeatureFlag{
{
Name: "trimDefaults",
Description: "Use cue schema to remove values that will be applied automatically",
Stage: FeatureStagePublicPreview,
Owner: grafanaAsCodeSquad,
},
{
Name: "disableEnvelopeEncryption",
Description: "Disable envelope encryption (emergency only)",

View File

@@ -1,5 +1,4 @@
Name,Stage,Owner,requiresDevMode,RequiresLicense,RequiresRestart,FrontendOnly
trimDefaults,preview,@grafana/grafana-as-code,false,false,false,false
disableEnvelopeEncryption,GA,@grafana/grafana-as-code,false,false,false,false
live-service-web-worker,experimental,@grafana/grafana-app-platform-squad,false,false,false,true
queryOverLive,experimental,@grafana/grafana-app-platform-squad,false,false,false,true
1 Name Stage Owner requiresDevMode RequiresLicense RequiresRestart FrontendOnly
trimDefaults preview @grafana/grafana-as-code false false false false
2 disableEnvelopeEncryption GA @grafana/grafana-as-code false false false false
3 live-service-web-worker experimental @grafana/grafana-app-platform-squad false false false true
4 queryOverLive experimental @grafana/grafana-app-platform-squad false false false true

View File

@@ -7,10 +7,6 @@
package featuremgmt
const (
// FlagTrimDefaults
// Use cue schema to remove values that will be applied automatically
FlagTrimDefaults = "trimDefaults"
// FlagDisableEnvelopeEncryption
// Disable envelope encryption (emergency only)
FlagDisableEnvelopeEncryption = "disableEnvelopeEncryption"

View File

@@ -9,7 +9,6 @@ import (
func TestFeatureUsageStats(t *testing.T) {
featureManagerWithAllFeatures := WithFeatures(
"trimDefaults",
"database_metrics",
"live-config",
"UPPER_SNAKE_CASE",
@@ -17,7 +16,6 @@ func TestFeatureUsageStats(t *testing.T) {
)
require.Equal(t, map[string]any{
"stats.features.trim_defaults.count": 1,
"stats.features.database_metrics.count": 1,
"stats.features.live_config.count": 1,
"stats.features.upper_snake_case.count": 1,