Fix frontend lint warnings in documents and references
- Remove unused `rank` field from CompliancePageReferenceListItemFragment; the parent list fragment already fetches it for drag-and-drop reordering. Thread `rank` through the onEdit call chain so the edit dialog can still pre-populate the field via a dedicated parameter instead of the fragment. - Add missing `documentTypeFilter` dependency to the refetch useEffect in DocumentList so stale closure values are never used on tab change. - Break overlong line in DocumentList (canSendAnySignatureNotifications). Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -31,7 +31,7 @@ type ReferenceFormData = z.infer<typeof referenceSchema>;
|
||||
|
||||
export type TrustCenterReferenceDialogRef = {
|
||||
openCreate: (trustCenterId: string, connectionId: string) => void;
|
||||
openEdit: (reference: CompliancePageReferenceListItemFragment$data) => void;
|
||||
openEdit: (reference: CompliancePageReferenceListItemFragment$data, rank: number) => void;
|
||||
};
|
||||
|
||||
export const TrustCenterReferenceDialog = forwardRef<TrustCenterReferenceDialogRef, { children?: ReactNode }>(
|
||||
@@ -72,7 +72,7 @@ export const TrustCenterReferenceDialog = forwardRef<TrustCenterReferenceDialogR
|
||||
});
|
||||
dialogRef.current?.open();
|
||||
},
|
||||
openEdit: (reference: CompliancePageReferenceListItemFragment$data) => {
|
||||
openEdit: (reference: CompliancePageReferenceListItemFragment$data, rank: number) => {
|
||||
setMode("edit");
|
||||
setEditReference(reference);
|
||||
setUploadedFile(null);
|
||||
@@ -80,7 +80,7 @@ export const TrustCenterReferenceDialog = forwardRef<TrustCenterReferenceDialogR
|
||||
name: reference.name,
|
||||
description: reference.description ?? undefined,
|
||||
websiteUrl: reference.websiteUrl,
|
||||
rank: reference.rank,
|
||||
rank,
|
||||
});
|
||||
dialogRef.current?.open();
|
||||
},
|
||||
|
||||
@@ -50,8 +50,8 @@ export function CompliancePageReferencesPage(props: { queryRef: PreloadedQuery<C
|
||||
}
|
||||
};
|
||||
|
||||
const handleEdit = (reference: CompliancePageReferenceListItemFragment$data) => {
|
||||
dialogRef.current?.openEdit(reference);
|
||||
const handleEdit = (reference: CompliancePageReferenceListItemFragment$data, rank: number) => {
|
||||
dialogRef.current?.openEdit(reference, rank);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -35,7 +35,7 @@ const fragment = graphql`
|
||||
|
||||
export function CompliancePageReferenceList(props: {
|
||||
fragmentRef: CompliancePageReferenceListFragment$key;
|
||||
onEdit: (r: CompliancePageReferenceListItemFragment$data) => void;
|
||||
onEdit: (r: CompliancePageReferenceListItemFragment$data, rank: number) => void;
|
||||
}) {
|
||||
const { fragmentRef, onEdit } = props;
|
||||
|
||||
@@ -116,7 +116,7 @@ export function CompliancePageReferenceList(props: {
|
||||
index={index}
|
||||
isDragging={draggedIndex === index}
|
||||
isDropTarget={dragOverIndex === index && draggedIndex !== index}
|
||||
onEdit={(r: CompliancePageReferenceListItemFragment$data) => onEdit(r)}
|
||||
onEdit={(r: CompliancePageReferenceListItemFragment$data) => onEdit(r, reference.rank)}
|
||||
connectionId={references.__id}
|
||||
onDragStart={() => handleDragStart(index)}
|
||||
onDragOver={e => handleDragOver(e, index)}
|
||||
|
||||
@@ -14,7 +14,6 @@ const fragment = graphql`
|
||||
name
|
||||
description
|
||||
websiteUrl
|
||||
rank
|
||||
canUpdate: permission(action: "core:trust-center-reference:update")
|
||||
canDelete: permission(action: "core:trust-center-reference:delete")
|
||||
}
|
||||
|
||||
@@ -118,11 +118,13 @@ export function DocumentList(props: {
|
||||
|
||||
const refetch = pagination.refetch;
|
||||
useEffect(() => {
|
||||
refetch(
|
||||
{ status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null },
|
||||
{ fetchPolicy: "store-and-network" },
|
||||
);
|
||||
}, [tab, refetch]);
|
||||
startTransition(() => {
|
||||
refetch(
|
||||
{ status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null },
|
||||
{ fetchPolicy: "store-and-network" },
|
||||
);
|
||||
});
|
||||
}, [tab, refetch, documentTypeFilter]);
|
||||
|
||||
const documents = pagination.data.documents.edges.map(({ node }) => node);
|
||||
const connectionId = pagination.data.documents.__id;
|
||||
@@ -145,7 +147,9 @@ export function DocumentList(props: {
|
||||
const canRequestAnySignatures = documents.some(({ canRequestSignatures }) => canRequestSignatures);
|
||||
const canArchiveAny = documents.some(({ canArchive }) => canArchive);
|
||||
const canUnarchiveAny = documents.some(({ canUnarchive }) => canUnarchive);
|
||||
const canSendAnySignatureNotifications = documents.some(({ canSendSigningNotifications }) => canSendSigningNotifications);
|
||||
const canSendAnySignatureNotifications = documents.some(
|
||||
({ canSendSigningNotifications }) => canSendSigningNotifications,
|
||||
);
|
||||
const hasAnyAction = tab === "ARCHIVED" ? canUnarchiveAny || canDeleteAny : canDeleteAny || canUpdateAny;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -170,12 +174,6 @@ export function DocumentList(props: {
|
||||
},
|
||||
),
|
||||
);
|
||||
startTransition(() => {
|
||||
pagination.refetch(
|
||||
{ status: [tab], documentTypes: newType ? [newType] : null },
|
||||
{ fetchPolicy: "store-and-network" },
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const handleBulkDelete = () => {
|
||||
|
||||
Reference in New Issue
Block a user