Files
outline/app/menus/DocumentContextMenu.tsx
T
Tom MoorandClaude Opus 5 0f8f69de42 Unpin and context menu controls on pinned documents (#13498)
* feat: Unpin and context menu controls on pinned documents

- Adds an unpin control to document chips in the collapsed pinned view
- Adds the collapse toggle to collections, matching home
- Makes the Pin menu items toggles with a selected state
- Adds a document context menu to pinned cards and chips
- Stops the drag sensor swallowing clicks on the card unpin button

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: Hide the collection pin toggle for a mixed selection

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 23:38:09 -04:00

48 lines
1.4 KiB
TypeScript

import { observer } from "mobx-react";
import type * as React from "react";
import { useTranslation } from "react-i18next";
import type Document from "~/models/Document";
import { ContextMenu } from "~/components/Menu/ContextMenu";
import { ActionContextProvider } from "~/hooks/useActionContext";
import { useDocumentActiveModels } from "~/hooks/useDocumentActiveModels";
import { useDocumentMenuAction } from "~/hooks/useDocumentMenuAction";
type Props = {
/** Document for which the menu is to be shown */
document: Document;
/** The element that opens the menu when right clicked */
children: React.ReactNode;
/** Invoked when menu is opened */
onOpen?: () => void;
/** Invoked when menu is closed */
onClose?: () => void;
};
/**
* Wraps its children in a right click context menu offering the standard
* document actions.
*/
export const DocumentContextMenu = observer(function DocumentContextMenu_({
document,
children,
onOpen,
onClose,
}: Props) {
const { t } = useTranslation();
const action = useDocumentMenuAction({ documentId: document.id });
const activeModels = useDocumentActiveModels(document);
return (
<ActionContextProvider value={{ activeModels }}>
<ContextMenu
action={action}
ariaLabel={t("Document options")}
onOpen={onOpen}
onClose={onClose}
>
{children}
</ContextMenu>
</ActionContextProvider>
);
});