From f6a83432a5f925b863b633ca3039525a7a76301f Mon Sep 17 00:00:00 2001 From: Laura Benz <48948963+L-M-K-B@users.noreply.github.com> Date: Tue, 28 May 2024 10:26:06 +0200 Subject: [PATCH] RestoreDashboards: Create trash section (#88278) * feat: add feature toggle to docs * feat: create page in BE * feat: create page in FE * refactor: set feat toggle as a condition * refactor * refactor * refactor * feat: add permission conditions * refactor * feat: add subtitle to translations * feat: add to codeowners * refactor: fix docs situation * refactor * Merge main branch into feat branch --- .github/CODEOWNERS | 1 + .../feature-toggles/index.md | 1 + pkg/services/featuremgmt/registry.go | 1 - pkg/services/featuremgmt/toggles_gen.json | 59 ++++++++++++------- pkg/services/navtree/navtreeimpl/navtree.go | 9 +++ .../app/core/utils/navBarItem-translations.ts | 7 +++ .../app/features/trash-section/TrashPage.tsx | 15 +++++ public/app/routes/routes.tsx | 7 +++ public/locales/en-US/grafana.json | 4 ++ public/locales/pseudo-LOCALE/grafana.json | 4 ++ 10 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 public/app/features/trash-section/TrashPage.tsx diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 067eeda60ef..4a514aafdb9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -435,6 +435,7 @@ playwright.config.ts @grafana/plugins-platform-frontend /public/app/features/transformers/timeSeriesTable/ @grafana/dataviz-squad @grafana/app-o11y-visualizations /public/app/features/users/ @grafana/identity-access-team /public/app/features/variables/ @grafana/dashboards-squad +/public/app/features/trash-section/ @grafana/grafana-frontend-platform /public/app/plugins/panel/alertlist/ @grafana/alerting-frontend /public/app/plugins/panel/annolist/ @grafana/grafana-frontend-platform /public/app/plugins/panel/barchart/ @grafana/dataviz-squad 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 193edc72016..1d19ed1f577 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -189,6 +189,7 @@ Experimental features might be changed or removed without prior notice. | `newDashboardSharingComponent` | Enables the new sharing drawer design | | `alertingListViewV2` | Enables the new alert list view design | | `notificationBanner` | Enables the notification banner UI and API | +| `dashboardRestore` | Enables deleted dashboard restore feature | ## Development feature toggles diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 3779a22cf4b..25ed32b6d2d 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -1279,7 +1279,6 @@ var ( Description: "Enables deleted dashboard restore feature", Stage: FeatureStageExperimental, Owner: grafanaFrontendPlatformSquad, - HideFromDocs: true, HideFromAdminPage: true, }, { diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index 4665163f218..9e750c36983 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -588,15 +588,17 @@ { "metadata": { "name": "dashboardRestore", - "resourceVersion": "1716448665531", - "creationTimestamp": "2024-05-23T07:17:45Z" + "resourceVersion": "1716564259132", + "creationTimestamp": "2024-05-23T07:17:45Z", + "annotations": { + "grafana.app/updatedTimestamp": "2024-05-24 15:24:19.132272 +0000 UTC" + } }, "spec": { "description": "Enables deleted dashboard restore feature", "stage": "experimental", "codeowner": "@grafana/grafana-frontend-platform", - "hideFromAdminPage": true, - "hideFromDocs": true + "hideFromAdminPage": true } }, { @@ -2204,26 +2206,19 @@ }, { "metadata": { - "name": "influxdbRunQueriesInParallel", - "resourceVersion": "1716448665531", - "creationTimestamp": "2024-05-23T07:17:45Z" - }, - "spec": { - "description": "Enables running InfluxDB Influxql queries in parallel", - "stage": "privatePreview", - "codeowner": "@grafana/observability-metrics" - } - }, - { - "metadata": { - "name": "disableSSEDataplane", - "resourceVersion": "1716448665531", - "creationTimestamp": "2024-05-23T07:17:45Z" + "name": "dashboardRestore", + "resourceVersion": "1716563559003", + "creationTimestamp": "2024-02-20T18:50:41Z", + "deletionTimestamp": "2024-05-24T15:24:19Z", + "annotations": { + "grafana.app/updatedTimestamp": "2024-05-24 15:12:39.003245 +0000 UTC" + } }, "spec": { "description": "Disables dataplane specific processing in server side expressions.", "stage": "experimental", - "codeowner": "@grafana/observability-metrics" + "codeowner": "@grafana/grafana-frontend-platform", + "hideFromAdminPage": true } }, { @@ -2265,6 +2260,30 @@ "hideFromAdminPage": true, "hideFromDocs": true } + }, + { + "metadata": { + "name": "disableSSEDataplane", + "resourceVersion": "1716816471156", + "creationTimestamp": "2024-05-27T13:27:51Z" + }, + "spec": { + "description": "Disables dataplane specific processing in server side expressions.", + "stage": "experimental", + "codeowner": "@grafana/observability-metrics" + } + }, + { + "metadata": { + "name": "influxdbRunQueriesInParallel", + "resourceVersion": "1716816471156", + "creationTimestamp": "2024-05-27T13:27:51Z" + }, + "spec": { + "description": "Enables running InfluxDB Influxql queries in parallel", + "stage": "privatePreview", + "codeowner": "@grafana/observability-metrics" + } } ] } \ No newline at end of file diff --git a/pkg/services/navtree/navtreeimpl/navtree.go b/pkg/services/navtree/navtreeimpl/navtree.go index 4647808a04c..826d367c82f 100644 --- a/pkg/services/navtree/navtreeimpl/navtree.go +++ b/pkg/services/navtree/navtreeimpl/navtree.go @@ -353,6 +353,15 @@ func (s *ServiceImpl) buildDashboardNavLinks(c *contextmodel.ReqContext) []*navt Icon: "library-panel", }) } + + if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagDashboardRestore) && hasAccess(ac.EvalPermission(dashboards.ActionDashboardsDelete)) { + dashboardChildNavs = append(dashboardChildNavs, &navtree.NavLink{ + Text: "Trash", + SubTitle: "Any items remaining in the Trash for more than 30 days will be automatically deleted", + Id: "dashboards/trash", + Url: s.cfg.AppSubURL + "/dashboard/trash", + }) + } } if hasAccess(ac.EvalPermission(dashboards.ActionDashboardsCreate)) { diff --git a/public/app/core/utils/navBarItem-translations.ts b/public/app/core/utils/navBarItem-translations.ts index faafa9b00f9..9a7dc478d30 100644 --- a/public/app/core/utils/navBarItem-translations.ts +++ b/public/app/core/utils/navBarItem-translations.ts @@ -40,6 +40,8 @@ export function getNavTitle(navId: string | undefined) { return t('nav.reporting.title', 'Reporting'); case 'dashboards/public': return t('nav.public.title', 'Public dashboards'); + case 'dashboards/trash': + return t('nav.trash.title', 'Trash'); case 'dashboards/new': return t('nav.new-dashboard.title', 'New dashboard'); case 'dashboards/folder/new': @@ -206,6 +208,11 @@ export function getNavSubTitle(navId: string | undefined) { ); case 'dashboards/library-panels': return t('nav.library-panels.subtitle', 'Reusable panels that can be added to multiple dashboards'); + case 'dashboards/trash': + return t( + 'nav.trash.subtitle', + 'Any items remaining in the Trash for more than 30 days will be automatically deleted' + ); case 'alerting': return t('nav.alerting.subtitle', 'Learn about problems in your systems moments after they occur'); case 'alerting-upgrade': diff --git a/public/app/features/trash-section/TrashPage.tsx b/public/app/features/trash-section/TrashPage.tsx new file mode 100644 index 00000000000..cfeca460d7e --- /dev/null +++ b/public/app/features/trash-section/TrashPage.tsx @@ -0,0 +1,15 @@ +import React from 'react'; + +import { Page } from 'app/core/components/Page/Page'; + +const TrashPage = () => { + return ( + + +

page content

+
+
+ ); +}; + +export default TrashPage; diff --git a/public/app/routes/routes.tsx b/public/app/routes/routes.tsx index 423e3ce9fff..1df805c21d4 100644 --- a/public/app/routes/routes.tsx +++ b/public/app/routes/routes.tsx @@ -435,6 +435,13 @@ export function getAppRoutes(): RouteDescriptor[] { () => import(/* webpackChunkName: "SnapshotListPage" */ 'app/features/manage-dashboards/SnapshotListPage') ), }, + config.featureToggles.dashboardRestore && { + path: '/dashboard/trash', + roles: () => contextSrv.evaluatePermission([AccessControlAction.DashboardsDelete]), + component: SafeDynamicImport( + () => import(/* webpackChunkName: "TrashPage" */ 'app/features/trash-section/TrashPage') + ), + }, { path: '/playlists', component: SafeDynamicImport( diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index bb7a7713ae4..ed87ba04fed 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -1179,6 +1179,10 @@ "subtitle": "Optimize performance with k6 and Synthetic Monitoring insights", "title": "Testing & synthetics" }, + "trash": { + "subtitle": "Any items remaining in the Trash for more than 30 days will be automatically deleted", + "title": "Trash" + }, "upgrading": { "title": "Stats and license" }, diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json index 59fc5847e61..492ed9100a4 100644 --- a/public/locales/pseudo-LOCALE/grafana.json +++ b/public/locales/pseudo-LOCALE/grafana.json @@ -1179,6 +1179,10 @@ "subtitle": "Øpŧįmįžę pęřƒőřmäʼnčę ŵįŧĥ ĸ6 äʼnđ Ŝyʼnŧĥęŧįč Mőʼnįŧőřįʼnģ įʼnşįģĥŧş", "title": "Ŧęşŧįʼnģ & şyʼnŧĥęŧįčş" }, + "trash": { + "subtitle": "Åʼny įŧęmş řęmäįʼnįʼnģ įʼn ŧĥę Ŧřäşĥ ƒőř mőřę ŧĥäʼn 30 đäyş ŵįľľ þę äūŧőmäŧįčäľľy đęľęŧęđ", + "title": "Ŧřäşĥ" + }, "upgrading": { "title": "Ŝŧäŧş äʼnđ ľįčęʼnşę" },