From 91a4b8b529c28af33a4d0b5e2544dbc22a127314 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Mon, 20 Mar 2023 09:36:49 -0700 Subject: [PATCH] Chore: remove dashboardsFromStorage (#65058) --- .betterer.results | 5 - .../feature-toggles/index.md | 13 +- .../src/types/featureToggles.gen.ts | 1 - pkg/api/annotations.go | 7 +- pkg/api/api.go | 4 - pkg/services/featuremgmt/registry.go | 7 - pkg/services/featuremgmt/toggles_gen.csv | 1 - pkg/services/featuremgmt/toggles_gen.go | 4 - pkg/services/store/config.go | 28 --- public/app/core/services/backend_srv.ts | 4 - .../SaveDashboard/SaveDashboardDrawer.tsx | 22 +- .../SaveDashboard/forms/SaveToStorageForm.tsx | 223 ------------------ .../dashboard/services/DashboardLoaderSrv.ts | 5 +- public/app/features/storage/StoragePage.tsx | 11 +- public/app/features/storage/storage.ts | 37 --- public/app/routes/routes.tsx | 23 -- 16 files changed, 12 insertions(+), 383 deletions(-) delete mode 100644 public/app/features/dashboard/components/SaveDashboard/forms/SaveToStorageForm.tsx diff --git a/.betterer.results b/.betterer.results index 87a05c981f9..5024b59fac9 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2876,11 +2876,6 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"] ], - "public/app/features/dashboard/components/SaveDashboard/forms/SaveToStorageForm.tsx:5381": [ - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] - ], "public/app/features/dashboard/components/SaveDashboard/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 99ec4435a1f..332f15ca52f 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -100,10 +100,9 @@ Alpha features might be changed or removed without prior notice. The following toggles require explicitly setting Grafana's [app mode]({{< relref "../_index.md/#app_mode" >}}) to 'development' before you can enable this feature toggle. These features tend to be experimental. -| Feature toggle name | Description | -| ----------------------- | --------------------------------------------------- | -| `k8s` | Explore native k8s integrations | -| `dashboardsFromStorage` | Load dashboards from the generic storage interface | -| `grpcServer` | Run GRPC server | -| `entityStore` | SQL-based entity store (requires storage flag also) | -| `nestedFolders` | Enable folder nesting | +| Feature toggle name | Description | +| ------------------- | --------------------------------------------------- | +| `k8s` | Explore native k8s integrations | +| `grpcServer` | Run GRPC server | +| `entityStore` | SQL-based entity store (requires storage flag also) | +| `nestedFolders` | Enable folder nesting | diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 69e65a27c48..2d05363b4ea 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -36,7 +36,6 @@ export interface FeatureToggles { migrationLocking?: boolean; storage?: boolean; k8s?: boolean; - dashboardsFromStorage?: boolean; exploreMixedDatasource?: boolean; tracing?: boolean; newTraceView?: boolean; diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go index 4a76de42661..92a8856e33a 100644 --- a/pkg/api/annotations.go +++ b/pkg/api/annotations.go @@ -13,7 +13,6 @@ import ( "github.com/grafana/grafana/pkg/services/annotations" contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model" "github.com/grafana/grafana/pkg/services/dashboards" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/guardian" "github.com/grafana/grafana/pkg/services/org" "github.com/grafana/grafana/pkg/services/user" @@ -53,11 +52,7 @@ func (hs *HTTPServer) GetAnnotations(c *contextmodel.ReqContext) response.Respon dq := dashboards.GetDashboardQuery{UID: query.DashboardUID, OrgID: c.OrgID} dqResult, err := hs.DashboardService.GetDashboard(c.Req.Context(), &dq) if err != nil { - if hs.Features.IsEnabled(featuremgmt.FlagDashboardsFromStorage) { - // OK... the storage UIDs do not (yet?) exist in the DashboardService - } else { - return response.Error(http.StatusBadRequest, "Invalid dashboard UID in annotation request", err) - } + return response.Error(http.StatusBadRequest, "Invalid dashboard UID in annotation request", err) } else { query.DashboardID = dqResult.ID } diff --git a/pkg/api/api.go b/pkg/api/api.go index 3e1343731a9..257786d55ae 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -157,10 +157,6 @@ func (hs *HTTPServer) registerRoutes() { r.Get("/dashboards/*", reqSignedIn, hs.Index) r.Get("/goto/:uid", reqSignedIn, hs.redirectFromShortURL, hs.Index) - if hs.Features.IsEnabled(featuremgmt.FlagDashboardsFromStorage) { - r.Get("/g/*", reqSignedIn, hs.Index) - } - if hs.Features.IsEnabled(featuremgmt.FlagPublicDashboards) { // list public dashboards r.Get("/public-dashboards/list", reqSignedIn, hs.Index) diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 5f4a9189b4e..d04d8904abb 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -121,13 +121,6 @@ var ( RequiresDevMode: true, Owner: grafanaAppPlatformSquad, }, - { - Name: "dashboardsFromStorage", - Description: "Load dashboards from the generic storage interface", - State: FeatureStateAlpha, - RequiresDevMode: true, // Also a gate on automatic git storage (for now) - Owner: grafanaAppPlatformSquad, - }, { Name: "exploreMixedDatasource", Description: "Enable mixed datasource in Explore", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index 5032651915a..ccb495f672c 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -17,7 +17,6 @@ featureHighlights,stable,@grafana/grafana-as-code,false,false,false,false migrationLocking,beta,@grafana/backend-platform,false,false,false,false storage,alpha,@grafana/grafana-app-platform-squad,false,false,false,false k8s,alpha,@grafana/grafana-app-platform-squad,true,false,false,false -dashboardsFromStorage,alpha,@grafana/grafana-app-platform-squad,true,false,false,false exploreMixedDatasource,alpha,@grafana/explore-squad,false,false,false,true tracing,alpha,@grafana/user-essentials,false,false,false,true newTraceView,alpha,@grafana/observability-traces-and-profiling,false,false,false,true diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index fdd3d16d1d8..13353e43d82 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -79,10 +79,6 @@ const ( // Explore native k8s integrations FlagK8S = "k8s" - // FlagDashboardsFromStorage - // Load dashboards from the generic storage interface - FlagDashboardsFromStorage = "dashboardsFromStorage" - // FlagExploreMixedDatasource // Enable mixed datasource in Explore FlagExploreMixedDatasource = "exploreMixedDatasource" diff --git a/pkg/services/store/config.go b/pkg/services/store/config.go index 3416649d963..7fc6737f0c9 100644 --- a/pkg/services/store/config.go +++ b/pkg/services/store/config.go @@ -44,34 +44,6 @@ func LoadStorageConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles) (* changed = true } - if g.Roots == nil && features.IsEnabled(featuremgmt.FlagDashboardsFromStorage) { - g.Roots = append(g.Roots, RootStorageConfig{ - Type: "git", - Prefix: "it-A", - Name: "Repository that requires pull requests", - Git: &StorageGitConfig{ - Remote: "https://github.com/grafana/hackathon-2022-03-git-dash-A", - Branch: "main", - Root: "dashboards", // the dashboard files - RequirePullRequest: true, - AccessToken: "$GRAFANA_STORAGE_GITHUB_ACCESS_TOKEN", - }, - }) - g.Roots = append(g.Roots, RootStorageConfig{ - Type: "git", - Prefix: "it-B", - Name: "Another repo (can push to main)", - Git: &StorageGitConfig{ - Remote: "https://github.com/grafana/hackathon-2022-03-git-dash-B", - Branch: "main", - Root: "dashboards", // the dashboard files - RequirePullRequest: false, - AccessToken: "$GRAFANA_STORAGE_GITHUB_ACCESS_TOKEN", - }, - }) - changed = true - } - g.filepath = fpath // Also configured from ini files diff --git a/public/app/core/services/backend_srv.ts b/public/app/core/services/backend_srv.ts index 81b563fbbdd..f2785d4c0b0 100644 --- a/public/app/core/services/backend_srv.ts +++ b/public/app/core/services/backend_srv.ts @@ -20,7 +20,6 @@ import { getConfig } from 'app/core/config'; import { loadUrlToken } from 'app/core/utils/urlToken'; import { DashboardModel } from 'app/features/dashboard/state'; import { DashboardSearchItem } from 'app/features/search/types'; -import { getGrafanaStorage } from 'app/features/storage/storage'; import { TokenRevokedModal } from 'app/features/users/TokenRevokedModal'; import { DashboardDTO, FolderDTO } from 'app/types'; @@ -456,9 +455,6 @@ export class BackendSrv implements BackendService { } getDashboardByUid(uid: string): Promise { - if (uid.indexOf('/') > 0 && config.featureToggles.dashboardsFromStorage) { - return getGrafanaStorage().getDashboard(uid); - } return this.get(`/api/dashboards/uid/${uid}`); } diff --git a/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDrawer.tsx b/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDrawer.tsx index da46a82f6d6..a411d3e67ae 100644 --- a/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDrawer.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/SaveDashboardDrawer.tsx @@ -13,16 +13,14 @@ import { SaveDashboardErrorProxy } from './SaveDashboardErrorProxy'; import { SaveDashboardAsForm } from './forms/SaveDashboardAsForm'; import { SaveDashboardForm } from './forms/SaveDashboardForm'; import { SaveProvisionedDashboardForm } from './forms/SaveProvisionedDashboardForm'; -import { SaveToStorageForm } from './forms/SaveToStorageForm'; import { SaveDashboardData, SaveDashboardModalProps, SaveDashboardOptions } from './types'; import { useDashboardSave } from './useDashboardSave'; export const SaveDashboardDrawer = ({ dashboard, onDismiss, onSaveSuccess, isCopy }: SaveDashboardModalProps) => { const [options, setOptions] = useState({}); - const isFromStorage = config.featureToggles.dashboardsFromStorage && dashboard.uid?.indexOf('/') > 0; - const isProvisioned = dashboard.meta.provisioned && !isFromStorage; - const isNew = dashboard.version === 0 && !isFromStorage; + const isProvisioned = dashboard.meta.provisioned; + const isNew = dashboard.version === 0; const previous = useAsync(async () => { if (isNew) { @@ -82,22 +80,6 @@ export const SaveDashboardDrawer = ({ dashboard, onDismiss, onSaveSuccess, isCop ); } - if (isFromStorage) { - return ( - - ); - } - if (isNew || isCopy) { return ( dashboard.hasTimeChanged(), [dashboard]); - const hasVariableChanged = useMemo(() => dashboard.hasVariableValuesChanged(), [dashboard]); - const [saving, setSaving] = useState(false); - const [response, setResponse] = useState(); - const [path, setPath] = useState(dashboard.uid); - const [workflow, setWorkflow] = useState(WorkflowID.Save); - const saveText = useMemo(() => { - switch (workflow) { - case WorkflowID.PR: - return 'Create PR'; - case WorkflowID.Push: - return 'Push'; - } - console.log('???', workflow); - return 'Save'; - }, [workflow]); - - const item = useAsync(async () => { - const opts = await getGrafanaStorage().getOptions(dashboard.uid); - setWorkflow(opts.workflows[0]?.value ?? WorkflowID.Save); - return opts; - }, [dashboard.uid]); - - if (item.error) { - return
Error loading workflows
; - } - - if (item.loading || !item.value) { - return ; - } - - if (response) { - return ( -
- {response.url && ( -
-

View pull request

- {response.url} -
- )} - -
{JSON.stringify(response)}
- - - - -
- ); - } - - let options = props.options; - const workflows = item.value?.workflows ?? []; - const canSave = saveModel.hasChanges || isNew || isCopy; - - return ( -
{ - if (!onSubmit) { - return; - } - setSaving(true); - - // Save dashboard without the UID - let { uid, ...body } = saveModel.clone; - if (isNew || isCopy) { - uid = path; - if (!uid.endsWith('-dash.json')) { - uid += '-dash.json'; - } - } - const rsp = await getGrafanaStorage().write(uid, { - body, - kind: 'dashboard', - title: data.title, - message: data.message, - workflow: workflow, - }); - - console.log('GOT', rsp); - if (rsp.code === 200) { - if (options.saveVariables) { - dashboard.resetOriginalVariables(); - } - if (options.saveTimerange) { - dashboard.resetOriginalTime(); - } - - if (!rsp.pending) { - // should close - onSuccess(); - - // Need to update the URL - if (isNew || isCopy) { - locationService.push(`/g/${uid}`); - } - } - } else { - setSaving(false); - } - setResponse(rsp); - }} - > - {({ register, errors }) => ( - - - {hasTimeChanged && ( - - onOptionsChange({ - ...options, - saveTimerange: !options.saveTimerange, - }) - } - label="Save current time range as dashboard default" - aria-label={selectors.pages.SaveDashboardModal.saveTimerange} - /> - )} - {hasVariableChanged && ( - - onOptionsChange({ - ...options, - saveVariables: !options.saveVariables, - }) - } - label="Save current variable values as dashboard default" - aria-label={selectors.pages.SaveDashboardModal.saveVariables} - /> - )} - - - {(isNew || isCopy) && ( - - setPath(v.currentTarget.value)} - /> - - )} - - {!isJustSave(item.value) && ( - - - - )} - - {workflow === WorkflowID.PR && ( - - - - )} - - -