mirror of
https://github.com/outline/outline.git
synced 2026-11-26 23:50:14 +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>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { useMemo } from "react";
|
|
import type Group from "~/models/Group";
|
|
import { ActionSeparator, createExternalLinkAction } from "~/actions";
|
|
import {
|
|
deleteGroupActionFactory,
|
|
editGroupActionFactory,
|
|
groupMembersActionFactory,
|
|
} from "~/actions/definitions/groups";
|
|
import { GroupSection } from "~/actions/sections";
|
|
import { useMenuAction } from "~/hooks/useMenuAction";
|
|
|
|
interface Options {
|
|
/** Whether to hide the "Members" navigation action. */
|
|
hideMembers?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Hook that constructs the action menu for group management operations.
|
|
*
|
|
* @param targetGroup - the group to build actions for, or null to skip.
|
|
* @param options - optional configuration for the menu.
|
|
* @returns action with children for use in menus.
|
|
*/
|
|
export function useGroupMenuActions(
|
|
targetGroup: Group | null,
|
|
options?: Options
|
|
) {
|
|
const actions = useMemo(
|
|
() =>
|
|
!targetGroup
|
|
? []
|
|
: [
|
|
...(options?.hideMembers
|
|
? []
|
|
: [groupMembersActionFactory(targetGroup), ActionSeparator]),
|
|
editGroupActionFactory(targetGroup),
|
|
deleteGroupActionFactory(targetGroup),
|
|
ActionSeparator,
|
|
// Read-only rows surfacing the group's external identifiers.
|
|
createExternalLinkAction({
|
|
name: targetGroup.externalId ?? "",
|
|
section: GroupSection,
|
|
visible: !!targetGroup.externalId,
|
|
disabled: true,
|
|
url: "",
|
|
}),
|
|
createExternalLinkAction({
|
|
name: `External ID: ${targetGroup.externalGroup?.externalId ?? ""}`,
|
|
section: GroupSection,
|
|
visible: !!targetGroup.externalGroup?.externalId,
|
|
disabled: true,
|
|
url: "",
|
|
}),
|
|
],
|
|
[targetGroup, options?.hideMembers]
|
|
);
|
|
|
|
return useMenuAction(actions);
|
|
}
|