mirror of
https://github.com/outline/outline.git
synced 2026-11-22 14:01:41 +03:00
* Initial plan * Add context menu support for table rows in settings Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> * Fix file formatting Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> * Add context menu support to all settings tables Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> * refactor * Reuse hooks * EmojiMenu --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import * as React from "react";
|
|
import type Share from "~/models/Share";
|
|
import usePolicy from "~/hooks/usePolicy";
|
|
import { ActionSeparator } from "~/actions";
|
|
import {
|
|
copyShareUrlFactory,
|
|
goToShareSourceFactory,
|
|
revokeShareFactory,
|
|
} 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
|
|
? []
|
|
: [
|
|
copyShareUrlFactory({ share: targetShare }),
|
|
goToShareSourceFactory({ share: targetShare }),
|
|
ActionSeparator,
|
|
revokeShareFactory({ share: targetShare, can }),
|
|
],
|
|
[targetShare, can]
|
|
);
|
|
|
|
return useMenuAction(actionList);
|
|
}
|