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
84 lines
3.0 KiB
TypeScript
84 lines
3.0 KiB
TypeScript
/**
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
import { Link } from "react-router";
|
|
import { DefaultTabOutline, UnpinOutline } from "@makeplane/propel/icons";
|
|
// plane imports
|
|
import { useTranslation } from "@plane/i18n";
|
|
import { ContextMenu } from "@plane/propel/context-menu";
|
|
import { TabNavigationItem } from "@plane/propel/tab-navigation";
|
|
// local imports
|
|
import type { TNavigationItem } from "./tab-navigation-root";
|
|
import type { TTabPreferences } from "./tab-navigation-utils";
|
|
|
|
export type TTabNavigationVisibleItemProps = {
|
|
item: TNavigationItem;
|
|
isActive: boolean;
|
|
tabPreferences: TTabPreferences;
|
|
onToggleDefault: (tabKey: string) => void;
|
|
onHide: (tabKey: string) => void;
|
|
itemRef?: (el: HTMLDivElement | null) => void;
|
|
};
|
|
|
|
/**
|
|
* Individual visible tab navigation item with context menu
|
|
* Handles right-click actions for setting default and hiding tabs
|
|
*/
|
|
export function TabNavigationVisibleItem({
|
|
item,
|
|
isActive,
|
|
tabPreferences,
|
|
onToggleDefault,
|
|
onHide,
|
|
itemRef,
|
|
}: TTabNavigationVisibleItemProps) {
|
|
const { t } = useTranslation();
|
|
const isDefault = item.key === tabPreferences.defaultTab;
|
|
|
|
return (
|
|
<div className="relative flex h-full items-center transition-all duration-300">
|
|
{isActive && (
|
|
<span className="absolute bottom-0 left-1/2 h-0.5 w-[80%] -translate-x-1/2 rounded-t-md bg-(--text-color-icon-primary) transition-all duration-300" />
|
|
)}
|
|
<div key={`${item.key}-measure`} ref={itemRef}>
|
|
<ContextMenu>
|
|
<ContextMenu.Trigger>
|
|
<Link key={`${item.key}-${isActive ? "active" : "inactive"}`} to={item.href}>
|
|
<TabNavigationItem isActive={isActive}>
|
|
<span>{t(item.i18n_key)}</span>
|
|
</TabNavigationItem>
|
|
</Link>
|
|
</ContextMenu.Trigger>
|
|
<ContextMenu.Portal>
|
|
<ContextMenu.Content positionerClassName="z-30">
|
|
<ContextMenu.Item
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
onToggleDefault(item.key);
|
|
}}
|
|
className="flex cursor-pointer items-center gap-2 text-secondary transition-colors"
|
|
>
|
|
<DefaultTabOutline className="size-3 shrink-0" />
|
|
<span className="text-11">{isDefault ? "Clear default" : "Set as default"}</span>
|
|
</ContextMenu.Item>
|
|
<ContextMenu.Item
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
onHide(item.key);
|
|
}}
|
|
className="flex cursor-pointer items-center gap-2 text-secondary transition-colors"
|
|
>
|
|
<UnpinOutline className="size-3 shrink-0" />
|
|
<span className="text-11">Hide in more menu</span>
|
|
</ContextMenu.Item>
|
|
</ContextMenu.Content>
|
|
</ContextMenu.Portal>
|
|
</ContextMenu>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|