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 = {
|
export type TrustCenterReferenceDialogRef = {
|
||||||
openCreate: (trustCenterId: string, connectionId: string) => void;
|
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 }>(
|
export const TrustCenterReferenceDialog = forwardRef<TrustCenterReferenceDialogRef, { children?: ReactNode }>(
|
||||||
@@ -72,7 +72,7 @@ export const TrustCenterReferenceDialog = forwardRef<TrustCenterReferenceDialogR
|
|||||||
});
|
});
|
||||||
dialogRef.current?.open();
|
dialogRef.current?.open();
|
||||||
},
|
},
|
||||||
openEdit: (reference: CompliancePageReferenceListItemFragment$data) => {
|
openEdit: (reference: CompliancePageReferenceListItemFragment$data, rank: number) => {
|
||||||
setMode("edit");
|
setMode("edit");
|
||||||
setEditReference(reference);
|
setEditReference(reference);
|
||||||
setUploadedFile(null);
|
setUploadedFile(null);
|
||||||
@@ -80,7 +80,7 @@ export const TrustCenterReferenceDialog = forwardRef<TrustCenterReferenceDialogR
|
|||||||
name: reference.name,
|
name: reference.name,
|
||||||
description: reference.description ?? undefined,
|
description: reference.description ?? undefined,
|
||||||
websiteUrl: reference.websiteUrl,
|
websiteUrl: reference.websiteUrl,
|
||||||
rank: reference.rank,
|
rank,
|
||||||
});
|
});
|
||||||
dialogRef.current?.open();
|
dialogRef.current?.open();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ export function CompliancePageReferencesPage(props: { queryRef: PreloadedQuery<C
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEdit = (reference: CompliancePageReferenceListItemFragment$data) => {
|
const handleEdit = (reference: CompliancePageReferenceListItemFragment$data, rank: number) => {
|
||||||
dialogRef.current?.openEdit(reference);
|
dialogRef.current?.openEdit(reference, rank);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const fragment = graphql`
|
|||||||
|
|
||||||
export function CompliancePageReferenceList(props: {
|
export function CompliancePageReferenceList(props: {
|
||||||
fragmentRef: CompliancePageReferenceListFragment$key;
|
fragmentRef: CompliancePageReferenceListFragment$key;
|
||||||
onEdit: (r: CompliancePageReferenceListItemFragment$data) => void;
|
onEdit: (r: CompliancePageReferenceListItemFragment$data, rank: number) => void;
|
||||||
}) {
|
}) {
|
||||||
const { fragmentRef, onEdit } = props;
|
const { fragmentRef, onEdit } = props;
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ export function CompliancePageReferenceList(props: {
|
|||||||
index={index}
|
index={index}
|
||||||
isDragging={draggedIndex === index}
|
isDragging={draggedIndex === index}
|
||||||
isDropTarget={dragOverIndex === index && draggedIndex !== index}
|
isDropTarget={dragOverIndex === index && draggedIndex !== index}
|
||||||
onEdit={(r: CompliancePageReferenceListItemFragment$data) => onEdit(r)}
|
onEdit={(r: CompliancePageReferenceListItemFragment$data) => onEdit(r, reference.rank)}
|
||||||
connectionId={references.__id}
|
connectionId={references.__id}
|
||||||
onDragStart={() => handleDragStart(index)}
|
onDragStart={() => handleDragStart(index)}
|
||||||
onDragOver={e => handleDragOver(e, index)}
|
onDragOver={e => handleDragOver(e, index)}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ const fragment = graphql`
|
|||||||
name
|
name
|
||||||
description
|
description
|
||||||
websiteUrl
|
websiteUrl
|
||||||
rank
|
|
||||||
canUpdate: permission(action: "core:trust-center-reference:update")
|
canUpdate: permission(action: "core:trust-center-reference:update")
|
||||||
canDelete: permission(action: "core:trust-center-reference:delete")
|
canDelete: permission(action: "core:trust-center-reference:delete")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,11 +118,13 @@ export function DocumentList(props: {
|
|||||||
|
|
||||||
const refetch = pagination.refetch;
|
const refetch = pagination.refetch;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refetch(
|
startTransition(() => {
|
||||||
{ status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null },
|
refetch(
|
||||||
{ fetchPolicy: "store-and-network" },
|
{ status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null },
|
||||||
);
|
{ fetchPolicy: "store-and-network" },
|
||||||
}, [tab, refetch]);
|
);
|
||||||
|
});
|
||||||
|
}, [tab, refetch, documentTypeFilter]);
|
||||||
|
|
||||||
const documents = pagination.data.documents.edges.map(({ node }) => node);
|
const documents = pagination.data.documents.edges.map(({ node }) => node);
|
||||||
const connectionId = pagination.data.documents.__id;
|
const connectionId = pagination.data.documents.__id;
|
||||||
@@ -145,7 +147,9 @@ export function DocumentList(props: {
|
|||||||
const canRequestAnySignatures = documents.some(({ canRequestSignatures }) => canRequestSignatures);
|
const canRequestAnySignatures = documents.some(({ canRequestSignatures }) => canRequestSignatures);
|
||||||
const canArchiveAny = documents.some(({ canArchive }) => canArchive);
|
const canArchiveAny = documents.some(({ canArchive }) => canArchive);
|
||||||
const canUnarchiveAny = documents.some(({ canUnarchive }) => canUnarchive);
|
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;
|
const hasAnyAction = tab === "ARCHIVED" ? canUnarchiveAny || canDeleteAny : canDeleteAny || canUpdateAny;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -170,12 +174,6 @@ export function DocumentList(props: {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
startTransition(() => {
|
|
||||||
pagination.refetch(
|
|
||||||
{ status: [tab], documentTypes: newType ? [newType] : null },
|
|
||||||
{ fetchPolicy: "store-and-network" },
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBulkDelete = () => {
|
const handleBulkDelete = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user