Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move all webclient code out of the COSS folders #32273

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ apps/meteor/server/startup/migrations @RocketChat/Architecture
/apps/meteor/ee/app/canned-responses @RocketChat/omnichannel
/apps/meteor/ee/app/livechat @RocketChat/omnichannel
/apps/meteor/ee/app/livechat-enterprise @RocketChat/omnichannel
/apps/meteor/ee/client/omnichannel @RocketChat/omnichannel
/apps/meteor/client/omnichannel @RocketChat/omnichannel
/apps/meteor/client/components/omnichannel @RocketChat/omnichannel
/apps/meteor/client/components/voip @RocketChat/omnichannel
1 change: 0 additions & 1 deletion apps/meteor/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'../client/**/*.stories.{js,tsx}',
'../app/**/*.stories.{js,tsx}',
'../ee/app/**/*.stories.{js,tsx}',
'../ee/client/**/*.stories.{js,tsx}',
],
addons: [
'@storybook/addon-essentials',
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/authorization/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { hasAllPermission, hasAtLeastOnePermission, hasPermission, userHasAllPermission } from './hasPermission';
import { hasRole, hasAnyRole } from './hasRole';
import './restrictedRoles';

export { hasAllPermission, hasAtLeastOnePermission, hasRole, hasAnyRole, hasPermission, userHasAllPermission };
12 changes: 12 additions & 0 deletions apps/meteor/app/authorization/client/restrictedRoles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Meteor } from 'meteor/meteor';

import { sdk } from '../../utils/client/lib/SDKClient';
import { AuthorizationUtils } from '../lib';

