Skip to content

Commit

Permalink
Replace useTranslation in some modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Oct 23, 2024
1 parent fa33a92 commit fc3a55f
Show file tree
Hide file tree
Showing 274 changed files with 888 additions and 608 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Sidebar } from '@rocket.chat/fuselage';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useEndpoint, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts';
import { useEndpoint, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import type { ReactElement, ComponentProps } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useOmnichannelAgentAvailable } from '../../hooks/omnichannel/useOmnichannelAgentAvailable';

type NavBarItemOmnichannelLivechatToggleProps = Omit<ComponentProps<typeof Sidebar.TopBar.Action>, 'icon'>;

const NavBarItemOmnichannelLivechatToggle = (props: NavBarItemOmnichannelLivechatToggleProps): ReactElement => {
const t = useTranslation();
const { t } = useTranslation();
const agentAvailable = useOmnichannelAgentAvailable();
const changeAgentStatus = useEndpoint('POST', '/v1/livechat/agent.status');
const dispatchToastMessage = useToastMessageDispatch();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { NavBarItem } from '@rocket.chat/fuselage';
import { GenericMenu } from '@rocket.chat/ui-client';
import { useCurrentRoutePath, useTranslation } from '@rocket.chat/ui-contexts';
import { useCurrentRoutePath } from '@rocket.chat/ui-contexts';
import type { HTMLAttributes } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useAuditMenu } from './hooks/useAuditMenu';

type NavBarItemAuditMenuProps = Omit<HTMLAttributes<HTMLElement>, 'is'>;

const NavBarItemAuditMenu = (props: NavBarItemAuditMenuProps) => {
const t = useTranslation();
const { t } = useTranslation();
const sections = useAuditMenu();
const currentRoute = useCurrentRoutePath();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { NavBarItem } from '@rocket.chat/fuselage';
import { GenericMenu } from '@rocket.chat/ui-client';
import { useCurrentRoutePath, useTranslation } from '@rocket.chat/ui-contexts';
import { useCurrentRoutePath } from '@rocket.chat/ui-contexts';
import type { HTMLAttributes } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useMarketPlaceMenu } from './hooks/useMarketPlaceMenu';

type NavBarItemMarketPlaceMenuProps = Omit<HTMLAttributes<HTMLElement>, 'is'>;

