Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/CMSPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Box, IconButton } from '@rocket.chat/fuselage';
import { VerticalWizardLayout, VerticalWizardLayoutFooter, VerticalWizardLayoutForm, VerticalWizardLayoutTitle } from '@rocket.chat/layout';
import { useSetting, useTranslation, useAssetWithDarkModePath } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';

import { LoginPoweredBy } from './components/LoginPoweredBy';

type CMSPageProps = {
page: 'Layout_Terms_of_Service' | 'Layout_Privacy_Policy' | 'Layout_Legal_Notice';
};

const CMSPage = ({ page }: CMSPageProps): ReactElement => {
const CMSPage = ({ page }: CMSPageProps) => {
const t = useTranslation();
const pageContent = useSetting(page, '');

Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/EmailConfirmationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { FieldGroup, TextInput, Field, FieldLabel, FieldRow, FieldError, ButtonGroup, Button, Callout } from '@rocket.chat/fuselage';
import { Form, ActionLink } from '@rocket.chat/layout';
import type { ReactElement } from 'react';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

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

export const EmailConfirmationForm = ({ email, onBackToLogin }: { email?: string; onBackToLogin: () => void }): ReactElement => {
export const EmailConfirmationForm = ({ email, onBackToLogin }: { email?: string; onBackToLogin: () => void }) => {
const { t } = useTranslation();

const basicEmailRegex = /^[^@]+@[^@]+$/;
Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Form, ActionLink } from '@rocket.chat/layout';
import { useDocumentTitle } from '@rocket.chat/ui-client';
import { useLoginWithPassword, useSetting } from '@rocket.chat/ui-contexts';
import { useMutation } from '@tanstack/react-query';
import type { ReactElement } from 'react';
import { useEffect, useId, useRef, useState } from 'react';
import { useForm } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -55,7 +54,7 @@ export type LoginErrors = keyof typeof LOGIN_SUBMIT_ERRORS | 'totp-canceled' | s

export type LoginErrorState = [error: LoginErrors, message?: string] | undefined;

export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }) => {
const {
register,
handleSubmit,
Expand Down
10 changes: 2 additions & 8 deletions packages/web-ui-registration/src/LoginServices.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { ButtonGroup, Divider } from '@rocket.chat/fuselage';
import { useLoginServices, useSetting } from '@rocket.chat/ui-contexts';
import type { Dispatch, ReactElement, SetStateAction } from 'react';
import type { Dispatch, SetStateAction } from 'react';
import { useTranslation } from 'react-i18next';

import type { LoginErrorState } from './LoginForm';
import LoginServicesButton from './LoginServicesButton';

const LoginServices = ({
disabled,
setError,
}: {
disabled?: boolean;
setError: Dispatch<SetStateAction<LoginErrorState>>;
}): ReactElement | null => {
const LoginServices = ({ disabled, setError }: { disabled?: boolean; setError: Dispatch<SetStateAction<LoginErrorState>> }) => {
const { t } = useTranslation();
const services = useLoginServices();
const showFormLogin = useSetting('Accounts_ShowFormLogin');
Expand Down
4 changes: 2 additions & 2 deletions packages/web-ui-registration/src/LoginServicesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button } from '@rocket.chat/fuselage';
import type { Keys as IconName } from '@rocket.chat/icons';
import type { LoginService } from '@rocket.chat/ui-contexts';
import { useLoginWithService } from '@rocket.chat/ui-contexts';
import type { ReactElement, SetStateAction, Dispatch } from 'react';
import type { SetStateAction, Dispatch } from 'react';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';

Expand All @@ -23,7 +23,7 @@ const LoginServicesButton = <T extends LoginService>({
className?: string;
disabled?: boolean;
setError?: Dispatch<SetStateAction<LoginErrorState>>;
}): ReactElement => {
}) => {
const { t } = useTranslation();
const handler = useLoginWithService({ service, buttonLabelText, ...props });

Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { Form, ActionLink } from '@rocket.chat/layout';
import { CustomFieldsForm, PasswordVerifier, useValidatePassword } from '@rocket.chat/ui-client';
import { useAccountsCustomFields, useSetting, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useEffect, useId, useRef, useState } from 'react';
import { useForm } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';
Expand All @@ -33,7 +32,7 @@ type LoginRegisterPayload = {
reason: string;
};

export const RegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
export const RegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }) => {
const { t } = useTranslation();

const requireNameForRegister = useSetting('Accounts_RequireNameForSignUp', true);
Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/RegisterFormDisabled.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Callout } from '@rocket.chat/fuselage';
import { Form, ActionLink } from '@rocket.chat/layout';
import { useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { Trans, useTranslation } from 'react-i18next';

import type { DispatchLoginRouter } from './hooks/useLoginRouter';

export const RegisterFormDisabled = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
export const RegisterFormDisabled = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }) => {
const linkReplacementText = useSetting('Accounts_RegistrationForm_LinkReplacementText', '');

const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useDocumentTitle } from '@rocket.chat/ui-client';
import { useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';

import RegisterForm from './RegisterForm';
Expand All @@ -17,7 +16,7 @@ export const RegisterSecretPageRouter = ({
}: {
setLoginRoute: DispatchLoginRouter;
origin: 'register' | 'secret-register' | 'invite-register';
}): ReactElement => {
}) => {
const { t } = useTranslation();
const registrationMode = useSetting<'Public' | 'Disabled' | 'Secret URL'>('Accounts_RegistrationForm', 'Public');

Expand Down
10 changes: 2 additions & 8 deletions packages/web-ui-registration/src/RegistrationPageRouter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSession } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';

import GuestForm from './GuestForm';
Expand All @@ -10,13 +10,7 @@ import ResetPasswordForm from './ResetPasswordForm';
import { useLoginRouter } from './hooks/useLoginRouter';
import type { LoginRoutes } from './hooks/useLoginRouter';

export const RegistrationPageRouter = ({
defaultRoute = 'login',
children,
}: {
defaultRoute?: LoginRoutes;
children?: ReactNode;
}): ReactElement | null => {
export const RegistrationPageRouter = ({ defaultRoute = 'login', children }: { defaultRoute?: LoginRoutes; children?: ReactNode }) => {
const { t } = useTranslation();
const defaultRouteSession = useSession('loginDefaultState') as LoginRoutes | undefined;
const [route, setLoginRoute] = useLoginRouter(defaultRouteSession || defaultRoute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
useLoginWithToken,
useEndpoint,
} from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useEffect, useId, useRef } from 'react';
import { useForm } from 'react-hook-form';

Expand All @@ -24,7 +23,7 @@ const getChangePasswordReason = ({
requirePasswordChangeReason = requirePasswordChange ? 'You_need_to_change_your_password' : 'Please_enter_your_new_password_below',
}: Pick<IUser, 'requirePasswordChange' | 'requirePasswordChangeReason'> = {}) => requirePasswordChangeReason as TranslationKey;

const ResetPasswordPage = (): ReactElement => {
const ResetPasswordPage = () => {
const user = useUser();
const t = useTranslation();
const setBasicInfo = useEndpoint('POST', '/v1/users.updateOwnBasicInfo');
Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/ResetPasswordForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { FieldGroup, TextInput, Field, FieldLabel, FieldRow, FieldError, ButtonGroup, Button, Callout } from '@rocket.chat/fuselage';
import { Form, ActionLink } from '@rocket.chat/layout';
import { useDocumentTitle } from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { useEffect, useId, useRef } from 'react';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import type { DispatchLoginRouter } from './hooks/useLoginRouter';
import { useSendForgotPassword } from './hooks/useSendForgotPassword';

export const ResetPasswordForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
export const ResetPasswordForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }) => {
const { t } = useTranslation();
const emailId = useId();
const formLabelId = useId();
Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/SecretRegisterForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useRouteParameter } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';

import RegisterForm from './RegisterForm';
import SecretRegisterInvalidForm from './SecretRegisterInvalidForm';
Expand All @@ -8,7 +7,7 @@ import type { DispatchLoginRouter } from './hooks/useLoginRouter';
import FormSkeleton from './template/FormSkeleton';
import HorizontalTemplate from './template/HorizontalTemplate';

const SecretRegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
const SecretRegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }) => {
const hash = useRouteParameter('hash');

const { data: valid, isSuccess } = useCheckRegistrationSecret(hash);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';

import VerticalTemplate from './template/VerticalTemplate';

const SecretRegisterInvalidForm = (): ReactElement => {
const SecretRegisterInvalidForm = () => {
const { t } = useTranslation();

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Box } from '@rocket.chat/fuselage';
import { ActionLink } from '@rocket.chat/layout';
import { useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { Trans } from 'react-i18next';

export const LoginPoweredBy = (): ReactElement | null => {
export const LoginPoweredBy = () => {
const hidePoweredBy = useSetting('Layout_Login_Hide_Powered_By', false);
if (hidePoweredBy) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HorizontalWizardLayoutCaption } from '@rocket.chat/layout';
import { normalizeLanguage } from '@rocket.chat/tools';
import { type TranslationLanguage, useSetting, useLoadLanguage, useLanguage, useLanguages } from '@rocket.chat/ui-contexts';
import { useMemo, useEffect } from 'react';
import type { ReactElement, UIEvent } from 'react';
import type { UIEvent } from 'react';
import { Trans, useTranslation } from 'react-i18next';

const useSuggestedLanguages = ({
Expand Down Expand Up @@ -41,7 +41,7 @@ type LoginSwitchLanguageFooterProps = {

const LoginSwitchLanguageFooter = ({
browserLanguage = normalizeLanguage(window.navigator.language ?? 'en'),
}: LoginSwitchLanguageFooterProps): ReactElement | null => {
}: LoginSwitchLanguageFooterProps) => {
const loadLanguage = useLoadLanguage();
const { suggestions } = useSuggestedLanguages({ browserLanguage });

Expand Down
3 changes: 1 addition & 2 deletions packages/web-ui-registration/src/components/LoginTerms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { Box } from '@rocket.chat/fuselage';
import { HorizontalWizardLayoutCaption } from '@rocket.chat/layout';
import { useSetting } from '@rocket.chat/ui-contexts';
import DOMPurify from 'dompurify';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';

export const LoginTerms = (): ReactElement => {
export const LoginTerms = () => {
const { t } = useTranslation();
const loginTerms = useSetting('Layout_Login_Terms', '');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { Trans } from 'react-i18next';

export const RegisterTitle = (): ReactElement | null => {
export const RegisterTitle = () => {
const siteName = useSetting('Site_Name', 'Rocket.Chat');
const hideTitle = useSetting('Layout_Login_Hide_Title', false);

Expand Down
55 changes: 26 additions & 29 deletions packages/web-ui-registration/src/template/FormSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
import { Field, FieldLabel, FieldRow, FieldHint, FieldDescription, Skeleton, InputBoxSkeleton } from '@rocket.chat/fuselage';
import { Form } from '@rocket.chat/layout';
import type { ReactElement } from 'react';

const FormSkeleton = (): ReactElement => {
return (
<Form aria-busy>
<Form.Header>
<Form.Title>
<Skeleton />
</Form.Title>
</Form.Header>
<Form.Container></Form.Container>
<Field>
<FieldLabel>
<Skeleton />
</FieldLabel>
<FieldDescription>
<Skeleton />
</FieldDescription>
<FieldRow>
<InputBoxSkeleton />
</FieldRow>
<FieldHint>
<Skeleton />
</FieldHint>
</Field>
<Form.Footer>
const FormSkeleton = () => (
<Form aria-busy>
<Form.Header>
<Form.Title>
<Skeleton />
</Form.Footer>
</Form>
);
};
</Form.Title>
</Form.Header>
<Form.Container></Form.Container>
<Field>
<FieldLabel>
<Skeleton />
</FieldLabel>
<FieldDescription>
<Skeleton />
</FieldDescription>
<FieldRow>
<InputBoxSkeleton />
</FieldRow>
<FieldHint>
<Skeleton />
</FieldHint>
</Field>
<Form.Footer>
<Skeleton />
</Form.Footer>
</Form>
);

export default FormSkeleton;
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
HorizontalWizardLayoutFooter,
} from '@rocket.chat/layout';
import { useSetting, useAssetWithDarkModePath } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';

import LoginPoweredBy from '../components/LoginPoweredBy';
import LoginSwitchLanguageFooter from '../components/LoginSwitchLanguageFooter';
import LoginTerms from '../components/LoginTerms';
import { RegisterTitle } from '../components/RegisterTitle';

const HorizontalTemplate = ({ children }: { children: ReactNode }): ReactElement => {
const HorizontalTemplate = ({ children }: { children: ReactNode }) => {
const hideLogo = useSetting('Layout_Login_Hide_Logo', false);
const customLogo = useAssetWithDarkModePath('logo');
const customBackground = useAssetWithDarkModePath('background');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Box } from '@rocket.chat/fuselage';
import { VerticalWizardLayout, VerticalWizardLayoutTitle, VerticalWizardLayoutFooter } from '@rocket.chat/layout';
import { useSetting, useAssetWithDarkModePath } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';

import LoginPoweredBy from '../components/LoginPoweredBy';
import LoginSwitchLanguageFooter from '../components/LoginSwitchLanguageFooter';
import LoginTerms from '../components/LoginTerms';
import { RegisterTitle } from '../components/RegisterTitle';

const VerticalTemplate = ({ children }: { children: ReactNode }): ReactElement => {
const VerticalTemplate = ({ children }: { children: ReactNode }) => {
const hideLogo = useSetting('Layout_Login_Hide_Logo', false);
const customLogo = useAssetWithDarkModePath('logo');
const customBackground = useAssetWithDarkModePath('background');
Expand Down
Loading