snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
import type { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import type { Icon } from '@rocket.chat/fuselage';
|
||||
import type { GenericMenuItemProps } from '@rocket.chat/ui-client';
|
||||
import { useEmbeddedLayout } from '@rocket.chat/ui-client';
|
||||
import { useLayoutHiddenActions } from '@rocket.chat/ui-contexts';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useAddUserAction } from './actions/useAddUserAction';
|
||||
import { useBanUserAction } from './actions/useBanUserAction';
|
||||
import { useBlockUserAction } from './actions/useBlockUserAction';
|
||||
import { useChangeLeaderAction } from './actions/useChangeLeaderAction';
|
||||
import { useChangeModeratorAction } from './actions/useChangeModeratorAction';
|
||||
import { useChangeOwnerAction } from './actions/useChangeOwnerAction';
|
||||
import { useDirectMessageAction } from './actions/useDirectMessageAction';
|
||||
import { useIgnoreUserAction } from './actions/useIgnoreUserAction';
|
||||
import { useMuteUserAction } from './actions/useMuteUserAction';
|
||||
import { useRedirectModerationConsole } from './actions/useRedirectModerationConsole';
|
||||
import { useRemoveUserAction } from './actions/useRemoveUserAction';
|
||||
import { useReportUser } from './actions/useReportUser';
|
||||
import { useUserMediaCallAction } from './actions/useUserMediaCallAction';
|
||||
import { useVideoCallAction } from './actions/useVideoCallAction';
|
||||
|
||||
export type UserInfoActionType = 'communication' | 'privileges' | 'management' | 'moderation';
|
||||
|
||||
type UserInfoActionWithOnlyIcon = {
|
||||
type?: UserInfoActionType;
|
||||
content?: string;
|
||||
icon: ComponentProps<typeof Icon>['name'];
|
||||
title: string;
|
||||
variant?: 'danger';
|
||||
onClick: () => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
type UserInfoActionWithContent = {
|
||||
type?: UserInfoActionType;
|
||||
content: string;
|
||||
icon?: ComponentProps<typeof Icon>['name'];
|
||||
title?: string;
|
||||
variant?: 'danger';
|
||||
onClick: () => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export type UserInfoAction = UserInfoActionWithContent | UserInfoActionWithOnlyIcon;
|
||||
|
||||
export type UserMenuAction = {
|
||||
id: string;
|
||||
title: string;
|
||||
items: GenericMenuItemProps[];
|
||||
}[];
|
||||
|
||||
type UserInfoActionsParams = {
|
||||
user: Pick<IUser, '_id' | 'username' | 'name' | 'freeSwitchExtension'>;
|
||||
rid: IRoom['_id'];
|
||||
reload?: () => void;
|
||||
size?: number;
|
||||
isMember?: boolean;
|
||||
isInvited?: boolean;
|
||||
};
|
||||
|
||||
type UseUserInfoActionsResult = {
|
||||
actions: [string, UserInfoAction][];
|
||||
menuActions: UserMenuAction | undefined;
|
||||
};
|
||||
|
||||
export const useUserInfoActions = ({
|
||||
user,
|
||||
rid,
|
||||
reload,
|
||||
size = 2,
|
||||
isMember,
|
||||
isInvited,
|
||||
}: UserInfoActionsParams): UseUserInfoActionsResult => {
|
||||
const addUser = useAddUserAction(user, rid, reload);
|
||||
const blockUser = useBlockUserAction(user, rid);
|
||||
const changeLeader = useChangeLeaderAction(user, rid);
|
||||
const changeModerator = useChangeModeratorAction(user, rid);
|
||||
const openModerationConsole = useRedirectModerationConsole(user._id);
|
||||
const changeOwner = useChangeOwnerAction(user, rid);
|
||||
const openDirectMessage = useDirectMessageAction(user, rid);
|
||||
const ignoreUser = useIgnoreUserAction(user, rid);
|
||||
const muteUser = useMuteUserAction(user, rid);
|
||||
const removeUser = useRemoveUserAction(user, rid, reload, isInvited);
|
||||
const banUser = useBanUserAction(user, rid);
|
||||
const videoCall = useVideoCallAction(user);
|
||||
const reportUserOption = useReportUser(user);
|
||||
const isLayoutEmbedded = useEmbeddedLayout();
|
||||
const { userToolbox: hiddenActions } = useLayoutHiddenActions();
|
||||
const userMediaCall = useUserMediaCallAction(user, rid);
|
||||
|
||||
const userinfoActions = useMemo(
|
||||
() => ({
|
||||
...(openDirectMessage && !isLayoutEmbedded && { openDirectMessage }),
|
||||
...(videoCall && { videoCall }),
|
||||
...(userMediaCall && { userMediaCall }),
|
||||
...(!isMember && addUser && { addUser }),
|
||||
...(isMember && changeOwner && { changeOwner }),
|
||||
...(isMember && changeLeader && { changeLeader }),
|
||||
...(isMember && changeModerator && { changeModerator }),
|
||||
...(isMember && openModerationConsole && { openModerationConsole }),
|
||||
...(isMember && ignoreUser && { ignoreUser }),
|
||||
...(isMember && muteUser && { muteUser }),
|
||||
...(blockUser && { toggleBlock: blockUser }),
|
||||
...((isMember || isInvited) && removeUser && { removeUser }),
|
||||
...((isMember || isInvited) && banUser && { banUser }),
|
||||
...(reportUserOption && { reportUser: reportUserOption }),
|
||||
}),
|
||||
[
|
||||
openDirectMessage,
|
||||
isLayoutEmbedded,
|
||||
videoCall,
|
||||
userMediaCall,
|
||||
changeOwner,
|
||||
changeLeader,
|
||||
changeModerator,
|
||||
ignoreUser,
|
||||
muteUser,
|
||||
blockUser,
|
||||
removeUser,
|
||||
reportUserOption,
|
||||
openModerationConsole,
|
||||
addUser,
|
||||
banUser,
|
||||
isMember,
|
||||
isInvited,
|
||||
],
|
||||
);
|
||||
|
||||
const actionSpread = useMemo(() => {
|
||||
const entries = Object.entries(userinfoActions).filter(([key]) => !hiddenActions.includes(key));
|
||||
|
||||
const options = entries.slice(0, size);
|
||||
const slicedOptions = entries.slice(size, entries.length);
|
||||
|
||||
const menuActions = slicedOptions.reduce((acc, [_key, item]) => {
|
||||
const group = item.type ? item.type : '';
|
||||
const section = acc.find((section: { id: string }) => section.id === group);
|
||||
|
||||
const newItem = {
|
||||
...item,
|
||||
id: item.content || item.title || '',
|
||||
content: item.content || item.title,
|
||||
};
|
||||
|
||||
if (section) {
|
||||
section.items.push(newItem);
|
||||
return acc;
|
||||
}
|
||||
|
||||
const newSection = { id: group, title: '', items: [newItem] };
|
||||
acc.push(newSection);
|
||||
|
||||
return acc;
|
||||
}, [] as UserMenuAction);
|
||||
|
||||
return { actions: options, menuActions };
|
||||
}, [size, userinfoActions, hiddenActions]);
|
||||
|
||||
return actionSpread;
|
||||
};
|
||||
Reference in New Issue
Block a user