chore: set all issue properties as true by default (#1640)

This commit is contained in:
Aaryan Khandelwal 2023-07-24 12:56:27 +05:30 committed by GitHub
parent e83ef7332d
commit f3b09a13b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 14 deletions

View File

@ -14,7 +14,7 @@ import { DangerButton, SecondaryButton } from "components/ui";
// icons
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
// types
import type { ICurrentUserResponse, ICycle } from "types";
import type { ICurrentUserResponse, ICycle, IProject } from "types";
type TConfirmCycleDeletionProps = {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
@ -27,6 +27,7 @@ import {
CURRENT_CYCLE_LIST,
CYCLES_LIST,
DRAFT_CYCLES_LIST,
PROJECT_DETAILS,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";
import { getDateRangeStatus } from "helpers/date-time.helper";
@ -50,7 +51,7 @@ export const DeleteCycleModal: React.FC<TConfirmCycleDeletionProps> = ({
};
const handleDeletion = async () => {
if (!data || !workspaceSlug) return;
if (!data || !workspaceSlug || !projectId) return;
setIsDeleteLoading(true);
@ -85,6 +86,21 @@ export const DeleteCycleModal: React.FC<TConfirmCycleDeletionProps> = ({
},
false
);
// update total cycles count in the project details
mutate<IProject>(
PROJECT_DETAILS(projectId.toString()),
(prevData) => {
if (!prevData) return prevData;
return {
...prevData,
total_cycles: prevData.total_cycles - 1,
};
},
false
);
handleClose();
setToastAlert({

View File

@ -15,7 +15,7 @@ import { CycleForm } from "components/cycles";
// helper
import { getDateRangeStatus } from "helpers/date-time.helper";
// types
import type { CycleDateCheckData, ICurrentUserResponse, ICycle } from "types";
import type { CycleDateCheckData, ICurrentUserResponse, ICycle, IProject } from "types";
// fetch keys
import {
COMPLETED_CYCLES_LIST,
@ -23,6 +23,7 @@ import {
CYCLES_LIST,
DRAFT_CYCLES_LIST,
INCOMPLETE_CYCLES_LIST,
PROJECT_DETAILS,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";
@ -66,6 +67,20 @@ export const CreateUpdateCycleModal: React.FC<CycleModalProps> = ({
mutate(INCOMPLETE_CYCLES_LIST(projectId.toString()));
mutate(CYCLES_LIST(projectId.toString()));
// update total cycles count in the project details
mutate<IProject>(
PROJECT_DETAILS(projectId.toString()),
(prevData) => {
if (!prevData) return prevData;
return {
...prevData,
total_cycles: prevData.total_cycles + 1,
};
},
false
);
setToastAlert({
type: "success",
title: "Success!",

View File

@ -1,5 +1,7 @@
import { useState, useEffect, useCallback } from "react";
import useSWR from "swr";
// services
import issueServices from "services/issues.service";
// hooks
@ -9,17 +11,17 @@ import { IssuePriorities, Properties } from "types";
const initialValues: Properties = {
assignee: true,
due_date: false,
due_date: true,
key: true,
labels: false,
priority: false,
labels: true,
priority: true,
state: true,
sub_issue_count: false,
attachment_count: false,
link: false,
estimate: false,
created_on: false,
updated_on: false,
sub_issue_count: true,
attachment_count: true,
link: true,
estimate: true,
created_on: true,
updated_on: true,
};
const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => {

View File

@ -176,8 +176,8 @@ const ProjectCycles: NextPage = () => {
</Tab.List>
<div className="justify-end sm:justify-start flex items-center gap-x-1">
{cycleViews.map((view) => {
if (view.key === "gantt" && (cycleTab === "Active" || cycleTab === "Drafts"))
return null;
if (cycleTab === "Active") return null;
if (view.key === "gantt" && cycleTab === "Drafts") return null;
return (
<button