mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +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>
46 lines
1.4 KiB
TypeScript
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);
|
|
}
|