Skip to content

Commit

Permalink
fix: dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
gakshita committed Oct 14, 2024
1 parent a50a00e commit b56b835
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 60 deletions.
10 changes: 2 additions & 8 deletions web/ce/components/cycles/analytics-sidebar/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import { EEstimateSystem } from "@plane/types/src/enums";
import { Loader } from "@plane/ui";
// components
import ProgressChart from "@/components/core/sidebar/progress-chart";
import { validateCycleSnapshot } from "@/components/cycles";
import { EstimateTypeDropdown, validateCycleSnapshot } from "@/components/cycles";
// helpers
import { CycleEstimateOptions } from "@/components/cycles/dropdowns/estimate-dropdown";
import { getDate } from "@/helpers/date-time.helper";
// hooks
import { useCycle, useProjectEstimates } from "@/hooks/store";
Expand Down Expand Up @@ -66,12 +65,7 @@ export const SidebarChart: FC<ProgressChartProps> = observer((props) => {
<>
{isCurrentEstimateTypeIsPoints && (
<div className="relative flex items-center justify-between gap-2 pt-4">
<CycleEstimateOptions
showEstimateSelection
estimateType={estimateType}
handleEstimateChange={onChange}
projectId={projectId}
/>
<EstimateTypeDropdown showEstimateSelection value={estimateType} onChange={onChange} projectId={projectId} />
</div>
)}
<div className="py-4">
Expand Down
8 changes: 4 additions & 4 deletions web/core/components/cycles/active-cycle/productivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EmptyStateType } from "@/constants/empty-state";
import { useCycle, useProjectEstimates } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";
import { CycleEstimateOptions } from "../dropdowns/estimate-dropdown";
import { EstimateTypeDropdown } from "../dropdowns/estimate-type-dropdown";

export type ActiveCycleProductivityProps = {
workspaceSlug: string;
Expand Down Expand Up @@ -48,10 +48,10 @@ export const ActiveCycleProductivity: FC<ActiveCycleProductivityProps> = observe
<Link href={`/${workspaceSlug}/projects/${projectId}/cycles/${cycle?.id}`}>
<h3 className="text-base text-custom-text-300 font-semibold">Issue burndown</h3>
</Link>
<CycleEstimateOptions
<EstimateTypeDropdown
showEstimateSelection={isCurrentEstimateTypeIsPoints}
estimateType={estimateType}
handleEstimateChange={onChange}
value={estimateType}
onChange={onChange}
projectId={projectId}
/>
</div>
Expand Down
48 changes: 0 additions & 48 deletions web/core/components/cycles/dropdowns/estimate-dropdown.tsx

This file was deleted.

39 changes: 39 additions & 0 deletions web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { TCycleEstimateType } from "@plane/types";
import { CustomSelect } from "@plane/ui";
import { useProjectEstimates } from "@/hooks/store";
import { cycleEstimateOptions } from "../analytics-sidebar";

type TProps = {
showEstimateSelection: boolean | undefined;
value: TCycleEstimateType;
onChange: (value: TCycleEstimateType) => Promise<void>;
projectId: string;
showDefault?: boolean;
};

export const EstimateTypeDropdown = (props: TProps) => {
const { showEstimateSelection, value, onChange, projectId, showDefault = false } = props;

const { areEstimateEnabledByProjectId } = useProjectEstimates();
const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false;
return showEstimateSelection && isCurrentProjectEstimateEnabled ? (
<div className="relative flex items-center gap-2">
<CustomSelect
value={value}
label={<span>{cycleEstimateOptions.find((v) => v.value === value)?.label ?? "None"}</span>}
onChange={onChange}
maxHeight="lg"
buttonClassName="bg-custom-background-90 border-none rounded text-sm font-medium "
>
{cycleEstimateOptions.map((item) => (
<CustomSelect.Option key={item.value} value={item.value}>
{item.label}
</CustomSelect.Option>
))}
</CustomSelect>
</div>
) : showDefault ? (
<span className="capitalize">{value}</span>
) : null;
};
1 change: 1 addition & 0 deletions web/core/components/cycles/dropdowns/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./filters";
export * from "./estimate-type-dropdown";

0 comments on commit b56b835

Please sign in to comment.