diff --git a/frontend/components/basic/dialog/DeleteEnvVar.tsx b/frontend/components/basic/dialog/DeleteEnvVar.tsx new file mode 100644 index 0000000000..14f5fde476 --- /dev/null +++ b/frontend/components/basic/dialog/DeleteEnvVar.tsx @@ -0,0 +1,78 @@ +import { Fragment } from "react"; +import { useTranslation } from "react-i18next"; +import { Dialog, Transition } from "@headlessui/react"; + +// #TODO: USE THIS. Currently it's not. Kinda complicated to set up because of state. + +type Props = { + isOpen: boolean + onClose: () => void + onSubmit: () => void +} + +export const DeleteEnvVar = ({ isOpen, onClose, onSubmit }: Props) => { + const { t } = useTranslation() + return ( +
+ + {}}> + +
+ +
+ +
+ + + + {t('dashboard:sidebar.delete-key-dialog.title')} + +
+

+ {t('dashboard:sidebar.delete-key-dialog.confirm-delete-message')} +

+
+
+ + +
+
+
+
+
+
+
+
+ ); +}; diff --git a/frontend/components/dashboard/DeleteActionButton.tsx b/frontend/components/dashboard/DeleteActionButton.tsx new file mode 100644 index 0000000000..db595ff031 --- /dev/null +++ b/frontend/components/dashboard/DeleteActionButton.tsx @@ -0,0 +1,33 @@ +import React, { useState } from 'react' +import { useTranslation } from 'react-i18next'; + +import Button from '../basic/buttons/Button'; +import { DeleteEnvVar } from '../basic/dialog/DeleteEnvVar'; + +type Props = { + onSubmit: () => void +} + +export function DeleteActionButton({ onSubmit }: Props) { + const { t } = useTranslation(); + const [open, setOpen] = useState(false) + + return ( +
+
+ ) +} diff --git a/frontend/components/dashboard/SideBar.tsx b/frontend/components/dashboard/SideBar.tsx index 8416e85736..52107b512b 100644 --- a/frontend/components/dashboard/SideBar.tsx +++ b/frontend/components/dashboard/SideBar.tsx @@ -9,6 +9,7 @@ import Button from '../basic/buttons/Button'; import Toggle from '../basic/Toggle'; import CommentField from './CommentField'; import DashboardInputField from './DashboardInputField'; +import { DeleteActionButton } from './DeleteActionButton'; import GenerateSecretMenu from './GenerateSecretMenu'; @@ -28,6 +29,10 @@ interface OverrideProps { pos: number; comment: string; } +export interface DeleteRowFunctionProps { + ids: string[]; + secretName: string; +} interface SideBarProps { toggleSidebar: (value: string) => void; @@ -41,7 +46,7 @@ interface SideBarProps { savePush: () => void; sharedToHide: string[]; setSharedToHide: (values: string[]) => void; - deleteRow: any; + deleteRow: (props: DeleteRowFunctionProps) => void; } /** @@ -170,14 +175,9 @@ const SideBar = ({ active={buttonReady} textDisabled="Saved" /> -
-
+ deleteRow({ ids: overrideEnabled ? data.map(secret => secret.id) : [data.filter(secret => secret.type == "shared")[0]?.id], secretName: data[0]?.key })} + /> }; diff --git a/frontend/public/locales/en/dashboard.json b/frontend/public/locales/en/dashboard.json index b64fdbd64d..99e6d9faa0 100644 --- a/frontend/public/locales/en/dashboard.json +++ b/frontend/public/locales/en/dashboard.json @@ -25,6 +25,11 @@ "comments": "Comments & Notes", "personal-explanation": "This secret is personal. It is not shared with any of your teammates.", "generate-random-hex": "Generate Random Hex", - "digits": "digits" + "digits": "digits", + "delete-key-dialog": { + "title": "Delete Key", + "confirm-delete-message": "Are you sure you want to delete this secret? This cannot be undone." + } } + }