[WEB-2326] fix: issue activity mutation on attachments upload. (#5886)
This commit is contained in:
parent
074ad6d1a4
commit
bf220666dd
3 changed files with 21 additions and 5 deletions
|
|
@ -17,13 +17,14 @@ type TAttachmentOperationsRemoveModal = Exclude<TAttachmentOperations, "create">
|
||||||
|
|
||||||
type TIssueAttachmentItemList = {
|
type TIssueAttachmentItemList = {
|
||||||
workspaceSlug: string;
|
workspaceSlug: string;
|
||||||
|
projectId: string;
|
||||||
issueId: string;
|
issueId: string;
|
||||||
handleAttachmentOperations: TAttachmentOperationsRemoveModal;
|
handleAttachmentOperations: TAttachmentOperationsRemoveModal;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((props) => {
|
export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((props) => {
|
||||||
const { workspaceSlug, issueId, handleAttachmentOperations, disabled } = props;
|
const { workspaceSlug, projectId, issueId, handleAttachmentOperations, disabled } = props;
|
||||||
// states
|
// states
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
// store hooks
|
// store hooks
|
||||||
|
|
@ -31,12 +32,18 @@ export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((p
|
||||||
attachment: { getAttachmentsByIssueId },
|
attachment: { getAttachmentsByIssueId },
|
||||||
attachmentDeleteModalId,
|
attachmentDeleteModalId,
|
||||||
toggleDeleteAttachmentModal,
|
toggleDeleteAttachmentModal,
|
||||||
|
fetchActivities,
|
||||||
} = useIssueDetail();
|
} = useIssueDetail();
|
||||||
// file size
|
// file size
|
||||||
const { maxFileSize } = useFileSize();
|
const { maxFileSize } = useFileSize();
|
||||||
// derived values
|
// derived values
|
||||||
const issueAttachments = getAttachmentsByIssueId(issueId);
|
const issueAttachments = getAttachmentsByIssueId(issueId);
|
||||||
|
|
||||||
|
// handlers
|
||||||
|
const handleFetchPropertyActivities = useCallback(() => {
|
||||||
|
fetchActivities(workspaceSlug, projectId, issueId);
|
||||||
|
}, [fetchActivities, workspaceSlug, projectId, issueId]);
|
||||||
|
|
||||||
const onDrop = useCallback(
|
const onDrop = useCallback(
|
||||||
(acceptedFiles: File[], rejectedFiles: FileRejection[]) => {
|
(acceptedFiles: File[], rejectedFiles: FileRejection[]) => {
|
||||||
const totalAttachedFiles = acceptedFiles.length + rejectedFiles.length;
|
const totalAttachedFiles = acceptedFiles.length + rejectedFiles.length;
|
||||||
|
|
@ -55,7 +62,10 @@ export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((p
|
||||||
message: "File could not be attached. Try uploading again.",
|
message: "File could not be attached. Try uploading again.",
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => setIsLoading(false));
|
.finally(() => {
|
||||||
|
handleFetchPropertyActivities();
|
||||||
|
setIsLoading(false);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +79,7 @@ export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((p
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
[handleAttachmentOperations, maxFileSize, workspaceSlug]
|
[handleAttachmentOperations, maxFileSize, workspaceSlug, handleFetchPropertyActivities]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export const IssueAttachmentsCollapsibleContent: FC<Props> = (props) => {
|
||||||
return (
|
return (
|
||||||
<IssueAttachmentItemList
|
<IssueAttachmentItemList
|
||||||
workspaceSlug={workspaceSlug}
|
workspaceSlug={workspaceSlug}
|
||||||
|
projectId={projectId}
|
||||||
issueId={issueId}
|
issueId={issueId}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
handleAttachmentOperations={handleAttachmentOperations}
|
handleAttachmentOperations={handleAttachmentOperations}
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,16 @@ export const IssueAttachmentActionButton: FC<Props> = observer((props) => {
|
||||||
// state
|
// state
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
// store hooks
|
// store hooks
|
||||||
const { setLastWidgetAction } = useIssueDetail();
|
const { setLastWidgetAction, fetchActivities } = useIssueDetail();
|
||||||
// file size
|
// file size
|
||||||
const { maxFileSize } = useFileSize();
|
const { maxFileSize } = useFileSize();
|
||||||
// operations
|
// operations
|
||||||
const handleAttachmentOperations = useAttachmentOperations(workspaceSlug, projectId, issueId);
|
const handleAttachmentOperations = useAttachmentOperations(workspaceSlug, projectId, issueId);
|
||||||
// handlers
|
// handlers
|
||||||
|
const handleFetchPropertyActivities = useCallback(() => {
|
||||||
|
fetchActivities(workspaceSlug, projectId, issueId);
|
||||||
|
}, [fetchActivities, workspaceSlug, projectId, issueId]);
|
||||||
|
|
||||||
const onDrop = useCallback(
|
const onDrop = useCallback(
|
||||||
(acceptedFiles: File[], rejectedFiles: FileRejection[]) => {
|
(acceptedFiles: File[], rejectedFiles: FileRejection[]) => {
|
||||||
const totalAttachedFiles = acceptedFiles.length + rejectedFiles.length;
|
const totalAttachedFiles = acceptedFiles.length + rejectedFiles.length;
|
||||||
|
|
@ -51,6 +55,7 @@ export const IssueAttachmentActionButton: FC<Props> = observer((props) => {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
handleFetchPropertyActivities();
|
||||||
setLastWidgetAction("attachments");
|
setLastWidgetAction("attachments");
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
|
|
@ -67,7 +72,7 @@ export const IssueAttachmentActionButton: FC<Props> = observer((props) => {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
[handleAttachmentOperations, maxFileSize, workspaceSlug]
|
[maxFileSize, workspaceSlug, handleAttachmentOperations, handleFetchPropertyActivities, setLastWidgetAction]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { getRootProps, getInputProps } = useDropzone({
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue