Skip to content

Commit

Permalink
[WEB-522] chore:Estimate structure (makeplane#4801)
Browse files Browse the repository at this point in the history
* dv: seperating constants for ce and ee

* dev: update estimate constants

* dev: updated estimate structure for ce and ee
  • Loading branch information
gurusainath authored Jun 13, 2024
1 parent ee4ad58 commit 52617ba
Show file tree
Hide file tree
Showing 30 changed files with 78 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC } from "react";
import { observer } from "mobx-react";
import { Pen, Trash } from "lucide-react";
import { Crown, Pen, Trash } from "lucide-react";
import { Tooltip } from "@plane/ui";

type TEstimateListItem = {
estimateId: string;
Expand All @@ -12,17 +13,24 @@ type TEstimateListItem = {
};

export const EstimateListItemButtons: FC<TEstimateListItem> = observer((props) => {
const { estimateId, isAdmin, isEditable, onEditClick, onDeleteClick } = props;
if (!isAdmin || !isEditable) return <></>;
const { estimateId, isAdmin, isEditable, onDeleteClick } = props;

if (!isAdmin || !isEditable) return <></>;
return (
<div className="relative flex items-center gap-1">
<button
className="relative flex-shrink-0 w-6 h-6 flex justify-center items-center rounded cursor-pointer transition-colors overflow-hidden hover:bg-custom-background-80"
onClick={() => onEditClick && onEditClick(estimateId)}
<Tooltip
tooltipContent={
<div className="relative flex items-center gap-2">
<div>Upgrade</div>
<Crown size={12} className="text-amber-400" />
</div>
}
position="top"
>
<Pen size={12} />
</button>
<button className="relative flex-shrink-0 w-6 h-6 flex justify-center items-center rounded cursor-pointer transition-colors overflow-hidden hover:bg-custom-background-80">
<Pen size={12} />
</button>
</Tooltip>
<button
className="relative flex-shrink-0 w-6 h-6 flex justify-center items-center rounded cursor-pointer transition-colors overflow-hidden hover:bg-custom-background-80"
onClick={() => onDeleteClick && onDeleteClick(estimateId)}
Expand Down
3 changes: 3 additions & 0 deletions web/ce/components/estimates/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./estimate-list-item-buttons";

export * from "./update";
1 change: 1 addition & 0 deletions web/ce/components/estimates/update/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./modal";
14 changes: 14 additions & 0 deletions web/ce/components/estimates/update/modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client";

import { FC } from "react";
import { observer } from "mobx-react";

type TUpdateEstimateModal = {
workspaceSlug: string;
projectId: string;
estimateId: string | undefined;
isOpen: boolean;
handleClose: () => void;
};

export const UpdateEstimateModal: FC<TUpdateEstimateModal> = observer(() => <></>);
21 changes: 4 additions & 17 deletions web/core/constants/estimates.ts → web/ce/constants/estimates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export enum EEstimateUpdateStages {
SWITCH = "switch",
}

export const minEstimatesCount = 2;
export const maxEstimatesCount = 6;
export const estimateCount = {
min: 2,
max: 6,
};

export const ESTIMATE_SYSTEMS: TEstimateSystems = {
points: {
Expand Down Expand Up @@ -119,18 +121,3 @@ export const ESTIMATE_SYSTEMS: TEstimateSystems = {
is_ee: true,
},
};

export const ESTIMATE_OPTIONS_STAGE_ONE = [
{
key: EEstimateUpdateStages.EDIT,
title: "Add, update or remove estimates",
description: "Manage current system either adding, updating or removing the points or categories.",
is_ee: true,
},
{
key: EEstimateUpdateStages.SWITCH,
title: "Change estimate type",
description: "Convert your points system to categories system and vice versa.",
is_ee: true,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { TYAxisValues } from "@plane/types";
import { CustomSelect } from "@plane/ui";
// constants
import { ANALYTICS_Y_AXIS_VALUES } from "@/constants/analytics";
import { EEstimateSystem } from "@/constants/estimates";
// hooks
import { useAppRouter, useProjectEstimates } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";

type Props = {
value: TYAxisValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import { CustomSelect, Spinner } from "@plane/ui";
import ProgressChart from "@/components/core/sidebar/progress-chart";
import { CycleProgressStats } from "@/components/cycles";
// constants
import { EEstimateSystem } from "@/constants/estimates";
import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";
// helpers
import { getDate } from "@/helpers/date-time.helper";
// hooks
import { useIssues, useCycle, useProjectEstimates } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";

type TCycleAnalyticsProgress = {
workspaceSlug: string;
Expand Down
3 changes: 2 additions & 1 deletion web/core/components/cycles/analytics-sidebar/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import { ArchiveCycleModal, CycleDeleteModal, CycleAnalyticsProgress } from "@/c
import { DateRangeDropdown } from "@/components/dropdowns";
// constants
import { CYCLE_STATUS } from "@/constants/cycle";
import { EEstimateSystem } from "@/constants/estimates";
import { CYCLE_UPDATED } from "@/constants/event-tracker";
import { EUserWorkspaceRoles } from "@/constants/workspace";
// helpers
import { findHowManyDaysLeft, getDate, renderFormattedPayloadDate } from "@/helpers/date-time.helper";
import { copyUrlToClipboard } from "@/helpers/string.helper";
// hooks
import { useEventTracker, useCycle, useUser, useMember, useProjectEstimates } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";
// services
import { CycleService } from "@/services/cycle.service";

Expand Down
4 changes: 2 additions & 2 deletions web/core/components/estimates/create/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Button, TOAST_TYPE, setToast } from "@plane/ui";
// components
import { EModalPosition, EModalWidth, ModalCore } from "@/components/core";
import { EstimateCreateStageOne, EstimatePointCreateRoot } from "@/components/estimates";
// constants
import { EEstimateSystem, ESTIMATE_SYSTEMS } from "@/constants/estimates";
// hooks
import { useProjectEstimates } from "@/hooks/store";
// plane web constants
import { EEstimateSystem, ESTIMATE_SYSTEMS } from "@/plane-web/constants/estimates";

type TCreateEstimateModal = {
workspaceSlug: string;
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/estimates/create/stage-one.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { TEstimateSystemKeys } from "@plane/types";
import { Tooltip } from "@plane/ui";
// components
import { RadioInput } from "@/components/estimates";
// constants
import { ESTIMATE_SYSTEMS } from "@/constants/estimates";
// plane web constants
import { ESTIMATE_SYSTEMS } from "@/plane-web/constants/estimates";

type TEstimateCreateStageOne = {
estimateSystem: TEstimateSystemKeys;
Expand Down
3 changes: 2 additions & 1 deletion web/core/components/estimates/estimate-list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { observer } from "mobx-react";
import { cn } from "@/helpers/common.helper";
// hooks
import { useEstimate, useProjectEstimates } from "@/hooks/store";
import { EstimateListItemButtons } from "./estimate-list-item-buttons";
// plane web components
import { EstimateListItemButtons } from "@/plane-web/components/estimates";

type TEstimateListItem = {
estimateId: string;
Expand Down
4 changes: 0 additions & 4 deletions web/core/components/estimates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ export * from "./estimate-disable-switch";
// estimates
export * from "./estimate-list";
export * from "./estimate-list-item";
export * from "./estimate-list-item-buttons";

// create
export * from "./create";

// update
export * from "./update";

// delete
export * from "./delete";

Expand Down
8 changes: 4 additions & 4 deletions web/core/components/estimates/points/create-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { TEstimatePointsObject, TEstimateSystemKeys } from "@plane/types";
import { Button, Sortable } from "@plane/ui";
// components
import { EstimatePointCreate, EstimatePointItemPreview } from "@/components/estimates/points";
// constants
import { maxEstimatesCount } from "@/constants/estimates";
// plane web constants
import { estimateCount } from "@/plane-web/constants/estimates";

type TEstimatePointCreateRoot = {
workspaceSlug: string;
Expand Down Expand Up @@ -89,7 +89,7 @@ export const EstimatePointCreateRoot: FC<TEstimatePointCreateRoot> = observer((p
};

const handleCreate = () => {
if (estimatePoints && estimatePoints.length + (estimatePointCreate?.length || 0) <= maxEstimatesCount - 1) {
if (estimatePoints && estimatePoints.length + (estimatePointCreate?.length || 0) <= estimateCount.max - 1) {
handleEstimatePointCreate("add", {
id: undefined,
key: estimatePoints.length + (estimatePointCreate?.length || 0) + 1,
Expand Down Expand Up @@ -143,7 +143,7 @@ export const EstimatePointCreateRoot: FC<TEstimatePointCreateRoot> = observer((p
isError={estimatePointCreateError.includes(estimatePoint.key) ? true : false}
/>
))}
{estimatePoints && estimatePoints.length + (estimatePointCreate?.length || 0) <= maxEstimatesCount - 1 && (
{estimatePoints && estimatePoints.length + (estimatePointCreate?.length || 0) <= estimateCount.max - 1 && (
<Button variant="link-primary" size="sm" prependIcon={<Plus />} onClick={handleCreate}>
Add {estimateType}
</Button>
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/estimates/points/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { observer } from "mobx-react";
import { Check, Info, X } from "lucide-react";
import { TEstimatePointsObject, TEstimateSystemKeys } from "@plane/types";
import { Spinner, TOAST_TYPE, Tooltip, setToast } from "@plane/ui";
// constants
import { EEstimateSystem } from "@/constants/estimates";
// helpers
import { cn } from "@/helpers/common.helper";
import { isEstimatePointValuesRepeated } from "@/helpers/estimates";
// hooks
import { useEstimate } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";

type TEstimatePointCreate = {
workspaceSlug: string;
Expand Down
5 changes: 3 additions & 2 deletions web/core/components/estimates/points/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { GripVertical, Pencil, Trash2 } from "lucide-react";
import { TEstimatePointsObject, TEstimateSystemKeys } from "@plane/types";
// components
import { EstimatePointUpdate, EstimatePointDelete } from "@/components/estimates/points";
import { minEstimatesCount } from "@/constants/estimates";
// plane web constants
import { estimateCount } from "@/plane-web/constants/estimates";

type TEstimatePointItemPreview = {
workspaceSlug: string;
Expand Down Expand Up @@ -61,7 +62,7 @@ export const EstimatePointItemPreview: FC<TEstimatePointItemPreview> = observer(
>
<Pencil size={14} className="text-custom-text-200" />
</div>
{estimatePoints.length > minEstimatesCount && (
{estimatePoints.length > estimateCount.min && (
<div
className="rounded-sm w-6 h-6 flex-shrink-0 relative flex justify-center items-center hover:bg-custom-background-80 transition-colors cursor-pointer"
onClick={() =>
Expand Down
4 changes: 2 additions & 2 deletions web/core/components/estimates/points/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { observer } from "mobx-react";
import { Check, Info, X } from "lucide-react";
import { TEstimatePointsObject, TEstimateSystemKeys } from "@plane/types";
import { Spinner, TOAST_TYPE, Tooltip, setToast } from "@plane/ui";
// constants
import { EEstimateSystem } from "@/constants/estimates";
// helpers
import { cn } from "@/helpers/common.helper";
import { isEstimatePointValuesRepeated } from "@/helpers/estimates";
// hooks
import { useEstimatePoint } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";

type TEstimatePointUpdate = {
workspaceSlug: string;
Expand Down
3 changes: 2 additions & 1 deletion web/core/components/estimates/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
EstimateEmptyScreen,
EstimateDisableSwitch,
CreateEstimateModal,
UpdateEstimateModal,
DeleteEstimateModal,
EstimateList,
} from "@/components/estimates";
// hooks
import { useProject, useProjectEstimates } from "@/hooks/store";
// plane web components
import { UpdateEstimateModal } from "@/plane-web/components/estimates";

type TEstimateRoot = {
workspaceSlug: string;
Expand Down
2 changes: 0 additions & 2 deletions web/core/components/estimates/update/index.ts

This file was deleted.

44 changes: 0 additions & 44 deletions web/core/components/estimates/update/modal.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions web/core/components/estimates/update/stage-one.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { CustomSelect, Spinner } from "@plane/ui";
import ProgressChart from "@/components/core/sidebar/progress-chart";
import { ModuleProgressStats } from "@/components/modules";
// constants
import { EEstimateSystem } from "@/constants/estimates";
import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";
// helpers
import { getDate } from "@/helpers/date-time.helper";
// hooks
import { useIssues, useModule, useProjectEstimates } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";

type TModuleAnalyticsProgress = {
workspaceSlug: string;
Expand Down
Loading

0 comments on commit 52617ba

Please sign in to comment.