mirror of
https://github.com/outline/outline.git
synced 2026-12-01 17:32:49 +03:00
* chore: Audit and move inline actions to definitions * fix: Reuse existing smart-quote translation key in emoji delete dialog Co-Authored-By: Claude <noreply@anthropic.com> * Remove two usages of 'Link copied' translation --------- Co-authored-by: Claude <noreply@anthropic.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import * as React from "react";
|
|
import type Share from "~/models/Share";
|
|
import usePolicy from "~/hooks/usePolicy";
|
|
import { ActionSeparator } from "~/actions";
|
|
import {
|
|
copyShareUrlActionFactory,
|
|
goToShareSourceActionFactory,
|
|
revokeShareActionFactory,
|
|
} from "~/actions/definitions/shares";
|
|
import { useMenuAction } from "~/hooks/useMenuAction";
|
|
|
|
/**
|
|
* Hook that constructs the action menu for share management operations.
|
|
*
|
|
* @param targetShare - the share to build actions for, or null to skip.
|
|
* @returns action with children for use in menus, or undefined if share is null.
|
|
*/
|
|
export function useShareMenuActions(targetShare: Share | null) {
|
|
const can = usePolicy(targetShare ?? ({} as Share));
|
|
|
|
const actionList = React.useMemo(
|
|
() =>
|
|
!targetShare
|
|
? []
|
|
: [
|
|
copyShareUrlActionFactory({ share: targetShare }),
|
|
goToShareSourceActionFactory({ share: targetShare }),
|
|
ActionSeparator,
|
|
revokeShareActionFactory({ share: targetShare, can }),
|
|
],
|
|
[targetShare, can]
|
|
);
|
|
|
|
return useMenuAction(actionList);
|
|
}
|