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
80 lines
2.5 KiB
TypeScript
80 lines
2.5 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 { observer } from "mobx-react";
|
|
import { TOAST_TYPE, setToast } from "@plane/propel/toast";
|
|
import type { TContextMenuItem } from "@plane/ui";
|
|
import { CustomMenu } from "@plane/ui";
|
|
import { copyUrlToClipboard, cn } from "@plane/utils";
|
|
import { useLayoutMenuItems } from "@/components/common/quick-actions-helper";
|
|
import { MoreHorizontalOutline } from "@makeplane/propel/icons";
|
|
import { IconButton } from "@plane/propel/icon-button";
|
|
|
|
type Props = {
|
|
workspaceSlug: string;
|
|
projectId: string;
|
|
storeType: "PROJECT" | "EPIC";
|
|
};
|
|
|
|
export const LayoutQuickActions = observer(function LayoutQuickActions(props: Props) {
|
|
const { workspaceSlug, projectId, storeType } = props;
|
|
|
|
const layoutLink = `${workspaceSlug}/projects/${projectId}/${storeType === "EPIC" ? "epics" : "issues"}`;
|
|
|
|
const handleCopyLink = () =>
|
|
copyUrlToClipboard(layoutLink).then(() => {
|
|
setToast({
|
|
type: TOAST_TYPE.SUCCESS,
|
|
title: "Link copied",
|
|
message: `${storeType === "EPIC" ? "Epics" : "Work items"} link copied to clipboard.`,
|
|
});
|
|
});
|
|
|
|
const handleOpenInNewTab = () => window.open(`/${layoutLink}`, "_blank");
|
|
|
|
const menuResult = useLayoutMenuItems({
|
|
workspaceSlug,
|
|
projectId,
|
|
storeType,
|
|
handleCopyLink,
|
|
handleOpenInNewTab,
|
|
});
|
|
|
|
const MENU_ITEMS: TContextMenuItem[] = Array.isArray(menuResult) ? menuResult : menuResult.items;
|
|
const additionalModals = Array.isArray(menuResult) ? null : menuResult.modals;
|
|
|
|
return (
|
|
<>
|
|
{additionalModals}
|
|
<CustomMenu
|
|
ellipsis
|
|
placement="bottom-end"
|
|
closeOnSelect
|
|
maxHeight="lg"
|
|
className="flex size-[26px] flex-shrink-0 items-center justify-center rounded"
|
|
customButton={<IconButton size="lg" variant="tertiary" icon={MoreHorizontalOutline} />}
|
|
>
|
|
{MENU_ITEMS.map((item) => {
|
|
if (item.shouldRender === false) return null;
|
|
return (
|
|
<CustomMenu.MenuItem
|
|
key={item.key}
|
|
onClick={item.action}
|
|
className={cn("flex items-center gap-2", {
|
|
"text-placeholder": item.disabled,
|
|
})}
|
|
disabled={item.disabled}
|
|
>
|
|
{item.icon && <item.icon className="h-3 w-3" />}
|
|
<span>{item.title}</span>
|
|
</CustomMenu.MenuItem>
|
|
);
|
|
})}
|
|
</CustomMenu>
|
|
</>
|
|
);
|
|
});
|