From a87dc2fcb93fb929ef01244b33520fe13940caf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <68869379+JoaoVictor6@users.noreply.github.com> Date: Thu, 5 Jan 2023 22:33:05 -0300 Subject: [PATCH 1/3] refactor: add new sentences I would add it in the Korean folder, but I don't know it :( --- frontend/public/locales/en/dashboard.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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." + } } + } From 4c79aadc224d3c799fca29bf6fdbed32a17fb4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <68869379+JoaoVictor6@users.noreply.github.com> Date: Thu, 5 Jan 2023 22:34:18 -0300 Subject: [PATCH 2/3] feat: create dialog and button for confirm delete --- .../components/basic/dialog/DeleteEnvVar.tsx | 78 +++++++++++++++++++ .../dashboard/DeleteActionButton.tsx | 33 ++++++++ 2 files changed, 111 insertions(+) create mode 100644 frontend/components/basic/dialog/DeleteEnvVar.tsx create mode 100644 frontend/components/dashboard/DeleteActionButton.tsx 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 ( +
+
+ ) +} From 12a9b60cc54992f6bfb928754be59588316e8434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <68869379+JoaoVictor6@users.noreply.github.com> Date: Thu, 5 Jan 2023 22:35:03 -0300 Subject: [PATCH 3/3] refactor: use DeleteActionButton component and improve types --- frontend/components/dashboard/SideBar.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/components/dashboard/SideBar.tsx b/frontend/components/dashboard/SideBar.tsx index 41ac9c1440..937e85a08b 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 })} + /> };