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,82 @@
|
||||
import { Box } from '@rocket.chat/fuselage';
|
||||
import { GenericMenu, HeaderToolbarAction } from '@rocket.chat/ui-client';
|
||||
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Utilities } from '../../../ee/lib/misc/Utilities';
|
||||
import { UiKitTriggerTimeoutError } from '../../lib/errors/UiKitTriggerTimeoutError';
|
||||
import { useUiKitActionManager } from '../../uikit/hooks/useUiKitActionManager';
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
import { useAppActionButtons } from '../useAppActionButtons';
|
||||
import { useApplyButtonFilters } from '../useApplyButtonFilters';
|
||||
|
||||
export const useAppsRoomStarActions = () => {
|
||||
const result = useAppActionButtons('roomAction');
|
||||
const actionManager = useUiKitActionManager();
|
||||
const applyButtonFilters = useApplyButtonFilters('ai');
|
||||
const room = useRoom();
|
||||
const { t } = useTranslation();
|
||||
const dispatchToastMessage = useToastMessageDispatch();
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!result.data) {
|
||||
return undefined;
|
||||
}
|
||||
const filteredActions = result.data.filter(applyButtonFilters);
|
||||
|
||||
if (filteredActions.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'ai-actions',
|
||||
title: 'AI_Actions',
|
||||
icon: 'stars',
|
||||
groups: ['group', 'channel', 'live', 'team', 'direct', 'direct_multiple'],
|
||||
featured: true,
|
||||
order: 3,
|
||||
renderToolboxItem: ({ id, icon, title, disabled, className }) => (
|
||||
<GenericMenu
|
||||
button={<HeaderToolbarAction icon={icon} />}
|
||||
key={id}
|
||||
title={title}
|
||||
disabled={disabled}
|
||||
items={filteredActions.map((action) => ({
|
||||
id: action.actionId,
|
||||
icon: undefined,
|
||||
title: Utilities.getI18nKeyForApp(action.labelI18n, action.appId),
|
||||
content: <Box is='span'>{t(`${Utilities.getI18nKeyForApp(action.labelI18n, action.appId)}`)}</Box>,
|
||||
variant: action.variant,
|
||||
groups: ['group', 'channel', 'live', 'team', 'direct', 'direct_multiple'],
|
||||
onClick: () => {
|
||||
void actionManager
|
||||
.emitInteraction(action.appId, {
|
||||
type: 'actionButton',
|
||||
actionId: action.actionId,
|
||||
rid: room._id,
|
||||
payload: { context: action.context },
|
||||
})
|
||||
.catch(async (reason) => {
|
||||
if (reason instanceof UiKitTriggerTimeoutError) {
|
||||
dispatchToastMessage({
|
||||
type: 'error',
|
||||
message: t('UIKit_Interaction_Timeout'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
return reason;
|
||||
});
|
||||
},
|
||||
type: 'apps',
|
||||
}))}
|
||||
className={className}
|
||||
placement='bottom-start'
|
||||
icon={icon}
|
||||
/>
|
||||
),
|
||||
};
|
||||
}, [actionManager, applyButtonFilters, dispatchToastMessage, result.data, room._id, t]);
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { useSetting, usePermission } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const AutoTranslate = lazy(() => import('../../views/room/contextualBar/AutoTranslate'));
|
||||
|
||||
export const useAutotranslateRoomAction = () => {
|
||||
const permitted = usePermission('auto-translate');
|
||||
const enabled = useSetting('AutoTranslate_Enabled', false);
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!permitted || !enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'autotranslate',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
title: 'Auto_Translate',
|
||||
icon: 'language',
|
||||
tabComponent: AutoTranslate,
|
||||
order: 20,
|
||||
full: true,
|
||||
type: 'customization',
|
||||
};
|
||||
}, [enabled, permitted]);
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { usePermission } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const BannedUsers = lazy(() => import('../../views/room/contextualBar/BannedUsers'));
|
||||
|
||||
export const useBannedUsersRoomAction = () => {
|
||||
const room = useRoom();
|
||||
|
||||
const hasPermissionToBan = usePermission('ban-user', room._id);
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!hasPermissionToBan) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'banned-users',
|
||||
groups: ['channel', 'group', 'team'],
|
||||
title: 'Banned_Users',
|
||||
icon: 'ban',
|
||||
tabComponent: BannedUsers,
|
||||
order: 13,
|
||||
type: 'moderation',
|
||||
};
|
||||
}, [hasPermissionToBan]);
|
||||
};
|
||||
35
apps/meteor/client/hooks/roomActions/useCallsRoomAction.ts
Normal file
35
apps/meteor/client/hooks/roomActions/useCallsRoomAction.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useContext, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { RoomContext } from '../../views/room/contexts/RoomContext';
|
||||
import { useHasLicenseModule } from '../useHasLicenseModule';
|
||||
|
||||
const VideoConfList = lazy(() => import('../../views/room/contextualBar/VideoConference/VideoConfList'));
|
||||
|
||||
export const useCallsRoomAction = () => {
|
||||
const { data: licensed = false } = useHasLicenseModule('videoconference-enterprise');
|
||||
const room = useContext(RoomContext)?.room;
|
||||
const federated = room ? isRoomFederated(room) : false;
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!licensed) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'calls',
|
||||
groups: ['channel', 'group', 'team', 'direct', 'direct_multiple'],
|
||||
icon: 'phone',
|
||||
title: 'Calls',
|
||||
...(federated && {
|
||||
tooltip: t('core.Video_Call_unavailable_for_this_type_of_room'),
|
||||
disabled: true,
|
||||
}),
|
||||
tabComponent: VideoConfList,
|
||||
order: 999,
|
||||
};
|
||||
}, [licensed, federated, t]);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const Info = lazy(() => import('../../views/room/contextualBar/Info'));
|
||||
|
||||
export const useChannelSettingsRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'channel-settings',
|
||||
groups: ['channel', 'group'],
|
||||
anonymous: true,
|
||||
full: true,
|
||||
title: 'Room_Info',
|
||||
icon: 'info-circled',
|
||||
tabComponent: Info,
|
||||
order: 1,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import { usePermission } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const PruneMessages = lazy(() => import('../../views/room/contextualBar/PruneMessages'));
|
||||
|
||||
export const useCleanHistoryRoomAction = () => {
|
||||
const room = useRoom();
|
||||
const federated = isRoomFederated(room);
|
||||
const permitted = usePermission('clean-channel-history', room._id);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!permitted) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'clean-history',
|
||||
groups: ['channel', 'group', 'team', 'direct_multiple', 'direct'],
|
||||
full: true,
|
||||
title: 'Prune_Messages',
|
||||
icon: 'eraser',
|
||||
...(federated && {
|
||||
tooltip: t('core.Clean_History_unavailable_for_federation'),
|
||||
disabled: true,
|
||||
}),
|
||||
tabComponent: PruneMessages,
|
||||
order: 250,
|
||||
type: 'customization',
|
||||
};
|
||||
}, [federated, permitted, t]);
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import { useSetting } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const Discussions = lazy(() => import('../../views/room/contextualBar/Discussions'));
|
||||
|
||||
export const useDiscussionsRoomAction = () => {
|
||||
const room = useRoom();
|
||||
const federated = isRoomFederated(room);
|
||||
const enabled = useSetting('Discussion_enabled', false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!enabled || !!room.prid) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'discussions',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
title: 'Discussions',
|
||||
icon: 'discussion',
|
||||
tabComponent: Discussions,
|
||||
full: true,
|
||||
...(federated && {
|
||||
disabled: true,
|
||||
tooltip: t('core.Discussions_unavailable_for_federation'),
|
||||
}),
|
||||
order: 3,
|
||||
};
|
||||
}, [enabled, federated, room.prid, t]);
|
||||
};
|
||||
112
apps/meteor/client/hooks/roomActions/useE2EERoomAction.ts
Normal file
112
apps/meteor/client/hooks/roomActions/useE2EERoomAction.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import { useStableCallback } from '@rocket.chat/fuselage-hooks';
|
||||
import { imperativeModal } from '@rocket.chat/ui-client';
|
||||
import { useSetting, usePermission, useEndpoint, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { getRoomTypeTranslation } from '../../lib/getRoomTypeTranslation';
|
||||
import { useRoom, useRoomSubscription } from '../../views/room/contexts/RoomContext';
|
||||
import { useE2EERoomState } from '../../views/room/hooks/useE2EERoomState';
|
||||
import { useE2EEState } from '../../views/room/hooks/useE2EEState';
|
||||
import BaseDisableE2EEModal from '../../views/room/modals/E2EEModals/BaseDisableE2EEModal';
|
||||
import EnableE2EEModal from '../../views/room/modals/E2EEModals/EnableE2EEModal';
|
||||
|
||||
export const useE2EERoomAction = () => {
|
||||
const enabled = useSetting('E2E_Enable', false);
|
||||
const room = useRoom();
|
||||
const subscription = useRoomSubscription();
|
||||
const e2eeState = useE2EEState();
|
||||
const e2eeRoomState = useE2EERoomState(room._id);
|
||||
const isE2EEReady = e2eeState === 'READY' || e2eeState === 'SAVE_PASSWORD';
|
||||
const readyToEncrypt = isE2EEReady || room.encrypted;
|
||||
const permittedToToggleEncryption = usePermission('toggle-room-e2e-encryption', room._id);
|
||||
const permittedToEditRoom = usePermission('edit-room', room._id);
|
||||
const permitted = (room.t === 'd' || (permittedToEditRoom && permittedToToggleEncryption)) && readyToEncrypt;
|
||||
const federated = isRoomFederated(room);
|
||||
const { t } = useTranslation();
|
||||
const dispatchToastMessage = useToastMessageDispatch();
|
||||
|
||||
const isE2EERoomNotReady = () => {
|
||||
if (e2eeRoomState === 'NOT_STARTED' || e2eeRoomState === 'DISABLED' || e2eeRoomState === 'ERROR' || e2eeRoomState === 'WAITING_KEYS') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const enabledOnRoom = !!room.encrypted;
|
||||
|
||||
const roomType = useMemo(() => getRoomTypeTranslation(room)?.toLowerCase(), [room]);
|
||||
|
||||
const roomId = room._id;
|
||||
|
||||
const toggleE2E = useEndpoint('POST', '/v1/rooms.saveRoomSettings');
|
||||
|
||||
const canResetRoomKey = enabled && isE2EEReady && (room.t === 'd' || permittedToToggleEncryption) && isE2EERoomNotReady();
|
||||
|
||||
const action = useStableCallback(async () => {
|
||||
if (enabledOnRoom) {
|
||||
imperativeModal.open({
|
||||
component: BaseDisableE2EEModal,
|
||||
props: {
|
||||
onClose: imperativeModal.close,
|
||||
onConfirm: handleToogleE2E,
|
||||
roomType,
|
||||
roomId,
|
||||
canResetRoomKey,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
imperativeModal.open({
|
||||
component: EnableE2EEModal,
|
||||
props: {
|
||||
onClose: imperativeModal.close,
|
||||
onConfirm: handleToogleE2E,
|
||||
roomType,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const handleToogleE2E = async () => {
|
||||
const { success } = await toggleE2E({ rid: room._id, encrypted: !room.encrypted });
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
|
||||
imperativeModal.close();
|
||||
|
||||
dispatchToastMessage({
|
||||
type: 'success',
|
||||
message: room.encrypted
|
||||
? t('E2E_Encryption_disabled_for_room', { roomName: room.name })
|
||||
: t('E2E_Encryption_enabled_for_room', { roomName: room.name }),
|
||||
});
|
||||
|
||||
if (subscription?.autoTranslate) {
|
||||
dispatchToastMessage({ type: 'success', message: t('AutoTranslate_Disabled_for_room', { roomName: room.name }) });
|
||||
}
|
||||
};
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!enabled || !permitted) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'e2e',
|
||||
groups: ['direct', 'direct_multiple', 'group', 'team'],
|
||||
title: enabledOnRoom ? 'Disable_E2E_encryption' : 'Enable_E2E_encryption',
|
||||
icon: 'key',
|
||||
order: 13,
|
||||
action,
|
||||
type: 'organization',
|
||||
...(federated && {
|
||||
tooltip: t('core.E2E_unavailable_for_federation'),
|
||||
disabled: true,
|
||||
}),
|
||||
};
|
||||
}, [enabled, permitted, federated, t, enabledOnRoom, action]);
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
import { usePermission } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const ExportMessages = lazy(() => import('../../views/room/contextualBar/ExportMessages'));
|
||||
|
||||
export const useExportMessagesRoomAction = () => {
|
||||
const room = useRoom();
|
||||
const permitted = usePermission('mail-messages', room._id);
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!permitted) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'export-messages',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
anonymous: true,
|
||||
title: 'Export_Messages',
|
||||
icon: 'mail',
|
||||
tabComponent: ExportMessages,
|
||||
full: true,
|
||||
order: 12,
|
||||
type: 'communication',
|
||||
};
|
||||
}, [permitted]);
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
import { useExternalComponentsQuery } from '../../apps/gameCenter/hooks/useExternalComponentsQuery';
|
||||
|
||||
const GameCenter = lazy(() => import('../../apps/gameCenter/GameCenter'));
|
||||
|
||||
export const useGameCenterRoomAction = () => {
|
||||
const result = useExternalComponentsQuery();
|
||||
const enabled = result.isSuccess && result.data.length > 0;
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'game-center',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
title: 'Apps_Game_Center',
|
||||
icon: 'game',
|
||||
tabComponent: GameCenter,
|
||||
order: -1,
|
||||
};
|
||||
}, [enabled]);
|
||||
};
|
||||
@@ -0,0 +1,146 @@
|
||||
import type { IUser, IRoom } from '@rocket.chat/core-typings';
|
||||
import { mockAppRoot } from '@rocket.chat/mock-providers';
|
||||
import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts';
|
||||
import { useMediaCallAction } from '@rocket.chat/ui-voip';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
|
||||
import { useMediaCallRoomAction } from './useMediaCallRoomAction';
|
||||
import FakeRoomProvider from '../../../tests/mocks/client/FakeRoomProvider';
|
||||
import { createFakeRoom, createFakeSubscription, createFakeUser } from '../../../tests/mocks/data';
|
||||
|
||||
jest.mock('@rocket.chat/ui-contexts', () => ({
|
||||
...jest.requireActual('@rocket.chat/ui-contexts'),
|
||||
useUserAvatarPath: jest.fn((_args: any) => 'avatar-url'),
|
||||
}));
|
||||
|
||||
jest.mock('@rocket.chat/ui-voip', () => ({
|
||||
useMediaCallAction: jest.fn(),
|
||||
}));
|
||||
|
||||
const getUserInfoMocked = jest.fn().mockResolvedValue({ user: createFakeUser({ _id: 'peer-uid', username: 'peer-username' }) });
|
||||
|
||||
const appRoot = (overrides: { user?: IUser | null; room?: IRoom; subscription?: SubscriptionWithRoom } = {}) => {
|
||||
const {
|
||||
user = createFakeUser({ _id: 'own-uid', username: 'own-username' }),
|
||||
room = createFakeRoom({ uids: ['own-uid', 'peer-uid'] }),
|
||||
subscription = createFakeSubscription(),
|
||||
} = overrides;
|
||||
|
||||
const root = mockAppRoot()
|
||||
.withRoom(room)
|
||||
.withEndpoint('GET', '/v1/users.info', getUserInfoMocked)
|
||||
.wrap((children) => (
|
||||
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
|
||||
{children}
|
||||
</FakeRoomProvider>
|
||||
));
|
||||
|
||||
if (user !== null) {
|
||||
root.withUser(user);
|
||||
}
|
||||
|
||||
return root.build();
|
||||
};
|
||||
|
||||
describe('useMediaCallRoomAction', () => {
|
||||
const useMediaCallActionMocked = jest.mocked(useMediaCallAction);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
useMediaCallActionMocked.mockReturnValue({
|
||||
action: jest.fn(),
|
||||
title: 'Start_call',
|
||||
icon: 'phone',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return undefined if ownUserId is not defined', () => {
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot({ user: null }),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if there are no other users in the room', () => {
|
||||
const fakeRoom = createFakeRoom({ uids: ['own-uid'] });
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot({ room: fakeRoom }),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if there are more than one other user (Group DM)', () => {
|
||||
const fakeRoom = createFakeRoom({ uids: ['own-uid', 'peer-uid-1', 'peer-uid-2'] });
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot({ room: fakeRoom }),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if callAction is undefined', () => {
|
||||
useMediaCallActionMocked.mockReturnValue(undefined);
|
||||
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot(),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if subscription is blocked', () => {
|
||||
const fakeBlockedSubscription = createFakeSubscription({ blocker: false, blocked: true });
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot({ subscription: fakeBlockedSubscription }),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if subscription is blocker', () => {
|
||||
const fakeBlockedSubscription = createFakeSubscription({ blocked: false, blocker: true });
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot({ subscription: fakeBlockedSubscription }),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if room is federated', () => {
|
||||
const fakeFederatedRoom = createFakeRoom({ uids: ['own-uid', 'peer-uid'], federated: true });
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot({ room: fakeFederatedRoom }),
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return the action config if all conditions are met', () => {
|
||||
const actionMock = jest.fn();
|
||||
useMediaCallActionMocked.mockReturnValue({
|
||||
action: actionMock,
|
||||
title: 'Start_call',
|
||||
icon: 'phone',
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useMediaCallRoomAction(), {
|
||||
wrapper: appRoot(),
|
||||
});
|
||||
|
||||
expect(result.current).toEqual({
|
||||
id: 'start-voice-call',
|
||||
title: 'Start_call',
|
||||
icon: 'phone',
|
||||
featured: true,
|
||||
action: expect.any(Function),
|
||||
groups: ['direct'],
|
||||
});
|
||||
|
||||
// Test the action trigger
|
||||
act(() => result.current?.action?.());
|
||||
expect(actionMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import { useUserAvatarPath, useUserId } from '@rocket.chat/ui-contexts';
|
||||
import type { TranslationKey, RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import type { PeerInfo } from '@rocket.chat/ui-voip';
|
||||
import { useMediaCallAction } from '@rocket.chat/ui-voip';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useRoom, useRoomSubscription } from '../../views/room/contexts/RoomContext';
|
||||
import { useUserInfoQuery } from '../useUserInfoQuery';
|
||||
|
||||
const getPeerId = (uids: string[], ownUserId: string | undefined) => {
|
||||
if (!ownUserId) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const otherIds = uids.filter((uid) => uid !== ownUserId);
|
||||
|
||||
// If no id, it's an one user DM. If more than one, it's a group dm. Both are not supported as of now.
|
||||
if (otherIds.length === 0 || otherIds.length > 1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return otherIds[0];
|
||||
};
|
||||
|
||||
export const useMediaCallRoomAction = () => {
|
||||
const room = useRoom();
|
||||
const { uids = [] } = room;
|
||||
const subscription = useRoomSubscription();
|
||||
const ownUserId = useUserId();
|
||||
const federated = isRoomFederated(room);
|
||||
|
||||
const getAvatarUrl = useUserAvatarPath();
|
||||
|
||||
const peerId = getPeerId(uids, ownUserId);
|
||||
|
||||
const { data } = useUserInfoQuery({ userId: peerId as string }, { enabled: !!peerId });
|
||||
|
||||
const peerInfo = useMemo<PeerInfo | undefined>(() => {
|
||||
if (!data?.user?._id) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
userId: data.user._id,
|
||||
displayName: data.user.name || data.user.username || '',
|
||||
avatarUrl: data.user.username
|
||||
? getAvatarUrl({ username: data.user.username, etag: data.user.avatarETag })
|
||||
: getAvatarUrl({ userId: data.user._id }),
|
||||
};
|
||||
}, [data, getAvatarUrl]);
|
||||
|
||||
const callAction = useMediaCallAction(peerInfo);
|
||||
|
||||
const blocked = subscription?.blocked || subscription?.blocker;
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!peerId || !callAction || blocked || federated) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { action, title, icon } = callAction;
|
||||
|
||||
return {
|
||||
id: 'start-voice-call',
|
||||
title: title as TranslationKey,
|
||||
icon,
|
||||
featured: true,
|
||||
action: () => action(),
|
||||
groups: ['direct'] as const,
|
||||
};
|
||||
}, [peerId, callAction, blocked, federated]);
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { isRoomFederated, isRoomNativeFederated } from '@rocket.chat/core-typings';
|
||||
import { usePermission } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { MemberListRouter } from '../../views/room';
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
export const useMembersListRoomAction = () => {
|
||||
const room = useRoom();
|
||||
const broadcast = !!room.broadcast;
|
||||
const team = !!room.teamMain;
|
||||
const permittedToViewBroadcastMemberList = usePermission('view-broadcast-member-list', room._id);
|
||||
|
||||
const isFederated = room && isRoomFederated(room);
|
||||
const isFederationBlocked = isFederated && !isRoomNativeFederated(room);
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (broadcast && !permittedToViewBroadcastMemberList) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (isFederationBlocked) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'members-list',
|
||||
groups: ['channel', 'group', 'team'],
|
||||
title: team ? 'Teams_members' : 'Members',
|
||||
icon: 'members',
|
||||
tabComponent: MemberListRouter,
|
||||
order: 7,
|
||||
};
|
||||
}, [broadcast, permittedToViewBroadcastMemberList, team, isFederationBlocked]);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const MentionsTab = lazy(() => import('../../views/room/contextualBar/MentionsTab'));
|
||||
|
||||
export const useMentionsRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'mentions',
|
||||
groups: ['channel', 'group', 'team'],
|
||||
title: 'Mentions',
|
||||
icon: 'at',
|
||||
tabComponent: MentionsTab,
|
||||
order: 6,
|
||||
type: 'organization',
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useSetting } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const OutlookEventsRoute = lazy(() => import('../../views/outlookCalendar/OutlookEventsRoute'));
|
||||
|
||||
export const useOutlookCalenderRoomAction = () => {
|
||||
const enabled = useSetting('Outlook_Calendar_Enabled', false);
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'outlookCalendar',
|
||||
groups: ['channel', 'group', 'team'],
|
||||
icon: 'calendar',
|
||||
title: 'Outlook_calendar',
|
||||
tabComponent: OutlookEventsRoute,
|
||||
order: 999,
|
||||
};
|
||||
}, [enabled]);
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import { useSetting } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const PinnedMessagesTab = lazy(() => import('../../views/room/contextualBar/PinnedMessagesTab'));
|
||||
|
||||
export const usePinnedMessagesRoomAction = () => {
|
||||
const room = useRoom();
|
||||
const federated = isRoomFederated(room);
|
||||
const enabled = useSetting('Message_AllowPinning', false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'pinned-messages',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
title: 'Pinned_Messages',
|
||||
icon: 'pin',
|
||||
tabComponent: PinnedMessagesTab,
|
||||
...(federated && {
|
||||
tooltip: t('core.Pinned_messages_unavailable_for_federation'),
|
||||
disabled: true,
|
||||
}),
|
||||
order: 9,
|
||||
type: 'organization',
|
||||
};
|
||||
}, [enabled, federated, t]);
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
import { useRoomSubscription } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const NotificationPreferences = lazy(() => import('../../views/room/contextualBar/NotificationPreferences'));
|
||||
|
||||
export const usePushNotificationsRoomAction = () => {
|
||||
const subscription = useRoomSubscription();
|
||||
const capable = !!subscription;
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!capable) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'push-notifications',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
title: 'Notifications_Preferences',
|
||||
icon: 'bell',
|
||||
tabComponent: NotificationPreferences,
|
||||
order: 11,
|
||||
type: 'customization',
|
||||
};
|
||||
}, [capable]);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const MessageSearchTab = lazy(() => import('../../views/room/contextualBar/MessageSearchTab'));
|
||||
|
||||
export const useRocketSearchRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'rocket-search',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'live', 'team'],
|
||||
title: 'Search_Messages',
|
||||
icon: 'magnifier',
|
||||
tabComponent: MessageSearchTab,
|
||||
order: 5,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const StarredMessagesTab = lazy(() => import('../../views/room/contextualBar/StarredMessagesTab'));
|
||||
|
||||
export const useStarredMessagesRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'starred-messages',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
title: 'Starred_Messages',
|
||||
icon: 'star',
|
||||
tabComponent: StarredMessagesTab,
|
||||
order: 10,
|
||||
type: 'organization',
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const TeamsChannels = lazy(() => import('../../views/teams/contextualBar/channels'));
|
||||
|
||||
export const useTeamChannelsRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'team-channels',
|
||||
groups: ['team'],
|
||||
anonymous: true,
|
||||
full: true,
|
||||
title: 'Team_Channels',
|
||||
icon: 'hash',
|
||||
tabComponent: TeamsChannels,
|
||||
order: 2,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const TeamsInfoWithData = lazy(() => import('../../views/teams/contextualBar/info/TeamsInfoWithData'));
|
||||
|
||||
export const useTeamInfoRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'team-info',
|
||||
groups: ['team'],
|
||||
anonymous: true,
|
||||
full: true,
|
||||
title: 'Teams_Info',
|
||||
icon: 'info-circled',
|
||||
tabComponent: TeamsInfoWithData,
|
||||
order: 1,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
65
apps/meteor/client/hooks/roomActions/useThreadRoomAction.tsx
Normal file
65
apps/meteor/client/hooks/roomActions/useThreadRoomAction.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import type { BadgeProps } from '@rocket.chat/fuselage';
|
||||
import { HeaderToolbarAction, HeaderToolbarActionBadge } from '@rocket.chat/ui-client';
|
||||
import { useSetting } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useRoomSubscription } from '../../views/room/contexts/RoomContext';
|
||||
|
||||
const getVariant = (tunreadUser: number, tunreadGroup: number): BadgeProps['variant'] => {
|
||||
if (tunreadUser > 0) {
|
||||
return 'danger';
|
||||
}
|
||||
|
||||
if (tunreadGroup > 0) {
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
return 'primary';
|
||||
};
|
||||
|
||||
const Threads = lazy(() => import('../../views/room/contextualBar/Threads'));
|
||||
|
||||
export const useThreadRoomAction = () => {
|
||||
const enabled = useSetting('Threads_enabled', false);
|
||||
const subscription = useRoomSubscription();
|
||||
|
||||
const tunread = subscription?.tunread?.length ?? 0;
|
||||
const tunreadUser = subscription?.tunreadUser?.length ?? 0;
|
||||
const tunreadGroup = subscription?.tunreadGroup?.length ?? 0;
|
||||
const unread = tunread > 99 ? '99+' : tunread;
|
||||
const variant = getVariant(tunreadUser, tunreadGroup);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'thread',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'team'],
|
||||
full: true,
|
||||
title: 'Threads',
|
||||
icon: 'thread',
|
||||
tabComponent: Threads,
|
||||
order: 2,
|
||||
renderToolboxItem: ({ id, className, icon, title, toolbox: { tab }, disabled, action, tooltip }) => (
|
||||
<HeaderToolbarAction
|
||||
key={id}
|
||||
className={className}
|
||||
id={id}
|
||||
icon={icon}
|
||||
title={t(title)}
|
||||
pressed={id === tab?.id}
|
||||
onClick={action}
|
||||
disabled={disabled}
|
||||
tooltip={tooltip}
|
||||
>
|
||||
{!!unread && <HeaderToolbarActionBadge variant={variant}>{unread}</HeaderToolbarActionBadge>}
|
||||
</HeaderToolbarAction>
|
||||
),
|
||||
};
|
||||
}, [enabled, t, unread, variant]);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { lazy, useMemo } from 'react';
|
||||
|
||||
const RoomFiles = lazy(() => import('../../views/room/contextualBar/RoomFiles'));
|
||||
|
||||
export const useUploadedFilesListRoomAction = () => {
|
||||
return useMemo((): RoomToolboxActionConfig => {
|
||||
return {
|
||||
id: 'uploaded-files-list',
|
||||
groups: ['channel', 'group', 'direct', 'direct_multiple', 'live', 'team'],
|
||||
title: 'Files',
|
||||
icon: 'clip',
|
||||
tabComponent: RoomFiles,
|
||||
order: 8,
|
||||
type: 'organization',
|
||||
};
|
||||
}, []);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { MemberListRouter } from '../../views/room';
|
||||
|
||||
export const useUserInfoGroupRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'user-info-group',
|
||||
groups: ['direct_multiple'],
|
||||
title: 'Members',
|
||||
icon: 'members',
|
||||
tabComponent: MemberListRouter,
|
||||
order: 1,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { MemberListRouter } from '../../views/room';
|
||||
|
||||
export const useUserInfoRoomAction = () => {
|
||||
return useMemo(
|
||||
(): RoomToolboxActionConfig => ({
|
||||
id: 'user-info',
|
||||
groups: ['direct'],
|
||||
title: 'User_Info',
|
||||
icon: 'user',
|
||||
tabComponent: MemberListRouter,
|
||||
order: 1,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
import { isRoomFederated } from '@rocket.chat/core-typings';
|
||||
import { useStableCallback, useStableArray } from '@rocket.chat/fuselage-hooks';
|
||||
import { usePermission, useSetting, useUser } from '@rocket.chat/ui-contexts';
|
||||
import type { RoomToolboxActionConfig } from '@rocket.chat/ui-contexts';
|
||||
import {
|
||||
useVideoConfDispatchOutgoing,
|
||||
useVideoConfIsCalling,
|
||||
useVideoConfIsRinging,
|
||||
useVideoConfLoadCapabilities,
|
||||
} from '@rocket.chat/ui-video-conf';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useRoom } from '../../views/room/contexts/RoomContext';
|
||||
import { useVideoConfWarning } from '../../views/room/contextualBar/VideoConference/hooks/useVideoConfWarning';
|
||||
|
||||
export const useVideoCallRoomAction = () => {
|
||||
const { t } = useTranslation();
|
||||
const room = useRoom();
|
||||
const user = useUser();
|
||||
const federated = isRoomFederated(room);
|
||||
|
||||
const ownUser = room.uids?.length === 1 || false;
|
||||
|
||||
const permittedToPostReadonly = usePermission('post-readonly', room._id);
|
||||
const permittedToCallManagement = usePermission('call-management', room._id);
|
||||
|
||||
const dispatchWarning = useVideoConfWarning();
|
||||
const dispatchPopup = useVideoConfDispatchOutgoing();
|
||||
const loadCapabilities = useVideoConfLoadCapabilities();
|
||||
const isCalling = useVideoConfIsCalling();
|
||||
const isRinging = useVideoConfIsRinging();
|
||||
|
||||
const enabledForDMs = useSetting('VideoConf_Enable_DMs', true);
|
||||
const enabledForChannels = useSetting('VideoConf_Enable_Channels', true);
|
||||
const enabledForTeams = useSetting('VideoConf_Enable_Teams', true);
|
||||
const enabledForGroups = useSetting('VideoConf_Enable_Groups', true);
|
||||
const enabledForLiveChat = useSetting('Omnichannel_call_provider', 'default-provider') === 'default-provider';
|
||||
|
||||
const groups = useStableArray(
|
||||
[
|
||||
enabledForDMs && 'direct',
|
||||
enabledForDMs && 'direct_multiple',
|
||||
enabledForGroups && 'group',
|
||||
enabledForLiveChat && 'live',
|
||||
enabledForTeams && 'team',
|
||||
enabledForChannels && 'channel',
|
||||
].filter((group): group is RoomToolboxActionConfig['groups'][number] => !!group),
|
||||
);
|
||||
|
||||
const visible = groups.length > 0;
|
||||
const allowed = visible && permittedToCallManagement && (!user?.username || !room.muted?.includes(user.username)) && !ownUser;
|
||||
const disabled = federated || (!!room.ro && !permittedToPostReadonly) || room.archived;
|
||||
const tooltip = disabled ? t('core.Video_Call_unavailable_for_this_type_of_room') : undefined;
|
||||
|
||||
const handleOpenVideoConf = useStableCallback(async () => {
|
||||
if (isCalling || isRinging) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await loadCapabilities();
|
||||
dispatchPopup({ rid: room._id });
|
||||
} catch (error: any) {
|
||||
dispatchWarning(error.error);
|
||||
}
|
||||
});
|
||||
|
||||
return useMemo((): RoomToolboxActionConfig | undefined => {
|
||||
if (!allowed) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
id: 'start-video-call',
|
||||
title: 'Video_call',
|
||||
icon: 'video',
|
||||
featured: true,
|
||||
action: handleOpenVideoConf,
|
||||
order: 1,
|
||||
groups,
|
||||
disabled,
|
||||
tooltip,
|
||||
};
|
||||
}, [allowed, groups, disabled, handleOpenVideoConf, tooltip]);
|
||||
};
|
||||
Reference in New Issue
Block a user