diff --git a/apps/docs/content/docs/developers/embedding/editor/v2.mdx b/apps/docs/content/docs/developers/embedding/editor/v2.mdx index 6c8fc91f4..ae7d11bf9 100644 --- a/apps/docs/content/docs/developers/embedding/editor/v2.mdx +++ b/apps/docs/content/docs/developers/embedding/editor/v2.mdx @@ -186,6 +186,15 @@ Controls envelope configuration options. Set to `null` to hide envelope settings | `allowConfigureEmailSender` | `boolean` | `true` | Allow configuring the email sender | | `allowConfigureEmailReplyTo` | `boolean` | `true` | Allow configuring the email reply-to | + + The settings dialog also contains an "Allow Document Rejection" option that is always shown. It sets the document's + own rejection setting (`meta.allowDocumentRejection` in the API) and defaults to the organisation or team document + preference. This + is separate from the `allowDocumentRejection` option of the embedded signing views: that option only controls the + signing embed's UI, while this one is stored on the document and enforced by the server. A recipient can reject only + when both allow it. + + ### Actions Controls available actions during editing: diff --git a/apps/docs/content/docs/developers/embedding/iframe.mdx b/apps/docs/content/docs/developers/embedding/iframe.mdx index 70077fcfc..20510dde9 100644 --- a/apps/docs/content/docs/developers/embedding/iframe.mdx +++ b/apps/docs/content/docs/developers/embedding/iframe.mdx @@ -47,10 +47,20 @@ Documenso expects the fragment to be **base64** of: | `lockEmail` | `boolean` | Lock the email field (prevents editing). | | `language` | `string` | Force the embed language (e.g. `en`). | | `darkModeDisabled` | `boolean` | Disable dark mode behavior. | -| `allowDocumentRejection` | `boolean` | Allow or disallow document rejection. | +| `allowDocumentRejection` | `boolean` | Show the reject option in the embed. Defaults to `false`. The document must also allow rejection, see below. | | `css` | `string` | Inject custom CSS into the embed. | | `cssVars` | `object` | Override embed CSS variables (see the CSS Variables page). | + + Two settings control whether a recipient can reject a document in an embed, and both must allow it: + + - `allowDocumentRejection` above, which you pass per embed. It only controls your embed's UI and defaults to `false`. + - The document's own "Allow Document Rejection" setting. Its default comes from the organisation or team document + preferences, and it can be changed per document in the editor or through the API (`meta.allowDocumentRejection`). + When it is disabled, the reject option stays hidden even if you pass `allowDocumentRejection: true`, and the server + refuses rejection requests for that document. + + #### Example ```ts diff --git a/apps/remix/app/components/embed/embed-document-signing-page-v1.tsx b/apps/remix/app/components/embed/embed-document-signing-page-v1.tsx index 739a5c8a6..98db678cf 100644 --- a/apps/remix/app/components/embed/embed-document-signing-page-v1.tsx +++ b/apps/remix/app/components/embed/embed-document-signing-page-v1.tsx @@ -96,6 +96,9 @@ export const EmbedSignDocumentV1ClientPage = ({ const [allowDocumentRejection, setAllowDocumentRejection] = useState(false); + // Both the embed host and the document settings must allow rejection. + const isDocumentRejectionAllowed = allowDocumentRejection && (metadata?.allowDocumentRejection ?? true); + const selectedSigner = allRecipients.find((r) => r.id === selectedSignerId); const isAssistantMode = recipient.role === RecipientRole.ASSISTANT; @@ -303,7 +306,7 @@ export const EmbedSignDocumentV1ClientPage = ({
- {allowDocumentRejection && ( + {isDocumentRejectionAllowed && ( )}
@@ -502,7 +505,7 @@ export const EmbedSignDocumentV1ClientPage = ({ ) : ( - {allowDocumentRejection && ( + {allowDocumentRejection && (document.documentMeta?.allowDocumentRejection ?? true) && (
diff --git a/apps/remix/app/components/general/document-signing/document-signing-page-view-v2.tsx b/apps/remix/app/components/general/document-signing/document-signing-page-view-v2.tsx index 46ff0d89f..e0be3f742 100644 --- a/apps/remix/app/components/general/document-signing/document-signing-page-view-v2.tsx +++ b/apps/remix/app/components/general/document-signing/document-signing-page-view-v2.tsx @@ -63,6 +63,10 @@ export const DocumentSigningPageViewV2 = () => { onDocumentRejected, } = useEmbedSigningContext() || {}; + // Both the document settings and the embed host (if any) must allow rejection. + const isDocumentRejectionAllowed = + envelope.type === EnvelopeType.DOCUMENT && envelope.documentMeta.allowDocumentRejection && allowDocumentRejection; + const { t } = useLingui(); const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(false); @@ -193,7 +197,7 @@ export const DocumentSigningPageViewV2 = () => { } /> - {envelope.type === EnvelopeType.DOCUMENT && allowDocumentRejection && ( + {isDocumentRejectionAllowed && ( { const MobileDropdownMenu = () => { const { envelope, recipient } = useRequiredEnvelopeSigningContext(); - const { allowDocumentRejection } = useEmbedSigningContext() || {}; + const { allowDocumentRejection = true } = useEmbedSigningContext() || {}; + + // Both the document settings and the embed host (if any) must allow rejection. + const isDocumentRejectionAllowed = + envelope.type === EnvelopeType.DOCUMENT && envelope.documentMeta.allowDocumentRejection && allowDocumentRejection; return ( @@ -113,7 +117,7 @@ const MobileDropdownMenu = () => { } /> - {envelope.type === EnvelopeType.DOCUMENT && allowDocumentRejection !== false && ( + {isDocumentRejectionAllowed && (