Skip to content

Commit 59db383

Browse files
authored
feat(dashboards): Add a confirm on dashboard deletion (#29971)
* feat(dashboards): Add a confirm on dashboard deletion - Show a message to confirm that deletion is desired on the dashboard management page * fix: tests
1 parent 6fd2793 commit 59db383

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

static/app/views/dashboardsV2/manage/dashboardList.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from 'app/actionCreators/dashboards';
1818
import {addErrorMessage, addSuccessMessage} from 'app/actionCreators/indicator';
1919
import {Client} from 'app/api';
20+
import {openConfirmModal} from 'app/components/confirm';
2021
import EmptyStateWarning from 'app/components/emptyStateWarning';
2122
import MenuItem from 'app/components/menuItem';
2223
import Pagination from 'app/components/pagination';
@@ -141,11 +142,15 @@ function DashboardList({
141142
<ContextMenu>
142143
<MenuItem
143144
data-test-id="dashboard-delete"
145+
disabled={dashboards.length <= 1}
144146
onClick={event => {
145147
event.preventDefault();
146-
handleDelete(dashboard);
148+
openConfirmModal({
149+
message: t('Are you sure you want to delete this dashboard?'),
150+
priority: 'danger',
151+
onConfirm: () => handleDelete(dashboard),
152+
});
147153
}}
148-
disabled={dashboards.length <= 1}
149154
>
150155
{t('Delete')}
151156
</MenuItem>

tests/js/spec/views/dashboardsV2/manage/dashboardList.spec.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {mountWithTheme} from 'sentry-test/enzyme';
2+
import {mountGlobalModal} from 'sentry-test/modal';
23

34
import DashboardList from 'app/views/dashboardsV2/manage/dashboardList';
45

@@ -192,6 +193,12 @@ describe('Dashboards > DashboardList', function () {
192193
card = wrapper.find('DashboardCard').last();
193194
clickMenuItem(card, 'dashboard-delete');
194195

196+
expect(deleteMock).not.toHaveBeenCalled();
197+
198+
// Confirm
199+
const modal = await mountGlobalModal();
200+
modal.find('Button').last().simulate('click');
201+
195202
await tick();
196203

197204
expect(deleteMock).toHaveBeenCalled();

0 commit comments

Comments
 (0)