github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/Modals/ConfirmDelete/index.tsx (about)

     1  import ShowModal, { ShowModalParams } from '@webapp/ui/Modals';
     2  
     3  interface ConfirmDeleteProps {
     4    objectType: string;
     5    objectName: string;
     6    onConfirm: () => void;
     7    warningMsg?: string;
     8    withConfirmationInput?: boolean;
     9  }
    10  
    11  function confirmDelete({
    12    objectName,
    13    objectType,
    14    onConfirm,
    15    withConfirmationInput,
    16    warningMsg,
    17  }: ConfirmDeleteProps) {
    18    const confirmationInputProps: Partial<ShowModalParams> = withConfirmationInput
    19      ? {
    20          input: 'text' as ShowModalParams['input'],
    21          inputLabel: `To confirm deletion enter ${objectType} name below.`,
    22          inputPlaceholder: objectName,
    23          inputValidator: (value) =>
    24            value === objectName ? null : 'Name does not match',
    25        }
    26      : {};
    27  
    28    // eslint-disable-next-line @typescript-eslint/no-floating-promises
    29    ShowModal({
    30      title: `Delete ${objectType}`,
    31      html: `Are you sure you want to delete<br><strong>${objectName}</strong> ?${
    32        warningMsg ? `<br><br>${warningMsg}` : ''
    33      }`,
    34      confirmButtonText: 'Delete',
    35      type: 'danger',
    36      onConfirm,
    37      ...confirmationInputProps,
    38    });
    39  }
    40  
    41  export default confirmDelete;