"use client"; import React, { useState } from "react"; import { observer } from "mobx-react"; // icons import { ArchiveX } from "lucide-react"; // types import { IProject } from "@plane/types"; // ui import { CustomSelect, CustomSearchSelect, ToggleSwitch, StateGroupIcon, DoubleCircleIcon, Loader } from "@plane/ui"; // component import { SelectMonthModal } from "@/components/automation"; // constants import { PROJECT_AUTOMATION_MONTHS } from "@/constants/project"; // hooks import { useProject, useProjectState, useUserPermissions } from "@/hooks/store"; import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; type Props = { handleChange: (formData: Partial) => Promise; }; export const AutoCloseAutomation: React.FC = observer((props) => { const { handleChange } = props; // states const [monthModal, setmonthModal] = useState(false); // store hooks const { currentProjectDetails } = useProject(); const { projectStates } = useProjectState(); const { allowPermissions } = useUserPermissions(); // const stateGroups = projectStateStore.groupedProjectStates ?? undefined; const options = projectStates ?.filter((state) => state.group === "cancelled") .map((state) => ({ value: state.id, query: state.name, content: (
{state.name}
), })); const multipleOptions = (options ?? []).length > 1; const defaultState = projectStates?.find((s) => s.group === "cancelled")?.id || null; const selectedOption = projectStates?.find((s) => s.id === (currentProjectDetails?.default_state ?? defaultState)); const currentDefaultState = projectStates?.find((s) => s.id === defaultState); const initialValues: Partial = { close_in: 1, default_state: defaultState, }; const isAdmin = allowPermissions( [EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT, currentProjectDetails?.workspace_detail?.slug, currentProjectDetails?.id ); return ( <> setmonthModal(false)} handleChange={handleChange} />

Auto-close issues

Plane will automatically close issues that haven{"'"}t been completed or canceled.

currentProjectDetails?.close_in === 0 ? handleChange({ close_in: 1, default_state: defaultState }) : handleChange({ close_in: 0, default_state: null }) } size="sm" disabled={!isAdmin} />
{currentProjectDetails ? ( currentProjectDetails.close_in !== 0 && (
Auto-close issues that are inactive for
{ handleChange({ close_in: val }); }} input disabled={!isAdmin} > <> {PROJECT_AUTOMATION_MONTHS.map((month) => ( {month.label} ))}
Auto-close status
{selectedOption ? ( ) : currentDefaultState ? ( ) : ( )} {selectedOption?.name ? selectedOption.name : (currentDefaultState?.name ?? State)}
} onChange={(val: string) => { handleChange({ default_state: val }); }} options={options} disabled={!multipleOptions} input />
) ) : ( )} ); });