list and spreadsheet sub issues mutation issue (#4415)

This commit is contained in:
rahulramesha 2024-05-10 16:14:15 +05:30 committed by GitHub
parent 74eb50aa1a
commit b725c69882
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -34,7 +34,7 @@ export const IssueParentSelect: React.FC<TIssueParentSelect> = observer((props)
isParentIssueModalOpen, isParentIssueModalOpen,
toggleParentIssueModal, toggleParentIssueModal,
removeSubIssue, removeSubIssue,
subIssues: { setSubIssueHelpers }, subIssues: { setSubIssueHelpers, fetchSubIssues },
} = useIssueDetail(); } = useIssueDetail();
// derived values // derived values
@ -47,7 +47,8 @@ export const IssueParentSelect: React.FC<TIssueParentSelect> = observer((props)
try { try {
await issueOperations.update(workspaceSlug, projectId, issueId, { parent_id: _issueId }); await issueOperations.update(workspaceSlug, projectId, issueId, { parent_id: _issueId });
await issueOperations.fetch(workspaceSlug, projectId, issueId); await issueOperations.fetch(workspaceSlug, projectId, issueId);
toggleParentIssueModal(issueId); _issueId && (await fetchSubIssues(workspaceSlug, projectId, _issueId));
toggleParentIssueModal(null);
} catch (error) { } catch (error) {
console.error("something went wrong while fetching the issue"); console.error("something went wrong while fetching the issue");
} }
@ -62,6 +63,7 @@ export const IssueParentSelect: React.FC<TIssueParentSelect> = observer((props)
try { try {
setSubIssueHelpers(parentIssueId, "issue_loader", issueId); setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
await removeSubIssue(workspaceSlug, projectId, parentIssueId, issueId); await removeSubIssue(workspaceSlug, projectId, parentIssueId, issueId);
await fetchSubIssues(workspaceSlug, projectId, parentIssueId);
setSubIssueHelpers(parentIssueId, "issue_loader", issueId); setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
} catch (error) { } catch (error) {
setToast({ setToast({

View File

@ -57,11 +57,14 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id });
const issue = issuesMap[issueId]; const issue = issuesMap[issueId];
const subIssues = subIssuesStore.subIssuesByIssueId(issueId);
const { isMobile } = usePlatformOS(); const { isMobile } = usePlatformOS();
if (!issue) return null; if (!issue) return null;
const canEditIssueProperties = canEditProperties(issue.project_id); const canEditIssueProperties = canEditProperties(issue.project_id);
const projectIdentifier = getProjectIdentifierById(issue.project_id); const projectIdentifier = getProjectIdentifierById(issue.project_id);
// if sub issues have been fetched for the issue, use that for count or use issue's sub_issues_count
const subIssuesCount = subIssues ? subIssues.length : issue.sub_issues_count;
const paddingLeft = `${spacingLeft}px`; const paddingLeft = `${spacingLeft}px`;
@ -90,11 +93,11 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
} }
)} )}
> >
<div className="flex w-full truncate" style={issue.parent_id && nestingLevel !== 0 ? { paddingLeft } : {}}> <div className="flex w-full truncate" style={nestingLevel !== 0 ? { paddingLeft } : {}}>
<div className="flex flex-grow items-center gap-3 truncate"> <div className="flex flex-grow items-center gap-3 truncate">
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<div className="flex h-5 w-5 items-center justify-center"> <div className="flex h-5 w-5 items-center justify-center">
{issue.sub_issues_count > 0 && ( {subIssuesCount > 0 && (
<button <button
className="flex items-center justify-center h-5 w-5 cursor-pointer rounded-sm text-custom-text-400 hover:text-custom-text-300" className="flex items-center justify-center h-5 w-5 cursor-pointer rounded-sm text-custom-text-400 hover:text-custom-text-300"
onClick={handleToggleExpand} onClick={handleToggleExpand}

View File

@ -166,6 +166,7 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => {
const { subIssues: subIssuesStore, issue } = useIssueDetail(); const { subIssues: subIssuesStore, issue } = useIssueDetail();
const issueDetail = issue.getIssueById(issueId); const issueDetail = issue.getIssueById(issueId);
const subIssues = subIssuesStore.subIssuesByIssueId(issueId);
const paddingLeft = `${spacingLeft}px`; const paddingLeft = `${spacingLeft}px`;
@ -199,6 +200,8 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => {
}; };
const disableUserActions = !canEditProperties(issueDetail.project_id); const disableUserActions = !canEditProperties(issueDetail.project_id);
// if sub issues have been fetched for the issue, use that for count or use issue's sub_issues_count
const subIssuesCount = subIssues ? subIssues.length : issueDetail.sub_issues_count;
return ( return (
<> <>
@ -219,13 +222,13 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => {
> >
<div <div
className="flex min-w-min items-center gap-0.5 px-4 py-2.5 pl-1.5 pr-0" className="flex min-w-min items-center gap-0.5 px-4 py-2.5 pl-1.5 pr-0"
style={issueDetail.parent_id && nestingLevel !== 0 ? { paddingLeft } : {}} style={nestingLevel !== 0 ? { paddingLeft } : {}}
> >
<div className="flex items-center"> <div className="flex items-center">
{/* bulk ops */} {/* bulk ops */}
<span className="size-3.5" /> <span className="size-3.5" />
<div className="flex size-4 items-center justify-center"> <div className="flex size-4 items-center justify-center">
{issueDetail.sub_issues_count > 0 && ( {subIssuesCount > 0 && (
<button <button
className="flex items-center justify-center size-4 cursor-pointer rounded-sm text-custom-text-400 hover:text-custom-text-300" className="flex items-center justify-center size-4 cursor-pointer rounded-sm text-custom-text-400 hover:text-custom-text-300"
onClick={handleToggleExpand} onClick={handleToggleExpand}