chore: created a new constant for archivable state groups (#4668)

This commit is contained in:
Aaryan Khandelwal 2024-05-31 17:39:23 +05:30 committed by GitHub
parent 98ebe88c86
commit 830f0861c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 14 additions and 18 deletions

View File

@ -48,7 +48,7 @@ import {
} from "@/components/issues"; } from "@/components/issues";
// helpers // helpers
// types // types
import { STATE_GROUPS } from "@/constants/state"; import { ARCHIVABLE_STATE_GROUPS } from "@/constants/state";
import { cn } from "@/helpers/common.helper"; import { cn } from "@/helpers/common.helper";
import { getDate, renderFormattedPayloadDate } from "@/helpers/date-time.helper"; import { getDate, renderFormattedPayloadDate } from "@/helpers/date-time.helper";
import { shouldHighlightIssueDueDate } from "@/helpers/issue.helper"; import { shouldHighlightIssueDueDate } from "@/helpers/issue.helper";
@ -117,8 +117,7 @@ export const IssueDetailsSidebar: React.FC<Props> = observer((props) => {
const stateDetails = getStateById(issue.state_id); const stateDetails = getStateById(issue.state_id);
// auth // auth
const isArchivingAllowed = !is_archived && issueOperations.archive && isEditable; const isArchivingAllowed = !is_archived && issueOperations.archive && isEditable;
const isInArchivableGroup = const isInArchivableGroup = !!stateDetails && ARCHIVABLE_STATE_GROUPS.includes(stateDetails?.group);
!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);
const minDate = issue.start_date ? getDate(issue.start_date) : null; const minDate = issue.start_date ? getDate(issue.start_date) : null;
minDate?.setDate(minDate.getDate()); minDate?.setDate(minDate.getDate());

View File

@ -11,7 +11,7 @@ import { ArchiveIcon, ContextMenu, CustomMenu, TContextMenuItem, TOAST_TYPE, set
import { ArchiveIssueModal, CreateUpdateIssueModal, DeleteIssueModal } from "@/components/issues"; import { ArchiveIssueModal, CreateUpdateIssueModal, DeleteIssueModal } from "@/components/issues";
// constants // constants
import { EIssuesStoreType } from "@/constants/issue"; import { EIssuesStoreType } from "@/constants/issue";
import { STATE_GROUPS } from "@/constants/state"; import { ARCHIVABLE_STATE_GROUPS } from "@/constants/state";
// helpers // helpers
import { cn } from "@/helpers/common.helper"; import { cn } from "@/helpers/common.helper";
import { copyUrlToClipboard } from "@/helpers/string.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper";
@ -48,8 +48,7 @@ export const AllIssueQuickActions: React.FC<IQuickActionProps> = observer((props
const isEditingAllowed = !readOnly; const isEditingAllowed = !readOnly;
// auth // auth
const isArchivingAllowed = handleArchive && isEditingAllowed; const isArchivingAllowed = handleArchive && isEditingAllowed;
const isInArchivableGroup = const isInArchivableGroup = !!stateDetails && ARCHIVABLE_STATE_GROUPS.includes(stateDetails?.group);
!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);
const issueLink = `${workspaceSlug}/projects/${issue.project_id}/issues/${issue.id}`; const issueLink = `${workspaceSlug}/projects/${issue.project_id}/issues/${issue.id}`;

View File

@ -12,7 +12,7 @@ import { ArchiveIssueModal, CreateUpdateIssueModal, DeleteIssueModal } from "@/c
// constants // constants
import { EIssuesStoreType } from "@/constants/issue"; import { EIssuesStoreType } from "@/constants/issue";
import { EUserProjectRoles } from "@/constants/project"; import { EUserProjectRoles } from "@/constants/project";
import { STATE_GROUPS } from "@/constants/state"; import { ARCHIVABLE_STATE_GROUPS } from "@/constants/state";
// helpers // helpers
import { cn } from "@/helpers/common.helper"; import { cn } from "@/helpers/common.helper";
import { copyUrlToClipboard } from "@/helpers/string.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper";
@ -54,8 +54,7 @@ export const CycleIssueQuickActions: React.FC<IQuickActionProps> = observer((pro
// auth // auth
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly; const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly;
const isArchivingAllowed = handleArchive && isEditingAllowed; const isArchivingAllowed = handleArchive && isEditingAllowed;
const isInArchivableGroup = const isInArchivableGroup = !!stateDetails && ARCHIVABLE_STATE_GROUPS.includes(stateDetails?.group);
!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);
const isDeletingAllowed = isEditingAllowed; const isDeletingAllowed = isEditingAllowed;
const activeLayout = `${issuesFilter.issueFilters?.displayFilters?.layout} layout`; const activeLayout = `${issuesFilter.issueFilters?.displayFilters?.layout} layout`;

View File

@ -12,7 +12,7 @@ import { ArchiveIssueModal, CreateUpdateIssueModal, DeleteIssueModal } from "@/c
// constants // constants
import { EIssuesStoreType } from "@/constants/issue"; import { EIssuesStoreType } from "@/constants/issue";
import { EUserProjectRoles } from "@/constants/project"; import { EUserProjectRoles } from "@/constants/project";
import { STATE_GROUPS } from "@/constants/state"; import { ARCHIVABLE_STATE_GROUPS } from "@/constants/state";
// helpers // helpers
import { cn } from "@/helpers/common.helper"; import { cn } from "@/helpers/common.helper";
import { copyUrlToClipboard } from "@/helpers/string.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper";
@ -54,8 +54,7 @@ export const ModuleIssueQuickActions: React.FC<IQuickActionProps> = observer((pr
// auth // auth
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly; const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly;
const isArchivingAllowed = handleArchive && isEditingAllowed; const isArchivingAllowed = handleArchive && isEditingAllowed;
const isInArchivableGroup = const isInArchivableGroup = !!stateDetails && ARCHIVABLE_STATE_GROUPS.includes(stateDetails?.group);
!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);
const isDeletingAllowed = isEditingAllowed; const isDeletingAllowed = isEditingAllowed;
const activeLayout = `${issuesFilter.issueFilters?.displayFilters?.layout} layout`; const activeLayout = `${issuesFilter.issueFilters?.displayFilters?.layout} layout`;

View File

@ -12,7 +12,7 @@ import { ArchiveIssueModal, CreateUpdateIssueModal, DeleteIssueModal } from "@/c
// constants // constants
import { EIssuesStoreType } from "@/constants/issue"; import { EIssuesStoreType } from "@/constants/issue";
import { EUserProjectRoles } from "@/constants/project"; import { EUserProjectRoles } from "@/constants/project";
import { STATE_GROUPS } from "@/constants/state"; import { ARCHIVABLE_STATE_GROUPS } from "@/constants/state";
// helpers // helpers
import { cn } from "@/helpers/common.helper"; import { cn } from "@/helpers/common.helper";
import { copyUrlToClipboard } from "@/helpers/string.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper";
@ -54,8 +54,7 @@ export const ProjectIssueQuickActions: React.FC<IQuickActionProps> = observer((p
// auth // auth
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly; const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly;
const isArchivingAllowed = handleArchive && isEditingAllowed; const isArchivingAllowed = handleArchive && isEditingAllowed;
const isInArchivableGroup = const isInArchivableGroup = !!stateDetails && ARCHIVABLE_STATE_GROUPS.includes(stateDetails?.group);
!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);
const isDeletingAllowed = isEditingAllowed; const isDeletingAllowed = isEditingAllowed;
const issueLink = `${workspaceSlug}/projects/${issue.project_id}/issues/${issue.id}`; const issueLink = `${workspaceSlug}/projects/${issue.project_id}/issues/${issue.id}`;

View File

@ -15,7 +15,7 @@ import {
} from "@plane/ui"; } from "@plane/ui";
// components // components
import { IssueSubscription, IssueUpdateStatus } from "@/components/issues"; import { IssueSubscription, IssueUpdateStatus } from "@/components/issues";
import { STATE_GROUPS } from "@/constants/state"; import { ARCHIVABLE_STATE_GROUPS } from "@/constants/state";
// helpers // helpers
import { cn } from "@/helpers/common.helper"; import { cn } from "@/helpers/common.helper";
import { copyUrlToClipboard } from "@/helpers/string.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper";
@ -100,8 +100,7 @@ export const IssuePeekOverviewHeader: FC<PeekOverviewHeaderProps> = observer((pr
}; };
// auth // auth
const isArchivingAllowed = !isArchived && !disabled; const isArchivingAllowed = !isArchived && !disabled;
const isInArchivableGroup = const isInArchivableGroup = !!stateDetails && ARCHIVABLE_STATE_GROUPS.includes(stateDetails?.group);
!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);
const isRestoringAllowed = isArchived && !disabled; const isRestoringAllowed = isArchived && !disabled;
return ( return (

View File

@ -33,3 +33,5 @@ export const STATE_GROUPS: {
color: "#dc2626", color: "#dc2626",
}, },
}; };
export const ARCHIVABLE_STATE_GROUPS = [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key];