From c71347aeb93e6ea68db49c145e964e1016958a7d Mon Sep 17 00:00:00 2001 From: Valentin Lestoille Date: Fri, 22 Mar 2024 15:46:22 +0100 Subject: [PATCH 1/4] S3Client: Add forcePathStyle --- .env.example | 2 ++ docker/README.md | 1 + docker/production/compose.yml | 1 + packages/lib/universal/upload/server-actions.ts | 1 + packages/tsconfig/process-env.d.ts | 1 + render.yaml | 2 ++ turbo.json | 1 + 7 files changed, 9 insertions(+) diff --git a/.env.example b/.env.example index 1f2df8550..343ae91c9 100644 --- a/.env.example +++ b/.env.example @@ -55,6 +55,8 @@ NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH= NEXT_PUBLIC_UPLOAD_TRANSPORT="database" # OPTIONAL: Defines the endpoint to use for the S3 storage transport. Relevant when using third-party S3-compatible providers. NEXT_PRIVATE_UPLOAD_ENDPOINT="http://127.0.0.1:9002" +# OPTIONAL: Defines the force path style to use for the S3 storage transport. Relevant when using third-party S3-compatible providers. +NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE="false" # OPTIONAL: Defines the region to use for the S3 storage transport. Defaults to us-east-1. NEXT_PRIVATE_UPLOAD_REGION="unknown" # REQUIRED: Defines the bucket to use for the S3 storage transport. diff --git a/docker/README.md b/docker/README.md index bda1638a2..2b0ce9953 100644 --- a/docker/README.md +++ b/docker/README.md @@ -115,6 +115,7 @@ Here's a markdown table documenting all the provided environment variables: | `NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH` | The path to the key file, default `/opt/documenso/cert.p12`. | | `NEXT_PUBLIC_UPLOAD_TRANSPORT` | The transport to use for file uploads (database or s3). | | `NEXT_PRIVATE_UPLOAD_ENDPOINT` | The endpoint for the S3 storage transport (for third-party S3-compatible providers). | +| `NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE` | Whether to force path-style URLs for the S3 storage transport. | | `NEXT_PRIVATE_UPLOAD_REGION` | The region for the S3 storage transport (defaults to us-east-1). | | `NEXT_PRIVATE_UPLOAD_BUCKET` | The bucket to use for the S3 storage transport. | | `NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID` | The access key ID for the S3 storage transport. | diff --git a/docker/production/compose.yml b/docker/production/compose.yml index 02acc655d..bcbd9b857 100644 --- a/docker/production/compose.yml +++ b/docker/production/compose.yml @@ -34,6 +34,7 @@ services: - NEXT_PRIVATE_DIRECT_DATABASE_URL=${NEXT_PRIVATE_DIRECT_DATABASE_URL:-${NEXT_PRIVATE_DATABASE_URL}} - NEXT_PUBLIC_UPLOAD_TRANSPORT=${NEXT_PUBLIC_UPLOAD_TRANSPORT:-database} - NEXT_PRIVATE_UPLOAD_ENDPOINT=${NEXT_PRIVATE_UPLOAD_ENDPOINT} + - NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE=${NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE} - NEXT_PRIVATE_UPLOAD_REGION=${NEXT_PRIVATE_UPLOAD_REGION} - NEXT_PRIVATE_UPLOAD_BUCKET=${NEXT_PRIVATE_UPLOAD_BUCKET} - NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID=${NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID} diff --git a/packages/lib/universal/upload/server-actions.ts b/packages/lib/universal/upload/server-actions.ts index fd4bfc57a..609cfdff7 100644 --- a/packages/lib/universal/upload/server-actions.ts +++ b/packages/lib/universal/upload/server-actions.ts @@ -132,6 +132,7 @@ const getS3Client = () => { return new S3Client({ endpoint: process.env.NEXT_PRIVATE_UPLOAD_ENDPOINT || undefined, + forcePathStyle: process.env.NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE || 'false', region: process.env.NEXT_PRIVATE_UPLOAD_REGION || 'us-east-1', credentials: hasCredentials ? { diff --git a/packages/tsconfig/process-env.d.ts b/packages/tsconfig/process-env.d.ts index 1b9c577cf..761defd54 100644 --- a/packages/tsconfig/process-env.d.ts +++ b/packages/tsconfig/process-env.d.ts @@ -17,6 +17,7 @@ declare namespace NodeJS { NEXT_PUBLIC_UPLOAD_TRANSPORT?: 'database' | 's3'; NEXT_PRIVATE_UPLOAD_ENDPOINT?: string; + NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE?: string; NEXT_PRIVATE_UPLOAD_REGION?: string; NEXT_PRIVATE_UPLOAD_BUCKET?: string; NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID?: string; diff --git a/render.yaml b/render.yaml index 9fe1bd2e9..6416e9ffb 100644 --- a/render.yaml +++ b/render.yaml @@ -85,6 +85,8 @@ services: value: 'database' - key: NEXT_PRIVATE_UPLOAD_ENDPOINT sync: false + - key: NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE + sync: false - key: NEXT_PRIVATE_UPLOAD_REGION sync: false - key: NEXT_PRIVATE_UPLOAD_BUCKET diff --git a/turbo.json b/turbo.json index d17a09661..5e2ef340d 100644 --- a/turbo.json +++ b/turbo.json @@ -60,6 +60,7 @@ "NEXT_PRIVATE_GOOGLE_CLIENT_SECRET", "NEXT_PUBLIC_UPLOAD_TRANSPORT", "NEXT_PRIVATE_UPLOAD_ENDPOINT", + "NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE", "NEXT_PRIVATE_UPLOAD_REGION", "NEXT_PRIVATE_UPLOAD_BUCKET", "NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID", From 994368156f26b568134f61c73a405926c0340dc1 Mon Sep 17 00:00:00 2001 From: Valentin Lestoille Date: Mon, 25 Mar 2024 08:23:28 +0100 Subject: [PATCH 2/4] Additional comment --- .env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.example b/.env.example index 343ae91c9..a9b600c03 100644 --- a/.env.example +++ b/.env.example @@ -56,6 +56,7 @@ NEXT_PUBLIC_UPLOAD_TRANSPORT="database" # OPTIONAL: Defines the endpoint to use for the S3 storage transport. Relevant when using third-party S3-compatible providers. NEXT_PRIVATE_UPLOAD_ENDPOINT="http://127.0.0.1:9002" # OPTIONAL: Defines the force path style to use for the S3 storage transport. Relevant when using third-party S3-compatible providers. +# This will change it from using virtual hosts .domain.com/ to fully qualified paths domain.com// NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE="false" # OPTIONAL: Defines the region to use for the S3 storage transport. Defaults to us-east-1. NEXT_PRIVATE_UPLOAD_REGION="unknown" From ba30d4368df6a0278fc2ac83de1e7c3602eaf4f8 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Wed, 27 Mar 2024 03:37:13 +0000 Subject: [PATCH 3/4] fix: build error --- packages/lib/universal/upload/server-actions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lib/universal/upload/server-actions.ts b/packages/lib/universal/upload/server-actions.ts index 609cfdff7..034385196 100644 --- a/packages/lib/universal/upload/server-actions.ts +++ b/packages/lib/universal/upload/server-actions.ts @@ -132,7 +132,7 @@ const getS3Client = () => { return new S3Client({ endpoint: process.env.NEXT_PRIVATE_UPLOAD_ENDPOINT || undefined, - forcePathStyle: process.env.NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE || 'false', + forcePathStyle: process.env.NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE === 'true', region: process.env.NEXT_PRIVATE_UPLOAD_REGION || 'us-east-1', credentials: hasCredentials ? { From 038370012fb13cc3f8180d0a1f26d64fe7743d01 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Wed, 27 Mar 2024 14:10:29 +0800 Subject: [PATCH 4/4] fix: render fields on document load (#1054) ## Description Currently if you try to load the document edit page when fields need to be rendered, you will not be able to see the fields until you proceed to the next step. This is because the fields require the document PDF to be loaded prior to rendering them. This PR resolves that issue by only rendering the fields after the PDF is loaded. ## Changes Made - Add a state to track whether the PDF is loaded - Render the fields only after the PDF is loaded ## Testing Performed Tested document flow manually and the fields are rendered correctly on load. ## Checklist - [X] I have tested these changes locally and they work as expected. - [X] I have updated the documentation to reflect these changes, if applicable. --- .../app/(marketing)/singleplayer/client.tsx | 1 + .../documents/[id]/edit-document.tsx | 8 ++++- .../primitives/document-flow/add-fields.tsx | 29 ++++++++++--------- .../primitives/document-flow/add-signers.tsx | 9 ++++-- .../primitives/document-flow/add-subject.tsx | 9 ++++-- .../ui/primitives/document-flow/add-title.tsx | 9 ++++-- 6 files changed, 42 insertions(+), 23 deletions(-) diff --git a/apps/marketing/src/app/(marketing)/singleplayer/client.tsx b/apps/marketing/src/app/(marketing)/singleplayer/client.tsx index a8e0a0c63..48b967de8 100644 --- a/apps/marketing/src/app/(marketing)/singleplayer/client.tsx +++ b/apps/marketing/src/app/(marketing)/singleplayer/client.tsx @@ -246,6 +246,7 @@ export const SinglePlayerClient = () => { recipients={uploadedFile ? [placeholderRecipient] : []} fields={fields} onSubmit={onFieldsSubmit} + isDocumentPdfLoaded={true} /> diff --git a/apps/web/src/app/(dashboard)/documents/[id]/edit-document.tsx b/apps/web/src/app/(dashboard)/documents/[id]/edit-document.tsx index 9b051bbad..90f605602 100644 --- a/apps/web/src/app/(dashboard)/documents/[id]/edit-document.tsx +++ b/apps/web/src/app/(dashboard)/documents/[id]/edit-document.tsx @@ -49,6 +49,8 @@ export const EditDocumentForm = ({ const searchParams = useSearchParams(); const team = useOptionalCurrentTeam(); + const [isDocumentPdfLoaded, setIsDocumentPdfLoaded] = useState(false); + const utils = trpc.useUtils(); const { data: document, refetch: refetchDocument } = @@ -294,6 +296,7 @@ export const EditDocumentForm = ({ document={document} password={document.documentMeta?.password} onPasswordSubmit={onPasswordSubmit} + onDocumentLoad={() => setIsDocumentPdfLoaded(true)} /> @@ -314,8 +317,8 @@ export const EditDocumentForm = ({ recipients={recipients} fields={fields} onSubmit={onAddTitleFormSubmit} + isDocumentPdfLoaded={isDocumentPdfLoaded} /> - diff --git a/packages/ui/primitives/document-flow/add-fields.tsx b/packages/ui/primitives/document-flow/add-fields.tsx index c4f58b83c..3031d6479 100644 --- a/packages/ui/primitives/document-flow/add-fields.tsx +++ b/packages/ui/primitives/document-flow/add-fields.tsx @@ -53,6 +53,7 @@ export type AddFieldsFormProps = { recipients: Recipient[]; fields: Field[]; onSubmit: (_data: TAddFieldsFormSchema) => void; + isDocumentPdfLoaded: boolean; }; export const AddFieldsFormPartial = ({ @@ -61,6 +62,7 @@ export const AddFieldsFormPartial = ({ recipients, fields, onSubmit, + isDocumentPdfLoaded, }: AddFieldsFormProps) => { const { isWithinPageBounds, getFieldPosition, getPage } = useDocumentElement(); const { currentStep, totalSteps, previousStep } = useStep(); @@ -342,19 +344,20 @@ export const AddFieldsFormPartial = ({ )} - {localFields.map((field, index) => ( - onFieldResize(options, index)} - onMove={(options) => onFieldMove(options, index)} - onRemove={() => remove(index)} - /> - ))} + {isDocumentPdfLoaded && + localFields.map((field, index) => ( + onFieldResize(options, index)} + onMove={(options) => onFieldMove(options, index)} + onRemove={() => remove(index)} + /> + ))} {!hideRecipients && ( diff --git a/packages/ui/primitives/document-flow/add-signers.tsx b/packages/ui/primitives/document-flow/add-signers.tsx index 8792af2a8..95f2c7983 100644 --- a/packages/ui/primitives/document-flow/add-signers.tsx +++ b/packages/ui/primitives/document-flow/add-signers.tsx @@ -39,6 +39,7 @@ export type AddSignersFormProps = { fields: Field[]; document: DocumentWithData; onSubmit: (_data: TAddSignersFormSchema) => void; + isDocumentPdfLoaded: boolean; }; export const AddSignersFormPartial = ({ @@ -47,6 +48,7 @@ export const AddSignersFormPartial = ({ document, fields, onSubmit, + isDocumentPdfLoaded, }: AddSignersFormProps) => { const { toast } = useToast(); const { remaining } = useLimits(); @@ -145,9 +147,10 @@ export const AddSignersFormPartial = ({ />
- {fields.map((field, index) => ( - - ))} + {isDocumentPdfLoaded && + fields.map((field, index) => ( + + ))} {signers.map((signer, index) => ( diff --git a/packages/ui/primitives/document-flow/add-subject.tsx b/packages/ui/primitives/document-flow/add-subject.tsx index aa0bc148f..3f9cbe798 100644 --- a/packages/ui/primitives/document-flow/add-subject.tsx +++ b/packages/ui/primitives/document-flow/add-subject.tsx @@ -50,6 +50,7 @@ export type AddSubjectFormProps = { fields: Field[]; document: DocumentWithData; onSubmit: (_data: TAddSubjectFormSchema) => void; + isDocumentPdfLoaded: boolean; }; export const AddSubjectFormPartial = ({ @@ -58,6 +59,7 @@ export const AddSubjectFormPartial = ({ fields: fields, document, onSubmit, + isDocumentPdfLoaded, }: AddSubjectFormProps) => { const { control, @@ -103,9 +105,10 @@ export const AddSubjectFormPartial = ({ />
- {fields.map((field, index) => ( - - ))} + {isDocumentPdfLoaded && + fields.map((field, index) => ( + + ))}
diff --git a/packages/ui/primitives/document-flow/add-title.tsx b/packages/ui/primitives/document-flow/add-title.tsx index a6390fd3a..5abe44003 100644 --- a/packages/ui/primitives/document-flow/add-title.tsx +++ b/packages/ui/primitives/document-flow/add-title.tsx @@ -28,6 +28,7 @@ export type AddTitleFormProps = { fields: Field[]; document: DocumentWithData; onSubmit: (_data: TAddTitleFormSchema) => void; + isDocumentPdfLoaded: boolean; }; export const AddTitleFormPartial = ({ @@ -36,6 +37,7 @@ export const AddTitleFormPartial = ({ fields, document, onSubmit, + isDocumentPdfLoaded, }: AddTitleFormProps) => { const { register, @@ -59,9 +61,10 @@ export const AddTitleFormPartial = ({ description={documentFlow.description} /> - {fields.map((field, index) => ( - - ))} + {isDocumentPdfLoaded && + fields.map((field, index) => ( + + ))}