mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: handled current project active estimate
This commit is contained in:
parent
638662d33a
commit
4fa3eda5cd
@ -24,7 +24,7 @@ export const CreateEstimateModal: FC<TCreateEstimateModal> = observer((props) =>
|
||||
// hooks
|
||||
const { createEstimate } = useProjectEstimates();
|
||||
// states
|
||||
const [estimateSystem, setEstimateSystem] = useState<TEstimateSystemKeys>(EEstimateSystem.POINTS);
|
||||
const [estimateSystem, setEstimateSystem] = useState<TEstimateSystemKeys>(EEstimateSystem.CATEGORIES);
|
||||
const [estimatePoints, setEstimatePoints] = useState<TEstimatePointsObject[] | undefined>(undefined);
|
||||
|
||||
const handleUpdatePoints = (newPoints: TEstimatePointsObject[] | undefined) => setEstimatePoints(newPoints);
|
||||
|
@ -38,7 +38,6 @@ export const EstimateCreateStageOne: FC<TEstimateCreateStageOne> = (props) => {
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<div className="text-sm font-medium text-custom-text-200">Start from scratch</div>
|
||||
|
||||
<button
|
||||
className="border border-custom-border-200 rounded-md p-2 text-left flex-1 w-full block"
|
||||
onClick={() => handleEstimatePoints("custom")}
|
||||
|
@ -2,7 +2,7 @@ import { FC } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { TOAST_TYPE, ToggleSwitch, setToast } from "@plane/ui";
|
||||
// hooks
|
||||
import { useProject } from "@/hooks/store";
|
||||
import { useProject, useProjectEstimates } from "@/hooks/store";
|
||||
|
||||
type TEstimateDisableSwitch = {
|
||||
workspaceSlug: string;
|
||||
@ -14,11 +14,17 @@ export const EstimateDisableSwitch: FC<TEstimateDisableSwitch> = observer((props
|
||||
const { workspaceSlug, projectId, isAdmin } = props;
|
||||
// hooks
|
||||
const { updateProject, currentProjectDetails } = useProject();
|
||||
const { currentActiveEstimateId } = useProjectEstimates();
|
||||
|
||||
const currentProjectActiveEstimate = currentProjectDetails?.estimate || undefined;
|
||||
|
||||
const disableEstimate = async () => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
||||
try {
|
||||
await updateProject(workspaceSlug, projectId, { estimate: null });
|
||||
await updateProject(workspaceSlug, projectId, {
|
||||
estimate: currentProjectActiveEstimate ? null : currentActiveEstimateId,
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
@ -35,7 +41,7 @@ export const EstimateDisableSwitch: FC<TEstimateDisableSwitch> = observer((props
|
||||
|
||||
return (
|
||||
<ToggleSwitch
|
||||
value={Boolean(currentProjectDetails?.estimate)}
|
||||
value={Boolean(currentProjectActiveEstimate)}
|
||||
onChange={disableEstimate}
|
||||
disabled={!isAdmin}
|
||||
size="sm"
|
||||
|
@ -10,12 +10,13 @@ import { useProjectEstimates } from "@/hooks/store";
|
||||
type TEstimateListItem = {
|
||||
estimateId: string;
|
||||
isAdmin: boolean;
|
||||
isEstimateEnabled: boolean;
|
||||
isEditable: boolean;
|
||||
onEditClick?: (estimateId: string) => void;
|
||||
};
|
||||
|
||||
export const EstimateListItem: FC<TEstimateListItem> = observer((props) => {
|
||||
const { estimateId, isAdmin, isEditable, onEditClick } = props;
|
||||
const { estimateId, isAdmin, isEstimateEnabled, isEditable, onEditClick } = props;
|
||||
// hooks
|
||||
const { estimateById } = useProjectEstimates();
|
||||
|
||||
@ -27,7 +28,7 @@ export const EstimateListItem: FC<TEstimateListItem> = observer((props) => {
|
||||
<div
|
||||
className={cn(
|
||||
"relative border-b border-custom-border-200 flex justify-between items-center gap-3 py-3.5",
|
||||
isAdmin && isEditable ? `text-custom-text-100` : `text-custom-text-200`
|
||||
isAdmin && isEditable && isEstimateEnabled ? `text-custom-text-100` : `text-custom-text-200`
|
||||
)}
|
||||
>
|
||||
<div className="space-y-1">
|
||||
|
@ -6,12 +6,13 @@ import { EstimateListItem } from "@/components/estimates";
|
||||
type TEstimateList = {
|
||||
estimateIds: string[] | undefined;
|
||||
isAdmin: boolean;
|
||||
isEstimateEnabled?: boolean;
|
||||
isEditable?: boolean;
|
||||
onEditClick?: (estimateId: string) => void;
|
||||
};
|
||||
|
||||
export const EstimateList: FC<TEstimateList> = observer((props) => {
|
||||
const { estimateIds, isAdmin, isEditable = false, onEditClick } = props;
|
||||
const { estimateIds, isAdmin, isEstimateEnabled = false, isEditable = false, onEditClick } = props;
|
||||
|
||||
if (!estimateIds || estimateIds?.length <= 0) return <></>;
|
||||
return (
|
||||
@ -22,6 +23,7 @@ export const EstimateList: FC<TEstimateList> = observer((props) => {
|
||||
key={estimateId}
|
||||
estimateId={estimateId}
|
||||
isAdmin={isAdmin}
|
||||
isEstimateEnabled={isEstimateEnabled}
|
||||
isEditable={isEditable}
|
||||
onEditClick={onEditClick}
|
||||
/>
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
EstimateList,
|
||||
} from "@/components/estimates";
|
||||
// hooks
|
||||
import { useProjectEstimates } from "@/hooks/store";
|
||||
import { useProject, useProjectEstimates } from "@/hooks/store";
|
||||
|
||||
type TEstimateRoot = {
|
||||
workspaceSlug: string;
|
||||
@ -22,6 +22,7 @@ type TEstimateRoot = {
|
||||
export const EstimateRoot: FC<TEstimateRoot> = observer((props) => {
|
||||
const { workspaceSlug, projectId, isAdmin } = props;
|
||||
// hooks
|
||||
const { currentProjectDetails } = useProject();
|
||||
const { loader, currentActiveEstimateId, archivedEstimateIds, getProjectEstimates } = useProjectEstimates();
|
||||
// states
|
||||
const [isEstimateCreateModalOpen, setIsEstimateCreateModalOpen] = useState(false);
|
||||
@ -59,6 +60,7 @@ export const EstimateRoot: FC<TEstimateRoot> = observer((props) => {
|
||||
<EstimateList
|
||||
estimateIds={[currentActiveEstimateId]}
|
||||
isAdmin={isAdmin}
|
||||
isEstimateEnabled={Boolean(currentProjectDetails?.estimate)}
|
||||
isEditable
|
||||
onEditClick={(estimateId: string) => setEstimateToUpdate(estimateId)}
|
||||
/>
|
||||
|
@ -16,6 +16,40 @@ export enum EEstimateUpdateStages {
|
||||
export const maxEstimatesCount = 11;
|
||||
|
||||
export const ESTIMATE_SYSTEMS: TEstimateSystems = {
|
||||
categories: {
|
||||
name: "Categories",
|
||||
templates: {
|
||||
t_shirt_sizes: {
|
||||
title: "T-Shirt Sizes",
|
||||
values: [
|
||||
{ id: undefined, key: 1, value: "XS" },
|
||||
{ id: undefined, key: 2, value: "S" },
|
||||
{ id: undefined, key: 3, value: "M" },
|
||||
{ id: undefined, key: 4, value: "L" },
|
||||
{ id: undefined, key: 5, value: "XL" },
|
||||
{ id: undefined, key: 6, value: "XXL" },
|
||||
],
|
||||
},
|
||||
easy_to_hard: {
|
||||
title: "Easy to hard",
|
||||
values: [
|
||||
{ id: undefined, key: 1, value: "Easy" },
|
||||
{ id: undefined, key: 2, value: "Medium" },
|
||||
{ id: undefined, key: 3, value: "Hard" },
|
||||
{ id: undefined, key: 4, value: "Very Hard" },
|
||||
],
|
||||
},
|
||||
custom: {
|
||||
title: "Custom",
|
||||
values: [
|
||||
{ id: undefined, key: 1, value: "1" },
|
||||
{ id: undefined, key: 2, value: "2" },
|
||||
],
|
||||
hide: true,
|
||||
},
|
||||
},
|
||||
is_available: true,
|
||||
},
|
||||
points: {
|
||||
name: "Points",
|
||||
templates: {
|
||||
@ -68,40 +102,6 @@ export const ESTIMATE_SYSTEMS: TEstimateSystems = {
|
||||
},
|
||||
is_available: true,
|
||||
},
|
||||
categories: {
|
||||
name: "Categories",
|
||||
templates: {
|
||||
t_shirt_sizes: {
|
||||
title: "T-Shirt Sizes",
|
||||
values: [
|
||||
{ id: undefined, key: 1, value: "XS" },
|
||||
{ id: undefined, key: 2, value: "S" },
|
||||
{ id: undefined, key: 3, value: "M" },
|
||||
{ id: undefined, key: 4, value: "L" },
|
||||
{ id: undefined, key: 5, value: "XL" },
|
||||
{ id: undefined, key: 6, value: "XXL" },
|
||||
],
|
||||
},
|
||||
easy_to_hard: {
|
||||
title: "Easy to hard",
|
||||
values: [
|
||||
{ id: undefined, key: 1, value: "Easy" },
|
||||
{ id: undefined, key: 2, value: "Medium" },
|
||||
{ id: undefined, key: 3, value: "Hard" },
|
||||
{ id: undefined, key: 4, value: "Very Hard" },
|
||||
],
|
||||
},
|
||||
custom: {
|
||||
title: "Custom",
|
||||
values: [
|
||||
{ id: undefined, key: 1, value: "1" },
|
||||
{ id: undefined, key: 2, value: "2" },
|
||||
],
|
||||
hide: true,
|
||||
},
|
||||
},
|
||||
is_available: true,
|
||||
},
|
||||
time: {
|
||||
name: "Time",
|
||||
templates: {
|
||||
|
Loading…
Reference in New Issue
Block a user