feat: add delegate document ownership option (#2272)

When using an API key created in a team context, the
documents/templates’ owner always defaults to the team API token
creator, rather than the actual uploader.

For example, John creates the API key for the team "Lawyers". Tom and
Maria use the API key to upload documents. All the uploaded documents
are attributed to John.

This makes it impossible to see who actually uploaded a document.

The new feature allows users to enable document ownership delegation
from the organization/team settings.
This commit is contained in:
Catalin Pit
2025-12-23 22:08:54 +11:00
committed by GitHub
parent 1e585e06e6
commit baa2c51123
24 changed files with 693 additions and 484 deletions
@@ -75,11 +75,12 @@ export async function loader({ params, request }: Route.LoaderArgs) {
},
recipients: envelope.recipients,
documentRootPath,
userId: user.id,
};
}
export default function DocumentsLogsPage({ loaderData }: Route.ComponentProps) {
const { document, recipients, documentRootPath } = loaderData;
const { document, recipients, documentRootPath, userId } = loaderData;
const { _, i18n } = useLingui();
@@ -171,15 +172,15 @@ export default function DocumentsLogsPage({ loaderData }: Route.ComponentProps)
<section className="mt-6">
<Card className="grid grid-cols-1 gap-4 p-4 sm:grid-cols-2" degrees={45} gradient>
{documentInformation.map((info, i) => (
<div className="text-foreground text-sm" key={i}>
<div className="text-sm text-foreground" key={i}>
<h3 className="font-semibold">{_(info.description)}</h3>
<p className="text-muted-foreground truncate">{info.value}</p>
<p className="truncate text-muted-foreground">{info.value}</p>
</div>
))}
<div className="text-foreground text-sm">
<div className="text-sm text-foreground">
<h3 className="font-semibold">Recipients</h3>
<ul className="text-muted-foreground list-inside list-disc">
<ul className="list-inside list-disc text-muted-foreground">
{recipients.map((recipient) => (
<li key={`recipient-${recipient.id}`}>
<span>{formatRecipientText(recipient)}</span>
@@ -191,7 +192,7 @@ export default function DocumentsLogsPage({ loaderData }: Route.ComponentProps)
</section>
<section className="mt-6">
<DocumentLogsTable documentId={document.id} />
<DocumentLogsTable documentId={document.id} userId={userId} />
</section>
</div>
);
@@ -50,6 +50,7 @@ export default function TeamsSettingsPage() {
includeSigningCertificate,
includeAuditLog,
signatureTypes,
delegateDocumentOwnership,
aiFeaturesEnabled,
} = data;
@@ -75,6 +76,7 @@ export default function TeamsSettingsPage() {
uploadSignatureEnabled: signatureTypes.includes(DocumentSignatureType.UPLOAD),
drawSignatureEnabled: signatureTypes.includes(DocumentSignatureType.DRAW),
}),
delegateDocumentOwnership: delegateDocumentOwnership,
},
});