snapshot of https://github.com/makeplane/plane.git @ d868349a55de79979eb8b98701bf1702c67ad634 (2026-09-15)
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
This commit is contained in:
83
apps/web/core/components/dropdowns/layout.tsx
Normal file
83
apps/web/core/components/dropdowns/layout.tsx
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
// plane imports
|
||||
import { ISSUE_LAYOUT_MAP } from "@plane/constants";
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
import { TickOutline } from "@makeplane/propel/icons";
|
||||
import { EIssueLayoutTypes } from "@plane/types";
|
||||
import { getButtonStyling } from "@plane/propel/button";
|
||||
import { Dropdown } from "@plane/ui";
|
||||
import { cn } from "@plane/utils";
|
||||
// components
|
||||
import { IssueLayoutIcon } from "@/components/issues/issue-layouts/layout-icon";
|
||||
|
||||
type TLayoutDropDown = {
|
||||
onChange: (value: EIssueLayoutTypes) => void;
|
||||
value: EIssueLayoutTypes;
|
||||
disabledLayouts?: EIssueLayoutTypes[];
|
||||
};
|
||||
|
||||
export const LayoutDropDown = observer(function LayoutDropDown(props: TLayoutDropDown) {
|
||||
const { onChange, value = EIssueLayoutTypes.LIST, disabledLayouts = [] } = props;
|
||||
// plane i18n
|
||||
const { t } = useTranslation();
|
||||
// derived values
|
||||
const availableLayouts = useMemo(
|
||||
() => Object.values(ISSUE_LAYOUT_MAP).filter((layout) => !disabledLayouts.includes(layout.key)),
|
||||
[disabledLayouts]
|
||||
);
|
||||
|
||||
const options = useMemo(
|
||||
() =>
|
||||
availableLayouts.map((issueLayout) => ({
|
||||
data: issueLayout.key,
|
||||
value: issueLayout.key,
|
||||
})),
|
||||
[availableLayouts]
|
||||
);
|
||||
|
||||
const buttonContent = useCallback((isOpen: boolean, buttonValue: string | string[] | undefined) => {
|
||||
const dropdownValue = ISSUE_LAYOUT_MAP[buttonValue as EIssueLayoutTypes];
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-secondary">
|
||||
<IssueLayoutIcon layout={dropdownValue.key} strokeWidth={2} className={`size-3.5 text-secondary`} />
|
||||
<span className="text-11 font-medium">{t(dropdownValue.i18n_label)}</span>
|
||||
</div>
|
||||
);
|
||||
}, []);
|
||||
|
||||
const itemContent = useCallback((props: { value: string; selected: boolean }) => {
|
||||
const dropdownValue = ISSUE_LAYOUT_MAP[props.value as EIssueLayoutTypes];
|
||||
|
||||
return (
|
||||
<div className={cn("flex w-full items-center justify-between gap-2 text-secondary")}>
|
||||
<div className="flex items-center gap-2">
|
||||
<IssueLayoutIcon layout={dropdownValue.key} strokeWidth={2} className={`size-3 text-secondary`} />
|
||||
<span className="text-11 font-medium">{t(dropdownValue.i18n_label)}</span>
|
||||
</div>
|
||||
{props.selected && <TickOutline className="h-3.5 w-3.5 flex-shrink-0" />}
|
||||
</div>
|
||||
);
|
||||
}, []);
|
||||
|
||||
const keyExtractor = useCallback((option: any) => option.value, []);
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
onChange={onChange as (value: string) => void}
|
||||
value={value?.toString()}
|
||||
keyExtractor={keyExtractor}
|
||||
options={options}
|
||||
buttonContainerClassName={cn(getButtonStyling("secondary", "lg"))}
|
||||
buttonContent={buttonContent}
|
||||
renderItem={itemContent}
|
||||
disableSearch
|
||||
/>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user