mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 01:32:06 +10:00
chore: minor updates
This commit is contained in:
@ -43,7 +43,7 @@ export const DocumentSigningCheckboxField = ({
|
|||||||
|
|
||||||
const { recipient, isAssistantMode } = useDocumentSigningRecipientContext();
|
const { recipient, isAssistantMode } = useDocumentSigningRecipientContext();
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const parsedFieldMeta = ZCheckboxFieldMeta.parse(
|
const parsedFieldMeta = ZCheckboxFieldMeta.parse(
|
||||||
field.fieldMeta ?? {
|
field.fieldMeta ?? {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ export const DocumentSigningDropdownField = ({
|
|||||||
|
|
||||||
const { recipient, isAssistantMode } = useDocumentSigningRecipientContext();
|
const { recipient, isAssistantMode } = useDocumentSigningRecipientContext();
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const parsedFieldMeta = ZDropdownFieldMeta.parse(field.fieldMeta);
|
const parsedFieldMeta = ZDropdownFieldMeta.parse(field.fieldMeta);
|
||||||
const isReadOnly = parsedFieldMeta?.readOnly;
|
const isReadOnly = parsedFieldMeta?.readOnly;
|
||||||
|
|||||||
@ -62,7 +62,7 @@ export const DocumentSigningFieldContainer = ({
|
|||||||
type,
|
type,
|
||||||
tooltipText,
|
tooltipText,
|
||||||
}: DocumentSigningFieldContainerProps) => {
|
}: DocumentSigningFieldContainerProps) => {
|
||||||
const { executeActionAuthProcedure, isAuthRedirectRequired, isEnterprise } =
|
const { executeActionAuthProcedure, isAuthRedirectRequired } =
|
||||||
useRequiredDocumentSigningAuthContext();
|
useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const parsedFieldMeta = field.fieldMeta ? ZFieldMetaSchema.parse(field.fieldMeta) : undefined;
|
const parsedFieldMeta = field.fieldMeta ? ZFieldMetaSchema.parse(field.fieldMeta) : undefined;
|
||||||
|
|||||||
@ -48,7 +48,7 @@ export const DocumentSigningNameField = ({
|
|||||||
|
|
||||||
const { recipient, isAssistantMode } = useDocumentSigningRecipientContext();
|
const { recipient, isAssistantMode } = useDocumentSigningRecipientContext();
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
||||||
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
||||||
|
|||||||
@ -72,7 +72,7 @@ export const DocumentSigningNumberField = ({
|
|||||||
|
|
||||||
const [errors, setErrors] = useState(initialErrors);
|
const [errors, setErrors] = useState(initialErrors);
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
||||||
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ export const DocumentSigningRadioField = ({
|
|||||||
|
|
||||||
const [selectedOption, setSelectedOption] = useState(defaultValue);
|
const [selectedOption, setSelectedOption] = useState(defaultValue);
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
||||||
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
||||||
|
|||||||
@ -59,7 +59,7 @@ export const DocumentSigningSignatureField = ({
|
|||||||
const { signature: providedSignature, setSignature: setProvidedSignature } =
|
const { signature: providedSignature, setSignature: setProvidedSignature } =
|
||||||
useRequiredDocumentSigningContext();
|
useRequiredDocumentSigningContext();
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
||||||
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
||||||
|
|||||||
@ -62,7 +62,7 @@ export const DocumentSigningTextField = ({
|
|||||||
const [errors, setErrors] = useState(initialErrors);
|
const [errors, setErrors] = useState(initialErrors);
|
||||||
const userInputHasErrors = Object.values(errors).some((error) => error.length > 0);
|
const userInputHasErrors = Object.values(errors).some((error) => error.length > 0);
|
||||||
|
|
||||||
const { executeActionAuthProcedure, isEnterprise } = useRequiredDocumentSigningAuthContext();
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
|
||||||
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
const { mutateAsync: signFieldWithToken, isPending: isSignFieldWithTokenLoading } =
|
||||||
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
trpc.field.signFieldWithToken.useMutation(DO_NOT_INVALIDATE_QUERY_ON_MUTATION);
|
||||||
|
|||||||
@ -114,7 +114,6 @@ export const updateDocument = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no data just return the document since this function is normally chained after a meta update.
|
|
||||||
if (!data || Object.values(data).length === 0) {
|
if (!data || Object.values(data).length === 0) {
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
@ -126,26 +125,11 @@ export const updateDocument = async ({
|
|||||||
const documentGlobalAccessAuth = documentAuthOption?.globalAccessAuth ?? null;
|
const documentGlobalAccessAuth = documentAuthOption?.globalAccessAuth ?? null;
|
||||||
const documentGlobalActionAuth = documentAuthOption?.globalActionAuth ?? null;
|
const documentGlobalActionAuth = documentAuthOption?.globalActionAuth ?? null;
|
||||||
|
|
||||||
// If the new global auth values aren't passed in, fallback to the current document values.
|
|
||||||
const newGlobalAccessAuth =
|
const newGlobalAccessAuth =
|
||||||
data?.globalAccessAuth === undefined ? documentGlobalAccessAuth : data.globalAccessAuth;
|
data?.globalAccessAuth === undefined ? documentGlobalAccessAuth : data.globalAccessAuth;
|
||||||
const newGlobalActionAuth =
|
const newGlobalActionAuth =
|
||||||
data?.globalActionAuth === undefined ? documentGlobalActionAuth : data.globalActionAuth;
|
data?.globalActionAuth === undefined ? documentGlobalActionAuth : data.globalActionAuth;
|
||||||
|
|
||||||
// Check if user has permission to set the global action auth.
|
|
||||||
// if (newGlobalActionAuth) {
|
|
||||||
// const isDocumentEnterprise = await isUserEnterprise({
|
|
||||||
// userId,
|
|
||||||
// teamId,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (!isDocumentEnterprise) {
|
|
||||||
// throw new AppError(AppErrorCode.UNAUTHORIZED, {
|
|
||||||
// message: 'You do not have permission to set the action auth',
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
const isTitleSame = data.title === undefined || data.title === document.title;
|
const isTitleSame = data.title === undefined || data.title === document.title;
|
||||||
const isExternalIdSame = data.externalId === undefined || data.externalId === document.externalId;
|
const isExternalIdSame = data.externalId === undefined || data.externalId === document.externalId;
|
||||||
const isGlobalAccessSame =
|
const isGlobalAccessSame =
|
||||||
@ -233,7 +217,6 @@ export const updateDocument = async ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Early return if nothing is required.
|
|
||||||
if (auditLogs.length === 0) {
|
if (auditLogs.length === 0) {
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,12 @@ export const DocumentGlobalAuthActionSelect = forwardRef<
|
|||||||
>(({ isDocumentEnterprise, ...props }, ref) => {
|
>(({ isDocumentEnterprise, ...props }, ref) => {
|
||||||
const { _ } = useLingui();
|
const { _ } = useLingui();
|
||||||
|
|
||||||
|
const authTypes = isDocumentEnterprise
|
||||||
|
? Object.values(DocumentActionAuth).filter((auth) => auth !== DocumentAuth.ACCOUNT)
|
||||||
|
: Object.values(NonEnterpriseDocumentActionAuth).filter(
|
||||||
|
(auth) => auth !== DocumentAuth.EXPLICIT_NONE,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select {...props}>
|
<Select {...props}>
|
||||||
<SelectTrigger className="bg-background text-muted-foreground">
|
<SelectTrigger className="bg-background text-muted-foreground">
|
||||||
@ -47,21 +53,11 @@ export const DocumentGlobalAuthActionSelect = forwardRef<
|
|||||||
<Trans>No restrictions</Trans>
|
<Trans>No restrictions</Trans>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
|
||||||
{isDocumentEnterprise
|
{authTypes.map((authType) => (
|
||||||
? Object.values(DocumentActionAuth)
|
<SelectItem key={authType} value={authType}>
|
||||||
.filter((auth) => auth !== DocumentAuth.ACCOUNT)
|
{DOCUMENT_AUTH_TYPES[authType].value}
|
||||||
.map((authType) => (
|
</SelectItem>
|
||||||
<SelectItem key={authType} value={authType}>
|
))}
|
||||||
{DOCUMENT_AUTH_TYPES[authType].value}
|
|
||||||
</SelectItem>
|
|
||||||
))
|
|
||||||
: Object.values(NonEnterpriseDocumentActionAuth)
|
|
||||||
.filter((auth) => auth !== DocumentAuth.EXPLICIT_NONE)
|
|
||||||
.map((authType) => (
|
|
||||||
<SelectItem key={authType} value={authType}>
|
|
||||||
{DOCUMENT_AUTH_TYPES[authType].value}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user