Skip to content

Commit 5777542

Browse files
authored
fix(compass-crud): add warning banner to the delete confirmation modal COMPASS-9839 (#7311)
add warning banner to the delete confirmation modal
1 parent da5e877 commit 5777542

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/compass-components/src/hooks/use-confirmation.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import ConfirmationModal from '../components/modals/confirmation-modal';
1010
import { css } from '@leafygreen-ui/emotion';
1111
import type { ButtonProps } from '@leafygreen-ui/button';
1212
import FormFieldContainer from '../components/form-field-container';
13-
import { TextInput } from '../components/leafygreen';
13+
import { Banner, TextInput } from '../components/leafygreen';
14+
import { spacing } from '@leafygreen-ui/tokens';
1415

1516
export { ConfirmationModalVariant };
1617

@@ -24,6 +25,7 @@ type ConfirmationProperties = Partial<
2425
hideConfirmButton?: boolean;
2526
hideCancelButton?: boolean;
2627
description?: React.ReactNode;
28+
warning?: React.ReactNode;
2729
signal?: AbortSignal;
2830
'data-testid'?: string;
2931
};
@@ -93,6 +95,7 @@ const confirmationModalState = new GlobalConfirmationModalState();
9395
*
9496
* @param props ConfirmationModal rendering properties
9597
*/
98+
9699
export const showConfirmation = confirmationModalState.showConfirmation.bind(
97100
confirmationModalState
98101
);
@@ -101,6 +104,10 @@ const hideButtonStyles = css({
101104
display: 'none !important',
102105
});
103106

107+
const warningBannerStyles = css({
108+
marginTop: spacing[400],
109+
});
110+
104111
const ConfirmationModalStateHandler: React.FunctionComponent = ({
105112
children,
106113
}) => {
@@ -191,6 +198,11 @@ const ConfirmationModalStateHandler: React.FunctionComponent = ({
191198
requiredInputText={confirmationProps.requiredInputText ?? undefined}
192199
>
193200
{confirmationProps.description}
201+
{confirmationProps.warning && (
202+
<Banner variant="warning" className={warningBannerStyles}>
203+
{confirmationProps.warning}
204+
</Banner>
205+
)}
194206
</ConfirmationModal>
195207
</>
196208
);

packages/compass-crud/src/stores/crud-store.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,8 @@ class CrudStoreImpl
19551955
description: `This action can not be undone. This will permanently delete ${
19561956
affected ?? 'an unknown number of'
19571957
} document${affected !== 1 ? 's' : ''}.`,
1958+
warning:
1959+
'The document list and count may not always reflect the latest updates in real time. This action will apply to all relevant documents, including those not currently visible, so please ensure they are handled safely.',
19581960
variant: 'danger',
19591961
});
19601962

0 commit comments

Comments
 (0)