const NavBarItemMarketPlaceMenu = (props: NavBarItemMarketPlaceMenuProps) => {
const t = useTranslation();
const { t } = useTranslation();
const sections = useMarketPlaceMenu();

const currentRoute = useCurrentRoutePath();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { GenericMenuItemProps } from '@rocket.chat/ui-client';
import { usePermission, useRouter, useTranslation } from '@rocket.chat/ui-contexts';
import { usePermission, useRouter } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';

import { useHasLicenseModule } from '../../../hooks/useHasLicenseModule';

export const useAuditMenu = () => {
const router = useRouter();
const t = useTranslation();
const { t } = useTranslation();

const hasAuditLicense = useHasLicenseModule('auditing') === true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { NavBarItem } from '@rocket.chat/fuselage';
import { GenericMenu } from '@rocket.chat/ui-client';
import { useCurrentRoutePath, useTranslation } from '@rocket.chat/ui-contexts';
import { useCurrentRoutePath } from '@rocket.chat/ui-contexts';
import type { HTMLAttributes } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useAdministrationMenu } from './hooks/useAdministrationMenu';

type NavBarItemAdministrationMenuProps = Omit<HTMLAttributes<HTMLElement>, 'is'>;

const NavBarItemAdministrationMenu = (props: NavBarItemAdministrationMenuProps) => {
const t = useTranslation();
const { t } = useTranslation();
const currentRoute = useCurrentRoutePath();

const sections = useAdministrationMenu();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Button } from '@rocket.chat/fuselage';
import { useSessionDispatch, useTranslation } from '@rocket.chat/ui-contexts';
import { useSessionDispatch } from '@rocket.chat/ui-contexts';
import type { HTMLAttributes } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

type NavBarItemLoginPageProps = Omit<HTMLAttributes<HTMLElement>, 'is'>;

const NavBarItemLoginPage = (props: NavBarItemLoginPageProps) => {
const setForceLogin = useSessionDispatch('forceLogin');
const t = useTranslation();
const { t } = useTranslation();

return (
<Button primary small icon='login' onClick={(): void => setForceLogin(true)} {...props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { IUser } from '@rocket.chat/core-typings';
import { Box, Margins } from '@rocket.chat/fuselage';
import { UserAvatar } from '@rocket.chat/ui-avatar';
import { useSetting, useTranslation } from '@rocket.chat/ui-contexts';
import { useSetting } from '@rocket.chat/ui-contexts';
import React from 'react';
import { useTranslation } from 'react-i18next';

import MarkdownText from '../../../components/MarkdownText';
import { UserStatus } from '../../../components/UserStatus';
Expand All @@ -11,7 +12,7 @@ import { useUserDisplayName } from '../../../hooks/useUserDisplayName';
type UserMenuHeaderProps = { user: IUser };

const UserMenuHeader = ({ user }: UserMenuHeaderProps) => {
const t = useTranslation();
const { t } = useTranslation();
const presenceDisabled = useSetting<boolean>('Presence_broadcast_disabled');
const displayName = useUserDisplayName(user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Badge } from '@rocket.chat/fuselage';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import type { GenericMenuItemProps } from '@rocket.chat/ui-client';
import { defaultFeaturesPreview, usePreferenceFeaturePreviewList } from '@rocket.chat/ui-client';
import { useRouter, useTranslation } from '@rocket.chat/ui-contexts';
import { useRouter } from '@rocket.chat/ui-contexts';
import React from 'react';
import { useTranslation } from 'react-i18next';

export const useAccountItems = (): GenericMenuItemProps[] => {
const t = useTranslation();
const { t } = useTranslation();
const router = useRouter();

const { unseenFeatures, featurePreviewEnabled } = usePreferenceFeaturePreviewList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { IUser } from '@rocket.chat/core-typings';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import type { GenericMenuItemProps } from '@rocket.chat/ui-client';
import { useLogout, useTranslation } from '@rocket.chat/ui-contexts';
import { useLogout } from '@rocket.chat/ui-contexts';
import React from 'react';
import { useTranslation } from 'react-i18next';

import UserMenuHeader from '../UserMenuHeader';
import { useAccountItems } from './useAccountItems';
import { useStatusItems } from './useStatusItems';
import { useVoipItemsSection } from './useVoipItemsSection';

export const useUserMenu = (user: IUser) => {
const t = useTranslation();
const { t } = useTranslation();

const statusItems = useStatusItems();
const accountItems = useAccountItems();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GenericMenuItemProps } from '@rocket.chat/ui-client';
import { useAtLeastOnePermission, usePermission, useRouter, useTranslation } from '@rocket.chat/ui-contexts';
import { useAtLeastOnePermission, usePermission, useRouter } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';

const ADMIN_PERMISSIONS = [
'view-statistics',
Expand Down Expand Up @@ -31,7 +32,7 @@ const ADMIN_PERMISSIONS = [

export const useAdministrationMenu = () => {
const router = useRouter();
const t = useTranslation();
const { t } = useTranslation();

const isAdmin = useAtLeastOnePermission(ADMIN_PERMISSIONS);
const isOmnichannel = usePermission('view-livechat-manager');
Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/client/components/NotFoundState.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Box, States, StatesAction, StatesActions, StatesIcon, StatesSubtitle, StatesTitle } from '@rocket.chat/fuselage';
import { useRouter, useTranslation } from '@rocket.chat/ui-contexts';
import { useRouter } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

type NotFoundProps = {
title: string;
subtitle: string;
};

const NotFoundState = ({ title, subtitle }: NotFoundProps): ReactElement => {
const t = useTranslation();
const { t } = useTranslation();
const router = useRouter();

const handleGoHomeClick = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { OmnichannelSortingMechanismSettingType as OmniSortingType } from '@rocket.chat/core-typings';
import { useSetting, useTranslation } from '@rocket.chat/ui-contexts';
import { useSetting } from '@rocket.chat/ui-contexts';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';

import { useOmnichannelEnterpriseEnabled } from '../../hooks/omnichannel/useOmnichannelEnterpriseEnabled';

Expand All @@ -19,7 +20,7 @@ export const useOmnichannelSortingDisclaimer = () => {
};

export const OmnichannelSortingDisclaimer = () => {
const t = useTranslation();
const { t } = useTranslation();

const type = useOmnichannelSortingDisclaimer();

Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/client/components/Omnichannel/Tags.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { TextInput, Chip, Button, FieldLabel, FieldRow } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts';
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import type { ChangeEvent, ReactElement } from 'react';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';

import { CurrentChatTags } from '../../views/omnichannel/additionalForms';
import { FormSkeleton } from './Skeleton';
Expand All @@ -17,7 +18,7 @@ type TagsProps = {
};

const Tags = ({ tags = [], handler, error, tagRequired, department }: TagsProps): ReactElement => {
const t = useTranslation();
const { t } = useTranslation();

const { data: tagsResult, isInitialLoading } = useLivechatTags({
department,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';

import { useScrollableRecordList } from '../../../hooks/lists/useScrollableRecordList';
import { useComponentDidUpdate } from '../../../hooks/useComponentDidUpdate';
Expand All @@ -24,7 +25,7 @@ export const useAgentsList = (
reload: () => void;
loadMoreItems: (start: number, end: number) => void;
} => {
const t = useTranslation();
const { t } = useTranslation();
const [itemsList, setItemsList] = useState(() => new RecordList<AgentOption>());
const reload = useCallback(() => setItemsList(new RecordList<AgentOption>()), []);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';

import { useScrollableRecordList } from '../../../hooks/lists/useScrollableRecordList';
import { useComponentDidUpdate } from '../../../hooks/useComponentDidUpdate';
Expand Down Expand Up @@ -27,7 +28,7 @@ export const useDepartmentsList = (
reload: () => void;
loadMoreItems: (start: number, end: number) => void;
} => {
const t = useTranslation();
const { t } = useTranslation();
const [itemsList, setItemsList] = useState(() => new RecordList<DepartmentListItem>());
const reload = useCallback(() => setItemsList(new RecordList<DepartmentListItem>()), []);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Button, Modal, Box } from '@rocket.chat/fuselage';
import { useOutsideClick } from '@rocket.chat/fuselage-hooks';
import { useRouter, useTranslation } from '@rocket.chat/ui-contexts';
import { useRouter } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useRef } from 'react';
import { useTranslation } from 'react-i18next';

import { useExternalLink } from '../../../hooks/useExternalLink';
import { useCheckoutUrl } from '../../../views/admin/subscription/hooks/useCheckoutUrl';

const EnterpriseDepartmentsModal = ({ closeModal }: { closeModal: () => void }): ReactElement => {
const t = useTranslation();
const { t } = useTranslation();
const router = useRouter();
const ref = useRef<HTMLDivElement>(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import {
Option,
} from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import { useEndpoint, useSetting, useTranslation } from '@rocket.chat/ui-contexts';
import { useEndpoint, useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import { useRecordList } from '../../../hooks/lists/useRecordList';
import { AsyncStatePhase } from '../../../hooks/useAsyncState';
Expand All @@ -33,7 +34,7 @@ const ForwardChatModal = ({
onCancel: () => void;
room: IOmnichannelRoom;
}): ReactElement => {
const t = useTranslation();
const { t } = useTranslation();
const getUserData = useEndpoint('GET', '/v1/users.info');
const idleAgentsAllowedForForwarding = useSetting('Livechat_enabled_when_agent_idle') as boolean;

Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/client/components/Page/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Box, IconButton } from '@rocket.chat/fuselage';
import { useDocumentTitle } from '@rocket.chat/ui-client';
import { useLayout, useTranslation } from '@rocket.chat/ui-contexts';
import { useLayout } from '@rocket.chat/ui-contexts';
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';

import { HeaderToolbar } from '../Header';
import SidebarToggler from '../SidebarToggler';
Expand All @@ -15,7 +16,7 @@ type PageHeaderProps = {
} & Omit<ComponentPropsWithoutRef<typeof Box>, 'title'>;

const PageHeader = ({ children = undefined, title, onClickBack, borderBlockEndColor, ...props }: PageHeaderProps) => {
const t = useTranslation();
const { t } = useTranslation();
const [border] = useContext(PageContext);
const { isMobile } = useLayout();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Box, FieldGroup, TextInput, Field, FieldLabel, FieldRow, FieldError, Button } from '@rocket.chat/fuselage';
import { useAutoFocus, useUniqueId } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch, useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import { useToastMessageDispatch, useEndpoint } from '@rocket.chat/ui-contexts';
import type { ReactElement, ChangeEvent, SyntheticEvent } from 'react';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';

import GenericModal from '../GenericModal';
import type { OnConfirm } from './TwoFactorModal';
Expand All @@ -17,7 +18,7 @@ type TwoFactorEmailModalProps = {

const TwoFactorEmailModal = ({ onConfirm, onClose, emailOrUsername, invalidAttempt }: TwoFactorEmailModalProps): ReactElement => {
const dispatchToastMessage = useToastMessageDispatch();
const t = useTranslation();
const { t } = useTranslation();
const [code, setCode] = useState<string>('');
const ref = useAutoFocus<HTMLInputElement>();

Expand Down
9 changes: 8 additions & 1 deletion apps/meteor/client/components/UrlChangeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ const UrlChangeModal = ({ onConfirm, siteUrl, currentUrl, onClose }: UrlChangeMo
}),
}}
/>
<p dangerouslySetInnerHTML={{ __html: t('Do_you_want_to_change_to_s_question', currentUrl) }} />
<p
dangerouslySetInnerHTML={{
__html: t('Do_you_want_to_change_to_s_question', {
postProcess: 'sprintf',
sprintf: [currentUrl],
}),
}}
/>
</GenericModal>
);
};
Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/client/components/UserStatusMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { UserStatus as UserStatusType } from '@rocket.chat/core-typings';
import { Button, PositionAnimated, Options, useCursor, Box } from '@rocket.chat/fuselage';
import { useSetting, useTranslation } from '@rocket.chat/ui-contexts';
import { useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement, ComponentProps } from 'react';
import React, { useRef, useCallback, useState, useMemo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';

import { UserStatus } from './UserStatus';

Expand All @@ -21,7 +22,7 @@ const UserStatusMenu = ({
optionWidth = undefined,
placement = 'bottom-end',
}: UserStatusMenuProps): ReactElement => {
const t = useTranslation();
const { t } = useTranslation();
const [status, setStatus] = useState(initialStatus);
const allowInvisibleStatus = useSetting('Accounts_AllowInvisibleStatusOption') as boolean;

Expand Down
Loading

0 comments on commit fc3a55f

Please sign in to comment.