diff --git a/public/app/features/search/components/DashboardActions.tsx b/public/app/features/search/components/DashboardActions.tsx index 5eacc48dcd2..40ee16db4f7 100644 --- a/public/app/features/search/components/DashboardActions.tsx +++ b/public/app/features/search/components/DashboardActions.tsx @@ -90,12 +90,7 @@ export const DashboardActions = ({ folder, canCreateFolders = false, canCreateDa {canMove && isMoveModalOpen && ( - {}} - results={moveSelection} - isOpen={isMoveModalOpen} - onDismiss={() => setIsMoveModalOpen(false)} - /> + {}} results={moveSelection} onDismiss={() => setIsMoveModalOpen(false)} /> )} ); diff --git a/public/app/features/search/page/components/ConfirmDeleteModal.test.tsx b/public/app/features/search/page/components/ConfirmDeleteModal.test.tsx index 2c0192cbb70..ac48422fb8e 100644 --- a/public/app/features/search/page/components/ConfirmDeleteModal.test.tsx +++ b/public/app/features/search/page/components/ConfirmDeleteModal.test.tsx @@ -1,22 +1,46 @@ import { render, screen, within } from '@testing-library/react'; import React from 'react'; +import { config } from 'app/core/config'; + import { ConfirmDeleteModal } from './ConfirmDeleteModal'; describe('ConfirmModal', () => { it('should render correct title, body, dismiss-, cancel- and delete-text', () => { - const items = new Map(); - const dashboardsUIDs = new Set(); - dashboardsUIDs.add('uid1'); - dashboardsUIDs.add('uid2'); - items.set('dashboard', dashboardsUIDs); - const onDeleteItems = jest.fn(); - render( {}} />); + const selectedItems = new Map([['dashboard', new Set(['uid1', 'uid2'])]]); + + render( {}} results={selectedItems} onDismiss={() => {}} />); expect(screen.getByRole('heading', { name: 'Delete' })).toBeInTheDocument(); expect(screen.getByText('Do you want to delete the 2 selected dashboards?')).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument(); const button = screen.getByRole('button', { name: 'Confirm Modal Danger Button' }); expect(within(button).getByText('Delete')).toBeInTheDocument(); + + expect(screen.queryByPlaceholderText('Type delete to confirm')).not.toBeInTheDocument(); + }); + + describe('with nestedFolders feature flag', () => { + let originalNestedFoldersValue = config.featureToggles.nestedFolders; + + beforeAll(() => { + originalNestedFoldersValue = config.featureToggles.nestedFolders; + config.featureToggles.nestedFolders = true; + }); + + afterAll(() => { + config.featureToggles.nestedFolders = originalNestedFoldersValue; + }); + + it("should ask to type 'delete' to confirm when a folder is selected", async () => { + const selectedItems = new Map([ + ['dashboard', new Set(['uid1', 'uid2'])], + ['folder', new Set(['uid3'])], + ]); + + render( {}} results={selectedItems} onDismiss={() => {}} />); + + expect(screen.getByPlaceholderText('Type delete to confirm')).toBeInTheDocument(); + }); }); }); diff --git a/public/app/features/search/page/components/ConfirmDeleteModal.tsx b/public/app/features/search/page/components/ConfirmDeleteModal.tsx index f5c6e5bdcf7..ec7b7808b8e 100644 --- a/public/app/features/search/page/components/ConfirmDeleteModal.tsx +++ b/public/app/features/search/page/components/ConfirmDeleteModal.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { ConfirmModal, useStyles2 } from '@grafana/ui'; +import { config } from 'app/core/config'; import { deleteFoldersAndDashboards } from 'app/features/manage-dashboards/state/actions'; import { OnMoveOrDeleleSelectedItems } from '../../types'; @@ -43,6 +44,8 @@ export const ConfirmDeleteModal = ({ results, onDeleteItems, onDismiss }: Props) }); }; + const requireDoubleConfirm = config.featureToggles.nestedFolders && folderCount > 0; + return ( } confirmText="Delete" + confirmationText={requireDoubleConfirm ? 'delete' : undefined} onConfirm={deleteItems} onDismiss={onDismiss} />