RestoreDashboards: Make confirmation text consistent (#92388)

* refactor: change wording

* refactor: change API

* refactor: clean up
This commit is contained in:
Laura Benz 2024-08-27 12:13:48 +02:00 committed by GitHub
parent f1ba609b34
commit 1f35bc8346
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -370,7 +370,7 @@ func (hs *HTTPServer) SoftDeleteDashboard(c *contextmodel.ReqContext) response.R
return response.JSON(http.StatusOK, util.DynMap{
"title": dash.Title,
"message": fmt.Sprintf("Dashboard %s moved to trash", dash.Title),
"message": fmt.Sprintf("Dashboard %s moved to Recently deleted", dash.Title),
"uid": dash.UID,
})
}

View File

@ -6,9 +6,9 @@ import { locationService, config, reportInteraction } from '@grafana/runtime';
import { Modal, ConfirmModal, Button, Text, Space, TextLink } from '@grafana/ui';
import { DashboardModel } from 'app/features/dashboard/state';
import { cleanUpDashboardAndVariables } from 'app/features/dashboard/state/actions';
import { deleteDashboard } from 'app/features/manage-dashboards/state/actions';
import { Trans, t } from '../../../../core/internationalization';
import { useDeleteItemsMutation } from '../../../browse-dashboards/api/browseDashboardsAPI';
type DeleteDashboardModalProps = {
hideModal(): void;
@ -25,6 +25,7 @@ type Props = DeleteDashboardModalProps & ConnectedProps<typeof connector>;
const DeleteDashboardModalUnconnected = ({ hideModal, cleanUpDashboardAndVariables, dashboard }: Props) => {
const isProvisioned = dashboard.meta.provisioned;
const [deleteItems] = useDeleteItemsMutation();
const [, onConfirm] = useAsyncFn(async () => {
reportInteraction('grafana_manage_dashboards_delete_clicked', {
@ -34,7 +35,14 @@ const DeleteDashboardModalUnconnected = ({ hideModal, cleanUpDashboardAndVariabl
source: 'dashboard_settings',
restore_enabled: config.featureToggles.dashboardRestoreUI,
});
await deleteDashboard(dashboard.uid, true);
await deleteItems({
selectedItems: {
dashboard: {
[dashboard.uid]: true,
},
folder: {},
},
});
cleanUpDashboardAndVariables();
hideModal();
locationService.replace('/');