Files
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

100 lines
3.1 KiB
TypeScript

import { observer } from "mobx-react";
import { EditIcon, PlusIcon } from "outline-icons";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import type Collection from "~/models/Collection";
import { Action } from "~/components/Actions";
import Button from "~/components/Button";
import Tooltip from "~/components/Tooltip";
import usePolicy from "~/hooks/usePolicy";
import CollectionMenu from "~/menus/CollectionMenu";
import {
collectionEditPath,
collectionPath,
newDocumentPath,
} from "~/utils/routeHelpers";
import useCurrentUser from "~/hooks/useCurrentUser";
import type { SidebarContextType } from "~/components/Sidebar/components/SidebarContext";
import { CollectionTab } from "./Navigation";
import lazyWithRetry from "@shared/utils/lazyWithRetry";
import history from "~/utils/history";
import RegisterKeyDown from "~/components/RegisterKeyDown";
import { useCallback } from "react";
const ShareButton = lazyWithRetry(() => import("./ShareButton"));
type Props = {
/** The collection for which to render actions */
collection: Collection;
/** Whether the collection is in editing mode */
isEditing: boolean;
/** Contextual information for the sidebar */
sidebarContext: SidebarContextType;
};
function Actions({ collection, isEditing, sidebarContext }: Props) {
const { t } = useTranslation();
const can = usePolicy(collection);
const user = useCurrentUser();
const goToEdit = useCallback(() => {
history.push({
pathname: collectionEditPath(collection),
state: { sidebarContext },
});
}, [collection, sidebarContext]);
const goBack = useCallback(() => {
history.push({
pathname: collectionPath(collection, CollectionTab.Overview),
state: { sidebarContext },
});
}, [collection, sidebarContext]);
return (
<>
{(!isEditing || !user?.separateEditMode) && !collection.isPersonal && (
<Action>
<ShareButton collection={collection} />
</Action>
)}
{!isEditing && user?.separateEditMode && (
<Action>
<RegisterKeyDown trigger="e" handler={goToEdit} />
<Tooltip content={t("Edit collection")} shortcut="e" side="bottom">
<Button icon={<EditIcon />} onClick={goToEdit} neutral>
{t("Edit")}
</Button>
</Tooltip>
</Action>
)}
{isEditing && user?.separateEditMode && (
<Action>
<RegisterKeyDown trigger="Escape" handler={goBack} />
<Button onClick={goBack}>{t("Done editing")}</Button>
</Action>
)}
{can.createDocument && (
<Action>
<Tooltip content={t("New document")} shortcut="n" side="bottom">
<Button
as={Link}
to={collection ? newDocumentPath(collection.id) : ""}
disabled={!collection}
icon={<PlusIcon />}
neutral={isEditing}
>
{t("New doc")}
</Button>
</Tooltip>
</Action>
)}
<Action>
<CollectionMenu collection={collection} align="end" neutral />
</Action>
</>
);
}
export default observer(Actions);