-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added a common dropdown component (#5826)
* fix: Added a common dropdown component * fix: dropdown * fix: estimate dropdown * fix: removed consoles
- Loading branch information
Showing
5 changed files
with
64 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { useCycle, useProjectEstimates } from "@/hooks/store"; | ||
import { cycleEstimateOptions } from "../analytics-sidebar"; | ||
|
||
type TProps = { | ||
value: TCycleEstimateType; | ||
onChange: (value: TCycleEstimateType) => Promise<void>; | ||
showDefault?: boolean; | ||
projectId: string; | ||
cycleId: string; | ||
}; | ||
|
||
export const EstimateTypeDropdown = (props: TProps) => { | ||
const { value, onChange, projectId, cycleId, showDefault = false } = props; | ||
const { getIsPointsDataAvailable } = useCycle(); | ||
const { areEstimateEnabledByProjectId } = useProjectEstimates(); | ||
const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false; | ||
return getIsPointsDataAvailable(cycleId) || 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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./filters"; | ||
export * from "./estimate-type-dropdown"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters