[WEB-3102]fix: transfer issues count (#6384)
* fix: updated cancelled issues count into pending issues * chore: code refactor * chore: added pending issues count * chore: added pending issues count * chore: added pending_issues to api response --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
996d11de12
commit
369d927321
5 changed files with 34 additions and 18 deletions
|
|
@ -132,6 +132,18 @@ class CycleViewSet(BaseViewSet):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.annotate(
|
||||||
|
pending_issues=Count(
|
||||||
|
"issue_cycle__issue__id",
|
||||||
|
distinct=True,
|
||||||
|
filter=Q(
|
||||||
|
issue_cycle__issue__state__group__in=["backlog", "unstarted", "started"],
|
||||||
|
issue_cycle__issue__archived_at__isnull=True,
|
||||||
|
issue_cycle__issue__is_draft=False,
|
||||||
|
issue_cycle__deleted_at__isnull=True,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
status=Case(
|
status=Case(
|
||||||
When(
|
When(
|
||||||
|
|
@ -214,6 +226,7 @@ class CycleViewSet(BaseViewSet):
|
||||||
"is_favorite",
|
"is_favorite",
|
||||||
"total_issues",
|
"total_issues",
|
||||||
"completed_issues",
|
"completed_issues",
|
||||||
|
"pending_issues",
|
||||||
"assignee_ids",
|
"assignee_ids",
|
||||||
"status",
|
"status",
|
||||||
"version",
|
"version",
|
||||||
|
|
@ -245,6 +258,7 @@ class CycleViewSet(BaseViewSet):
|
||||||
# meta fields
|
# meta fields
|
||||||
"is_favorite",
|
"is_favorite",
|
||||||
"total_issues",
|
"total_issues",
|
||||||
|
"pending_issues",
|
||||||
"completed_issues",
|
"completed_issues",
|
||||||
"assignee_ids",
|
"assignee_ids",
|
||||||
"status",
|
"status",
|
||||||
|
|
|
||||||
5
packages/types/src/cycle/cycle.d.ts
vendored
5
packages/types/src/cycle/cycle.d.ts
vendored
|
|
@ -104,6 +104,7 @@ export interface ICycle extends TProgressSnapshot {
|
||||||
project_detail: IProjectDetails;
|
project_detail: IProjectDetails;
|
||||||
progress: any[];
|
progress: any[];
|
||||||
version: number;
|
version: number;
|
||||||
|
pending_issues: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CycleIssueResponse {
|
export interface CycleIssueResponse {
|
||||||
|
|
@ -120,9 +121,7 @@ export interface CycleIssueResponse {
|
||||||
sub_issues_count: number;
|
sub_issues_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SelectCycleType =
|
export type SelectCycleType = (ICycle & { actionType: "edit" | "delete" | "create-issue" }) | undefined;
|
||||||
| (ICycle & { actionType: "edit" | "delete" | "create-issue" })
|
|
||||||
| undefined;
|
|
||||||
|
|
||||||
export type CycleDateCheckData = {
|
export type CycleDateCheckData = {
|
||||||
start_date: string;
|
start_date: string;
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,11 @@ export const CycleListItemAction: FC<Props> = observer((props) => {
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const cycleStatus = cycleDetails.status ? (cycleDetails.status.toLocaleLowerCase() as TCycleGroups) : "draft";
|
const cycleStatus = cycleDetails.status ? (cycleDetails.status.toLocaleLowerCase() as TCycleGroups) : "draft";
|
||||||
|
|
||||||
const showIssueCount = useMemo(() => cycleStatus === "draft" || cycleStatus === "upcoming", [cycleStatus]);
|
const showIssueCount = useMemo(() => cycleStatus === "draft" || cycleStatus === "upcoming", [cycleStatus]);
|
||||||
const transferableIssuesCount = cycleDetails ? cycleDetails.total_issues - cycleDetails.completed_issues : 0;
|
|
||||||
const showTransferIssues = routerProjectId && transferableIssuesCount > 0 && cycleStatus === "completed"; // Only available inside project view.
|
const showTransferIssues = cycleDetails.pending_issues > 0 && cycleStatus === "completed";
|
||||||
|
|
||||||
const isEditingAllowed = allowPermissions(
|
const isEditingAllowed = allowPermissions(
|
||||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
||||||
EUserPermissionsLevel.PROJECT,
|
EUserPermissionsLevel.PROJECT,
|
||||||
|
|
@ -256,7 +258,7 @@ export const CycleListItemAction: FC<Props> = observer((props) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TransferIcon className="fill-custom-primary-200 w-4" />
|
<TransferIcon className="fill-custom-primary-200 w-4" />
|
||||||
<span>Transfer {transferableIssuesCount} issues</span>
|
<span>Transfer {cycleDetails.pending_issues} issues</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
|
||||||
const isArchived = !!cycleDetails?.archived_at;
|
const isArchived = !!cycleDetails?.archived_at;
|
||||||
const isCompleted = cycleDetails?.status?.toLowerCase() === "completed";
|
const isCompleted = cycleDetails?.status?.toLowerCase() === "completed";
|
||||||
const isCurrentCycle = cycleDetails?.status?.toLowerCase() === "current";
|
const isCurrentCycle = cycleDetails?.status?.toLowerCase() === "current";
|
||||||
const transferableIssuesCount = cycleDetails ? cycleDetails.total_issues - cycleDetails.completed_issues : 0;
|
|
||||||
// auth
|
// auth
|
||||||
const isEditingAllowed = allowPermissions(
|
const isEditingAllowed = allowPermissions(
|
||||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
||||||
|
|
@ -170,14 +169,16 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
|
||||||
workspaceSlug={workspaceSlug}
|
workspaceSlug={workspaceSlug}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
<EndCycleModal
|
{isCurrentCycle && (
|
||||||
isOpen={isEndCycleModalOpen}
|
<EndCycleModal
|
||||||
handleClose={() => setEndCycleModalOpen(false)}
|
isOpen={isEndCycleModalOpen}
|
||||||
cycleId={cycleId}
|
handleClose={() => setEndCycleModalOpen(false)}
|
||||||
projectId={projectId}
|
cycleId={cycleId}
|
||||||
workspaceSlug={workspaceSlug}
|
projectId={projectId}
|
||||||
transferrableIssuesCount={transferableIssuesCount}
|
workspaceSlug={workspaceSlug}
|
||||||
/>
|
transferrableIssuesCount={cycleDetails.pending_issues}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<ContextMenu parentRef={parentRef} items={MENU_ITEMS} />
|
<ContextMenu parentRef={parentRef} items={MENU_ITEMS} />
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export const TransferIssuesModal: React.FC<Props> = observer((props) => {
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
|
|
||||||
// store hooks
|
// store hooks
|
||||||
const { currentProjectIncompleteCycleIds, getCycleById, fetchCycleDetails } = useCycle();
|
const { currentProjectIncompleteCycleIds, getCycleById, fetchActiveCycleProgress } = useCycle();
|
||||||
const {
|
const {
|
||||||
issues: { transferIssuesFromCycle },
|
issues: { transferIssuesFromCycle },
|
||||||
} = useIssues(EIssuesStoreType.CYCLE);
|
} = useIssues(EIssuesStoreType.CYCLE);
|
||||||
|
|
@ -57,8 +57,8 @@ export const TransferIssuesModal: React.FC<Props> = observer((props) => {
|
||||||
/**To update issue counts in target cycle and current cycle */
|
/**To update issue counts in target cycle and current cycle */
|
||||||
const getCycleDetails = async (newCycleId: string) => {
|
const getCycleDetails = async (newCycleId: string) => {
|
||||||
const cyclesFetch = [
|
const cyclesFetch = [
|
||||||
fetchCycleDetails(workspaceSlug.toString(), projectId.toString(), cycleId),
|
fetchActiveCycleProgress(workspaceSlug.toString(), projectId.toString(), cycleId),
|
||||||
fetchCycleDetails(workspaceSlug.toString(), projectId.toString(), newCycleId),
|
fetchActiveCycleProgress(workspaceSlug.toString(), projectId.toString(), newCycleId),
|
||||||
];
|
];
|
||||||
await Promise.all(cyclesFetch).catch((error) => {
|
await Promise.all(cyclesFetch).catch((error) => {
|
||||||
setToast({
|
setToast({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue