mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: enhance document attachment updates and audit logging
- Implemented detailed handling for document attachment updates in DocumentHistorySheet. - Updated updateDocument function to log changes only when attachments differ. - Enhanced ZDocumentSchema to include attachment type validation. - Refined audit log formatting for document attachment updates to improve clarity.
This commit is contained in:
@ -361,6 +361,25 @@ export const DocumentHistorySheet = ({
|
||||
]}
|
||||
/>
|
||||
))
|
||||
.with(
|
||||
{ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_ATTACHMENTS_UPDATED },
|
||||
({ data }) => (
|
||||
<DocumentHistorySheetChanges
|
||||
values={[
|
||||
{
|
||||
key: 'Old',
|
||||
value:
|
||||
data.from.map((attachment) => attachment.label).join(', ') || 'None',
|
||||
},
|
||||
{
|
||||
key: 'New',
|
||||
value:
|
||||
data.to.map((attachment) => attachment.label).join(', ') || 'None',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
),
|
||||
)
|
||||
.exhaustive()}
|
||||
|
||||
{isUserDetailsVisible && (
|
||||
|
||||
@ -242,7 +242,7 @@ export const updateDocument = async ({
|
||||
);
|
||||
}
|
||||
|
||||
if (data.attachments) {
|
||||
if (!isAttachmentsSame) {
|
||||
auditLogs.push(
|
||||
createDocumentAuditLogData({
|
||||
type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_ATTACHMENTS_UPDATED,
|
||||
@ -250,7 +250,7 @@ export const updateDocument = async ({
|
||||
metadata: requestMetadata,
|
||||
data: {
|
||||
from: document.attachments,
|
||||
to: data.attachments,
|
||||
to: data.attachments ?? [],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@ -64,6 +64,7 @@ export const ZDocumentSchema = DocumentSchema.pick({
|
||||
id: true,
|
||||
label: true,
|
||||
url: true,
|
||||
type: true,
|
||||
})
|
||||
.array()
|
||||
.optional(),
|
||||
|
||||
@ -388,9 +388,9 @@ export const formatDocumentAuditLogAction = (
|
||||
anonymous: msg`Document completed`,
|
||||
identified: msg`Document completed`,
|
||||
}))
|
||||
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_ATTACHMENTS_UPDATED }, ({ data }) => ({
|
||||
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_ATTACHMENTS_UPDATED }, () => ({
|
||||
anonymous: msg`Document attachments updated`,
|
||||
identified: msg`${prefix} updated the document attachments ${data.to.map((a) => a.label).join(', ')}`,
|
||||
identified: msg`${prefix} updated the document attachments`,
|
||||
}))
|
||||
.exhaustive();
|
||||
|
||||
|
||||
@ -171,7 +171,6 @@ export const AddSettingsFormPartial = ({
|
||||
formId: nanoid(12),
|
||||
label: '',
|
||||
url: '',
|
||||
type: 'LINK',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -63,7 +63,6 @@ export const ZAddSettingsFormSchema = z.object({
|
||||
id: true,
|
||||
label: true,
|
||||
url: true,
|
||||
type: true,
|
||||
})
|
||||
.extend({
|
||||
formId: z.string().min(1),
|
||||
|
||||
Reference in New Issue
Block a user