forked from github/plane
chore: added a prop to render default state conditionally (#4669)
This commit is contained in:
parent
ba4798deb9
commit
c8c86a33f8
@ -24,7 +24,8 @@ type Props = TDropdownProps & {
|
|||||||
onChange: (val: string) => void;
|
onChange: (val: string) => void;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
value: string;
|
showDefaultState?: boolean;
|
||||||
|
value: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const StateDropdown: React.FC<Props> = observer((props) => {
|
export const StateDropdown: React.FC<Props> = observer((props) => {
|
||||||
@ -42,6 +43,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
|
|||||||
onClose,
|
onClose,
|
||||||
placement,
|
placement,
|
||||||
projectId,
|
projectId,
|
||||||
|
showDefaultState = true,
|
||||||
showTooltip = false,
|
showTooltip = false,
|
||||||
tabIndex,
|
tabIndex,
|
||||||
value,
|
value,
|
||||||
@ -72,8 +74,8 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
|
|||||||
const { workspaceSlug } = useAppRouter();
|
const { workspaceSlug } = useAppRouter();
|
||||||
const { fetchProjectStates, getProjectStates, getStateById } = useProjectState();
|
const { fetchProjectStates, getProjectStates, getStateById } = useProjectState();
|
||||||
const statesList = getProjectStates(projectId);
|
const statesList = getProjectStates(projectId);
|
||||||
const defaultStateList = statesList?.find((state) => state.default);
|
const defaultState = statesList?.find((state) => state.default);
|
||||||
const stateValue = value ? value : defaultStateList?.id;
|
const stateValue = value ?? (showDefaultState ? defaultState?.id : undefined);
|
||||||
|
|
||||||
const options = statesList?.map((state) => ({
|
const options = statesList?.map((state) => ({
|
||||||
value: state.id,
|
value: state.id,
|
||||||
@ -170,7 +172,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
|
|||||||
{!hideIcon && (
|
{!hideIcon && (
|
||||||
<StateGroupIcon
|
<StateGroupIcon
|
||||||
stateGroup={selectedState?.group ?? "backlog"}
|
stateGroup={selectedState?.group ?? "backlog"}
|
||||||
color={selectedState?.color}
|
color={selectedState?.color ?? "rgba(var(--color-text-300))"}
|
||||||
className="h-3 w-3 flex-shrink-0"
|
className="h-3 w-3 flex-shrink-0"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user