Files
outline/app/menus/NewChildDocumentMenu.tsx
T
Tom MoorandClaude Opus 5.5 9e2565184e chore: Prune stale comments, TODOs, and type suppressions (#14092)
* chore: Remove unused lint disable directives

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Replace TODO type suppressions with typed code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Remove obsolete workaround comments in tests and MediaDimension

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Remove Tippy compatibility props from Tooltip

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Decouple DropdownMenu props from Tooltip and clarify sharing styles

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Remove stale retention TODOs from cleanup tasks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Register relations synchronously and clarify workaround comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

* chore: Replace Notion import TODOs with descriptive comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-15 08:54:37 -04:00

92 lines
2.6 KiB
TypeScript

import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import type Document from "~/models/Document";
import { DropdownMenu } from "~/components/Menu/DropdownMenu";
import usePolicy from "~/hooks/usePolicy";
import useStores from "~/hooks/useStores";
import { newDocumentPath, newNestedDocumentPath } from "~/utils/routeHelpers";
import { createInternalLinkAction } from "~/actions";
import { ActiveDocumentSection } from "~/actions/sections";
import { useMenuAction } from "~/hooks/useMenuAction";
import Tooltip from "~/components/Tooltip";
import Button from "~/components/Button";
import { PlusIcon } from "outline-icons";
type Props = {
document: Document;
};
function NewChildDocumentMenu({ document }: Props) {
const { t } = useTranslation();
const canCollection = usePolicy(document.collectionId);
const { collections } = useStores();
const collection = document.collectionId
? collections.get(document.collectionId)
: undefined;
const collectionName = collection ? collection.displayName : t("collection");
const actions = React.useMemo(
() => [
createInternalLinkAction({
name: (
<Trans
defaults="New document in <em>{{ collectionName }}</em>"
values={{
collectionName,
}}
components={{
em: <strong />,
}}
/>
),
section: ActiveDocumentSection,
visible: !!canCollection.createDocument,
to: newDocumentPath(document.collectionId),
}),
createInternalLinkAction({
name: (
<Trans
defaults="New document in <em>{{ collectionName }}</em>"
values={{
collectionName: document.displayTitle,
}}
components={{
em: <strong />,
}}
/>
),
section: ActiveDocumentSection,
visible: true,
to: newNestedDocumentPath(document.id),
}),
],
[
collectionName,
canCollection.createDocument,
document.id,
document.displayTitle,
document.collectionId,
]
);
const rootAction = useMenuAction(actions);
return (
<Tooltip content={t("New document")} shortcut="n" side="bottom">
<DropdownMenu
action={rootAction}
align="end"
ariaLabel={t("New child document")}
>
<Button icon={<PlusIcon />} neutral>
{t("New doc")}
</Button>
</DropdownMenu>
</Tooltip>
);
}
export default observer(NewChildDocumentMenu);