From ea27870ce334380c7574fec1afc16d1faaff703e Mon Sep 17 00:00:00 2001 From: carlosmonastyrski Date: Fri, 14 Mar 2025 16:12:40 -0300 Subject: [PATCH] Move useOrganization outside ShareSecretForm as it's used on a public page --- .../components/ShareSecret/AddShareSecretModal.tsx | 5 +++++ .../ShareSecretPage/components/ShareSecretForm.tsx | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx b/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx index 3378313b7..45b974755 100644 --- a/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx +++ b/frontend/src/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal.tsx @@ -1,4 +1,5 @@ import { Modal, ModalContent } from "@app/components/v2"; +import { useOrganization } from "@app/context"; import { UsePopUpState } from "@app/hooks/usePopUp"; import { ShareSecretForm } from "@app/pages/public/ShareSecretPage/components"; @@ -11,6 +12,7 @@ type Props = { }; export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => { + const { currentOrg } = useOrganization(); return ( { diff --git a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx index 07a6336fa..a2228e46b 100644 --- a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx +++ b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx @@ -7,7 +7,6 @@ import { z } from "zod"; import { createNotification } from "@app/components/notifications"; import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2"; -import { useOrganization } from "@app/context"; import { useTimedReset } from "@app/hooks"; import { useCreatePublicSharedSecret, useCreateSharedSecret } from "@app/hooks/api"; import { SecretSharingAccessType } from "@app/hooks/api/secretSharing"; @@ -42,11 +41,15 @@ export type FormData = z.infer; type Props = { isPublic: boolean; // whether or not this is a public (non-authenticated) secret sharing form value?: string; + allowSecretSharingOutsideOrganization?: boolean; }; -export const ShareSecretForm = ({ isPublic, value }: Props) => { +export const ShareSecretForm = ({ + isPublic, + value, + allowSecretSharingOutsideOrganization = true +}: Props) => { const [secretLink, setSecretLink] = useState(""); - const { currentOrg } = useOrganization(); const [, isCopyingSecret, setCopyTextSecret] = useTimedReset({ initialState: "Copy to clipboard" }); @@ -232,7 +235,7 @@ export const ShareSecretForm = ({ isPublic, value }: Props) => { onValueChange={(e) => onChange(e)} className="w-full" > - {currentOrg?.allowSecretSharingOutsideOrganization && ( + {allowSecretSharingOutsideOrganization && ( Anyone )}