Meteor.startup(async () => {
const result = await sdk.call('license:isEnterprise');
if (result) {
// #ToDo: Load this from the server with an API call instead of having a duplicate list
AuthorizationUtils.addRolePermissionWhiteList('guest', ['view-d-room', 'view-joined-room', 'view-p-room', 'start-discussion']);
}
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { hasPermission } from '../../../../../app/authorization/client';
import { settings } from '../../../../../app/settings/client';
import { sdk } from '../../../../../app/utils/client/lib/SDKClient';
import { hasPermission } from '../../../authorization/client';
import { settings } from '../../../settings/client';
import { sdk } from '../../../utils/client/lib/SDKClient';
import { CannedResponse } from '../collections/CannedResponse';

const events = {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { queryClient } from '../../../../client/lib/queryClient';
import { fetchFeatures } from '../../../client/lib/fetchFeatures';
import { queryClient } from '../../../client/lib/queryClient';

export async function hasLicense(feature: string): Promise<boolean> {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { hasLicense } from '../../license/client';
import '../lib/messageTypes';
import './startup';

void hasLicense('livechat-enterprise').then((enabled) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import type { IMessage } from '@rocket.chat/core-typings';

import { MessageTypes } from '../../../../app/ui-utils/client';
import { t } from '../../../../app/utils/lib/i18n';
import { MessageTypes } from '../../ui-utils/client';
import { t } from '../../utils/lib/i18n';

MessageTypes.registerType({
id: 'livechat_transfer_history_fallback',
system: true,
message: 'New_chat_transfer_fallback',
data(message: any) {
if (!message.transferData) {
return {
fallback: 'SHOULD_NEVER_HAPPEN',
};
}
const from = message.transferData.prevDepartment;
const to = message.transferData.department.name;

return {
fallback: t('Livechat_transfer_failed_fallback', { from, to }),
};
},
});

MessageTypes.registerType({
id: 'omnichannel_priority_change_history',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';

import { businessHourManager } from '../../../../app/livechat/client/views/app/business-hours/BusinessHours';
import type { IBusinessHourBehavior } from '../../../../app/livechat/client/views/app/business-hours/IBusinessHourBehavior';
import { SingleBusinessHourBehavior } from '../../../../app/livechat/client/views/app/business-hours/Single';
import { settings } from '../../../../app/settings/client';
import { hasLicense } from '../../license/client';
import { businessHourManager } from '../../livechat/client/views/app/business-hours/BusinessHours';
import type { IBusinessHourBehavior } from '../../livechat/client/views/app/business-hours/IBusinessHourBehavior';
import { SingleBusinessHourBehavior } from '../../livechat/client/views/app/business-hours/Single';
import { settings } from '../../settings/client';
import { MultipleBusinessHoursBehavior } from './views/business-hours/Multiple';

const businessHours: Record<string, IBusinessHourBehavior> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ILivechatBusinessHour } from '@rocket.chat/core-typings';
import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings';

import type { IBusinessHourBehavior } from '../../../../../../app/livechat/client/views/app/business-hours/IBusinessHourBehavior';
import type { IBusinessHourBehavior } from '../../../../livechat/client/views/app/business-hours/IBusinessHourBehavior';

export class MultipleBusinessHoursBehavior implements IBusinessHourBehavior {
getView(): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hasPermission, hasAtLeastOnePermission } from '../../../../../app/authorization/client';
import { registerOmnichannelSidebarItem } from '../../../../../client/views/omnichannel/sidebarItems';
import { registerOmnichannelSidebarItem } from '../../../../client/views/omnichannel/sidebarItems';
import { hasPermission, hasAtLeastOnePermission } from '../../../authorization/client';

registerOmnichannelSidebarItem({
href: '/omnichannel/reports',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AppsEngineUIHost } from '@rocket.chat/apps-engine/client/AppsEngineUIHost';
import { Meteor } from 'meteor/meteor';

import { ChatRoom } from '../../../app/models/client';
import { getUserAvatarURL } from '../../../app/utils/client/getUserAvatarURL';
import { sdk } from '../../../app/utils/client/lib/SDKClient';
import { RoomManager } from '../../../client/lib/RoomManager';
import { baseURI } from '../../../client/lib/baseURI';
import { ChatRoom } from '../../app/models/client';
import { getUserAvatarURL } from '../../app/utils/client/getUserAvatarURL';
import { sdk } from '../../app/utils/client/lib/SDKClient';
import { RoomManager } from '../lib/RoomManager';
import { baseURI } from '../lib/baseURI';

export class RealAppsEngineUIHost extends AppsEngineUIHost {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import React, { useState } from 'react';
import type { ReactElement } from 'react';

import { preventSyntheticEvent } from '../../../../client/lib/utils/preventSyntheticEvent';
import { useRoomToolbox } from '../../../../client/views/room/contexts/RoomToolboxContext';
import { preventSyntheticEvent } from '../../lib/utils/preventSyntheticEvent';
import { useRoomToolbox } from '../../views/room/contexts/RoomToolboxContext';
import GameCenterContainer from './GameCenterContainer';
import GameCenterList from './GameCenterList';
import { useExternalComponentsQuery } from './hooks/useExternalComponentsQuery';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ContextualbarBack,
ContextualbarContent,
ContextualbarClose,
} from '../../../../client/components/Contextualbar';
} from '../../components/Contextualbar';
import type { IGame } from './GameCenter';

interface IGameCenterContainerProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useState } from 'react';

import GenericModal from '../../../../client/components/GenericModal';
import UserAutoCompleteMultipleFederated from '../../../../client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated';
import { useOpenedRoom } from '../../../../client/lib/RoomManager';
import { roomCoordinator } from '../../../../client/lib/rooms/roomCoordinator';
import { callWithErrorHandling } from '../../../../client/lib/utils/callWithErrorHandling';
import GenericModal from '../../components/GenericModal';
import UserAutoCompleteMultipleFederated from '../../components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated';
import { useOpenedRoom } from '../../lib/RoomManager';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { callWithErrorHandling } from '../../lib/utils/callWithErrorHandling';
import type { IGame } from './GameCenter';

type Username = Exclude<IUser['username'], undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ import { useSetModal, useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useCallback } from 'react';

import {
ContextualbarHeader,
ContextualbarTitle,
ContextualbarClose,
ContextualbarContent,
} from '../../../../client/components/Contextualbar';
import { FormSkeleton } from '../../../../client/components/Skeleton';
import { ContextualbarHeader, ContextualbarTitle, ContextualbarClose, ContextualbarContent } from '../../components/Contextualbar';
import { FormSkeleton } from '../../components/Skeleton';
import type { IGame } from './GameCenter';
import GameCenterInvitePlayersModal from './GameCenterInvitePlayersModal';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import type { IPermission } from '@rocket.chat/apps-engine/definition/permission
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import type { Serialized } from '@rocket.chat/core-typings';

import { hasAtLeastOnePermission } from '../../../app/authorization/client';
import { sdk } from '../../../app/utils/client/lib/SDKClient';
import { dispatchToastMessage } from '../../../client/lib/toast';
import type { App } from '../../../client/views/marketplace/types';
import { hasAtLeastOnePermission } from '../../app/authorization/client';
import { sdk } from '../../app/utils/client/lib/SDKClient';
import { dispatchToastMessage } from '../lib/toast';
import type { App } from '../views/marketplace/types';
import type { IAppExternalURL, ICategory } from './@types/IOrchestrator';
import { RealAppsEngineUIHost } from './RealAppsEngineUIHost';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { ReactElement } from 'react';
import React, { useCallback, useState, useEffect, useMemo } from 'react';
import { useForm } from 'react-hook-form';

import { useHasLicenseModule } from '../../../../ee/client/hooks/useHasLicenseModule';
import { useHasLicenseModule } from '../../../hooks/useHasLicenseModule';
import { dispatchToastMessage } from '../../../lib/toast';
import GenericModal from '../../GenericModal';
import Tags from '../Tags';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-context
import type { ComponentProps, ReactElement } from 'react';
import React from 'react';

import { downloadCsvAs } from '../../../../client/lib/download';
import { downloadCsvAs } from '../../lib/download';

type RowFor<THeaders extends readonly string[]> = readonly unknown[] & {
length: THeaders['length'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ComponentProps, ReactElement } from 'react';
import React from 'react';

import GenericNoResults from '../../../../../client/components/GenericNoResults/GenericNoResults';
import {
GenericTable,
GenericTableHeader,
GenericTableBody,
GenericTableLoadingTable,
} from '../../../../../client/components/GenericTable';
import { AsyncStatePhase } from '../../../../../client/lib/asyncState';
import { AsyncStatePhase } from '../../../lib/asyncState';
import GenericNoResults from '../../GenericNoResults/GenericNoResults';
import { GenericTable, GenericTableHeader, GenericTableBody, GenericTableLoadingTable } from '../../GenericTable';

type DeviceManagementTableProps<T> = {
data?: Serialized<PaginatedResult<{ sessions: T[] }>>;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/contexts/AppsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import type { Serialized } from '@rocket.chat/core-typings';
import { createContext } from 'react';

import type { IAppExternalURL, ICategory } from '../../ee/client/apps/@types/IOrchestrator';
import type { IAppExternalURL, ICategory } from '../apps/@types/IOrchestrator';
import type { AsyncState } from '../lib/asyncState';
import { AsyncStatePhase } from '../lib/asyncState';
import type { App } from '../views/marketplace/types';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/contexts/CallContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Device } from '@rocket.chat/ui-contexts';
import { createContext, useContext, useMemo } from 'react';
import { useSyncExternalStore } from 'use-sync-external-store/shim';

import { useHasLicenseModule } from '../../ee/client/hooks/useHasLicenseModule';
import { useHasLicenseModule } from '../hooks/useHasLicenseModule';
import type { VoIPUser } from '../lib/voip/VoIPUser';

export type CallContextValue = CallContextDisabled | CallContextReady | CallContextError | CallContextEnabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

import { sdk } from '../../app/utils/client/lib/SDKClient';
import type { ClientSession } from '../app/ecdh/client/ClientSession';
import { sdk } from '../app/utils/client/lib/SDKClient';

let resolveSession: (value: ClientSession | void) => void;
const sessionPromise = new Promise<ClientSession | void>((resolve) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';

import { QuickActionsEnum, type QuickActionsActionConfig } from '../../../../client/views/room/lib/quickActions';
import { QuickActionsEnum, type QuickActionsActionConfig } from '../../views/room/lib/quickActions';
import { useHasLicenseModule } from '../useHasLicenseModule';

export const useOnHoldChatQuickAction = (): QuickActionsActionConfig | undefined => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { isRoomFederated } from '@rocket.chat/core-typings';
import { lazy, useContext, useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import { RoomContext } from '../../../../client/views/room/contexts/RoomContext';
import type { RoomToolboxActionConfig } from '../../../../client/views/room/contexts/RoomToolboxContext';
import { RoomContext } from '../../views/room/contexts/RoomContext';
import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext';
import { useHasLicenseModule } from '../useHasLicenseModule';

const VideoConfList = lazy(() => import('../../../../client/views/room/contextualBar/VideoConference/VideoConfList'));
const VideoConfList = lazy(() => import('../../views/room/contextualBar/VideoConference/VideoConfList'));

export const useCallsRoomAction = () => {
const licensed = useHasLicenseModule('videoconference-enterprise') === true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import { lazy, useMemo } from 'react';

import type { RoomToolboxActionConfig } from '../../../../client/views/room/contexts/RoomToolboxContext';
import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext';
import { useHasLicenseModule } from '../useHasLicenseModule';

const CannedResponse = lazy(() => import('../../omnichannel/cannedResponses/contextualBar/CannedResponse/WrapCannedResponseList'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { lazy, useMemo } from 'react';

import type { RoomToolboxActionConfig } from '../../../../client/views/room/contexts/RoomToolboxContext';
import { useExternalComponentsQuery } from '../../apps/gameCenter/hooks/useExternalComponentsQuery';
import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext';

const GameCenter = lazy(() => import('../../apps/gameCenter/GameCenter'));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useSetModal, useTranslation, useToastMessageDispatch, useRoute, useRouteParameter } from '@rocket.chat/ui-contexts';
import React, { useCallback } from 'react';

import GenericModal from '../../../client/components/GenericModal';
import { useEndpointAction } from '../../../client/hooks/useEndpointAction';
import GenericModal from '../components/GenericModal';
import { useEndpointAction } from './useEndpointAction';

export const useDeviceLogout = (
sessionId: string,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/hooks/useDialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { Suspense, lazy, useCallback, useMemo } from 'react';
import { useIsVoipEnterprise } from '../contexts/CallContext';
import { dispatchToastMessage } from '../lib/toast';

const DialPadModal = lazy(() => import('../../ee/client/voip/modal/DialPad/DialPadModal'));
const DialPadModal = lazy(() => import('../voip/modal/DialPad/DialPadModal'));

type DialModalProps = {
initialValue?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { LicenseModule } from '@rocket.chat/core-typings';

import { useLicenseBase } from '../../../client/hooks/useLicense';
import { useLicenseBase } from './useLicense';

export const useHasLicenseModule = (licenseName: LicenseModule): 'loading' | boolean => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallClient, useIsVoipEnterprise } from '../../../client/contexts/CallContext';
import { useCallClient, useIsVoipEnterprise } from '../contexts/CallContext';
import { EEVoipClient } from '../lib/voip/EEVoipClient';

export const useOutboundDialer = (): EEVoipClient | null => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useCallback, useState } from 'react';

import { useScrollableRecordList } from '../../../client/hooks/lists/useScrollableRecordList';
import { useComponentDidUpdate } from '../../../client/hooks/useComponentDidUpdate';
import { RecordList } from '../../../client/lib/lists/RecordList';
import { RecordList } from '../lib/lists/RecordList';
import { useScrollableRecordList } from './lists/useScrollableRecordList';
import { useComponentDidUpdate } from './useComponentDidUpdate';

type TagsListOptions = {
filter: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { useUser, useSetting, useEndpoint, useStream } from '@rocket.chat/ui-con
import { KJUR } from 'jsrsasign';
import { useEffect, useState } from 'react';

import { VoIPUser } from '../../../client/lib/voip/VoIPUser';
import { useWebRtcServers } from '../../../client/providers/CallProvider/hooks/useWebRtcServers';
import { EEVoipClient } from '../lib/voip/EEVoipClient';
import { VoIPUser } from '../lib/voip/VoIPUser';
import { useWebRtcServers } from '../providers/CallProvider/hooks/useWebRtcServers';
import { useHasLicenseModule } from './useHasLicenseModule';

type UseVoipClientResult = {
Expand Down
3 changes: 3 additions & 0 deletions apps/meteor/client/importPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '../app/cors/client';
import '../app/apple/client';
import '../app/authorization/client';
import '../app/autotranslate/client';
import '../app/canned-responses/client';
import '../app/custom-sounds/client';
import '../app/dolphin/client';
import '../app/drupal/client';
Expand All @@ -12,7 +13,9 @@ import '../app/file-upload/client';
import '../app/github-enterprise/client';
import '../app/gitlab/client';
import '../app/iframe-login/client';
import '../app/license/client';
import '../app/lib/client';
import '../app/livechat-enterprise/client';
import '../app/message-mark-as-unread/client';
import '../app/nextcloud/client';
import '../app/notifications/client';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CachedCollectionManager } from '../../../app/ui-cached-collection/client';
import { sdk } from '../../../app/utils/client/lib/SDKClient';
import { CachedCollectionManager } from '../../app/ui-cached-collection/client';
import { sdk } from '../../app/utils/client/lib/SDKClient';

export const fetchFeatures = (): Promise<string[]> =>
new Promise((resolve, reject) => {
Expand Down
Loading
Loading