From c1696fbf480a1e5bf10b067f8bf36ef38485abba Mon Sep 17 00:00:00 2001 From: Wahyu Kurniawan Date: Thu, 14 Mar 2024 21:55:30 +0700 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20create=20delet?= =?UTF-8?q?e=20variable=20dialog=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/Dialog/DeleteVariableDialog.tsx | 36 +++++++++++++++++++ .../settings/EditEnvironmentVariableRow.tsx | 20 ++++------- 2 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 packages/frontend/src/components/projects/Dialog/DeleteVariableDialog.tsx diff --git a/packages/frontend/src/components/projects/Dialog/DeleteVariableDialog.tsx b/packages/frontend/src/components/projects/Dialog/DeleteVariableDialog.tsx new file mode 100644 index 00000000..227fa34a --- /dev/null +++ b/packages/frontend/src/components/projects/Dialog/DeleteVariableDialog.tsx @@ -0,0 +1,36 @@ +import ConfirmDialog, { + ConfirmDialogProps, +} from 'components/shared/ConfirmDialog'; +import React from 'react'; + +interface DeleteVariableDialogProps extends ConfirmDialogProps { + variableKey: string; +} + +export const DeleteVariableDialog = ({ + variableKey, + open, + handleCancel, + handleConfirm, + ...props +}: DeleteVariableDialogProps) => { + return ( + +

+ Are you sure you want to delete the variable{' '} + + {variableKey} + + ? +

+
+ ); +}; diff --git a/packages/frontend/src/components/projects/project/settings/EditEnvironmentVariableRow.tsx b/packages/frontend/src/components/projects/project/settings/EditEnvironmentVariableRow.tsx index c15c142e..0e382986 100644 --- a/packages/frontend/src/components/projects/project/settings/EditEnvironmentVariableRow.tsx +++ b/packages/frontend/src/components/projects/project/settings/EditEnvironmentVariableRow.tsx @@ -5,8 +5,8 @@ import { EnvironmentVariable } from 'gql-client'; import { IconButton, Input, Typography } from '@material-tailwind/react'; -import ConfirmDialog from '../../../shared/ConfirmDialog'; -import { useGQLClient } from '../../../../context/GQLClientContext'; +import { useGQLClient } from 'context/GQLClientContext'; +import { DeleteVariableDialog } from 'components/projects/Dialog/DeleteVariableDialog'; const ShowPasswordIcon = ({ handler, @@ -161,20 +161,12 @@ const EditEnvironmentVariableRow = ({ )} - - setDeleteDialogOpen((preVal) => !preVal)} + setDeleteDialogOpen((preVal) => !preVal)} open={deleteDialogOpen} - confirmButtonTitle="Yes, Confirm delete" handleConfirm={removeEnvironmentVariableHandler} - color="red" - > - - Are you sure you want to delete the variable  - {variable.key}? - - + variableKey={variable.key} + /> ); };