Files
outline/app/hooks/useUserMenuActions.tsx
T
Tom MoorandClaude 8192bc0514 chore: Audit and move inline actions to definitions (#13133)
* 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>
2026-07-25 16:13:12 +00:00

46 lines
1.4 KiB
TypeScript

import { useMemo } from "react";
import type User from "~/models/User";
import { ActionSeparator } from "~/actions";
import {
activateUserActionFactory,
changeUserAvatarActionFactory,
changeUserEmailActionFactory,
changeUserNameActionFactory,
changeUserRoleActionFactory,
deleteUserActionFactory,
resendInviteActionFactory,
revokeInviteActionFactory,
suspendUserActionFactory,
} from "~/actions/definitions/users";
import { useMenuAction } from "~/hooks/useMenuAction";
/**
* Hook that constructs the action menu for user management operations.
*
* @param targetUser - the user to build actions for, or null to skip.
* @returns action with children for use in menus.
*/
export function useUserMenuActions(targetUser: User | null) {
const actions = useMemo(
() =>
targetUser
? [
changeUserRoleActionFactory(targetUser),
changeUserAvatarActionFactory(targetUser),
changeUserNameActionFactory(targetUser),
changeUserEmailActionFactory(targetUser),
resendInviteActionFactory(targetUser),
ActionSeparator,
revokeInviteActionFactory(targetUser),
activateUserActionFactory(targetUser),
suspendUserActionFactory(targetUser),
ActionSeparator,
deleteUserActionFactory(targetUser.id),
]
: [],
[targetUser]
);
return useMenuAction(actions);
}