From 338620277322fc519a398b350fdb963f3977d863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Jaeger=20Foresti?= <60678893+juliajforesti@users.noreply.github.com> Date: Mon, 2 Oct 2023 21:37:17 -0300 Subject: [PATCH] refactor: replace `Field.[SUBCOMPONENT]` in favor of named imports (#1180) Co-authored-by: Tasso Evangelista --- .../FieldGroup/FieldGroup.stories.tsx | 29 +-- .../src/components/Modal/Modal.stories.tsx | 17 +- .../HorizontalWizardLayout.stories.tsx | 166 ++++++++-------- .../VerticalWizardLayout.stories.tsx | 178 +++++++++--------- .../src/forms/AdminInfoForm/AdminInfoForm.tsx | 46 ++--- .../CreateCloudWorkspaceForm.tsx | 73 +++---- .../CreateFirstMemberForm.tsx | 23 ++- .../CreateNewPassword/CreateNewPassword.tsx | 23 ++- .../src/forms/LoginForm/LoginForm.tsx | 23 ++- .../forms/NewAccountForm/NewAccountForm.tsx | 49 ++--- .../OrganizationInfoForm.tsx | 43 +++-- .../RegisterServerForm/RegisterServerForm.tsx | 31 ++- .../RequestTrialForm/RequestTrialForm.tsx | 48 ++--- .../ResetPasswordForm/ResetPasswordForm.tsx | 18 +- .../src/forms/TotpForm/TotpForm.tsx | 19 +- 15 files changed, 431 insertions(+), 355 deletions(-) diff --git a/packages/fuselage/src/components/FieldGroup/FieldGroup.stories.tsx b/packages/fuselage/src/components/FieldGroup/FieldGroup.stories.tsx index d129f6dd86..a945432db3 100644 --- a/packages/fuselage/src/components/FieldGroup/FieldGroup.stories.tsx +++ b/packages/fuselage/src/components/FieldGroup/FieldGroup.stories.tsx @@ -2,7 +2,14 @@ import { Title, Description, Primary, Stories } from '@storybook/addon-docs'; import type { ComponentStory, ComponentMeta } from '@storybook/react'; import React from 'react'; -import { Field, FieldGroup, InputBox } from '../..'; +import { + Field, + FieldGroup, + FieldHint, + FieldLabel, + FieldRow, + InputBox, +} from '../..'; export default { title: 'Inputs/FieldGroup', @@ -29,23 +36,23 @@ export default { export const Default: ComponentStory = () => ( - Field #1 - + Field #1 + - + - Field #2 - + Field #2 + - - Help text + + Help text - Field #3 - + Field #3 + - + ); diff --git a/packages/fuselage/src/components/Modal/Modal.stories.tsx b/packages/fuselage/src/components/Modal/Modal.stories.tsx index 7859842ee4..0a2bea4d2e 100644 --- a/packages/fuselage/src/components/Modal/Modal.stories.tsx +++ b/packages/fuselage/src/components/Modal/Modal.stories.tsx @@ -3,7 +3,16 @@ import type { ComponentStory } from '@storybook/react'; import type { ComponentProps } from 'react'; import React from 'react'; -import { FieldGroup, Field, TextInput, Button, Modal, Box } from '../..'; +import { + FieldGroup, + Field, + TextInput, + Button, + Modal, + Box, + FieldLabel, + FieldRow, +} from '../..'; export default { title: 'Containers/Modal', @@ -193,10 +202,10 @@ export const _WithForm: ComponentStory = () => ( - Label - + Label + - + diff --git a/packages/layout/src/HorizontalWizardLayout/HorizontalWizardLayout.stories.tsx b/packages/layout/src/HorizontalWizardLayout/HorizontalWizardLayout.stories.tsx index dc82b25ba6..be0c891759 100644 --- a/packages/layout/src/HorizontalWizardLayout/HorizontalWizardLayout.stories.tsx +++ b/packages/layout/src/HorizontalWizardLayout/HorizontalWizardLayout.stories.tsx @@ -1,4 +1,12 @@ -import { Field, InputBox } from '@rocket.chat/fuselage'; +import { + Field, + FieldDescription, + FieldError, + FieldHint, + FieldLabel, + FieldRow, + InputBox, +} from '@rocket.chat/fuselage'; import type { Meta, Story } from '@storybook/react'; import { ActionLink, Form } from '..'; @@ -45,13 +53,13 @@ export const Default: Story = (props) => ( - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint footer @@ -80,112 +88,112 @@ export const WithScroll: Story = (props) => ( - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint footer diff --git a/packages/layout/src/VerticalWizardLayout/VerticalWizardLayout.stories.tsx b/packages/layout/src/VerticalWizardLayout/VerticalWizardLayout.stories.tsx index 942ed6c629..bb0f688666 100644 --- a/packages/layout/src/VerticalWizardLayout/VerticalWizardLayout.stories.tsx +++ b/packages/layout/src/VerticalWizardLayout/VerticalWizardLayout.stories.tsx @@ -1,4 +1,12 @@ -import { Field, InputBox } from '@rocket.chat/fuselage'; +import { + Field, + FieldDescription, + FieldError, + FieldHint, + FieldLabel, + FieldRow, + InputBox, +} from '@rocket.chat/fuselage'; import type { Meta, Story } from '@storybook/react'; import Form from '../FormPageLayout'; @@ -25,13 +33,13 @@ export const Default: Story = () => ( - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint footer @@ -54,121 +62,121 @@ export const WithScroll: Story = () => ( - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint {' '} - Label - Description - + Label + Description + - - Error - Hint + + Error + Hint footer diff --git a/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx b/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx index 3edb8af36d..4948f53234 100644 --- a/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx +++ b/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx @@ -8,6 +8,10 @@ import { TextInput, Box, CheckBox, + FieldLabel, + FieldRow, + FieldError, + FieldHint, } from '@rocket.chat/fuselage'; import { useUniqueId } from '@rocket.chat/fuselage-hooks'; import { Form } from '@rocket.chat/layout'; @@ -81,10 +85,10 @@ const AdminInfoForm = ({ - + {t('form.adminInfoForm.fields.fullName.label')} - - + + - + {errors.fullname && ( - {errors.fullname.message} + {errors.fullname.message} )} - + {t('form.adminInfoForm.fields.username.label')} - - + + - + {errors.username && ( - {errors.username.message} + {errors.username.message} )} - + {t('form.adminInfoForm.fields.email.label')} - - + + - - {errors.email && {errors.email.message}} + + {errors.email && {errors.email.message}} - + {t('form.adminInfoForm.fields.password.label')} - - + + - - {passwordRulesHint} + + {passwordRulesHint} {errors.password && ( - {errors.password.message} + {errors.password.message} )} {keepPosted && ( diff --git a/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx b/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx index 0e14d8e1e9..0e4b54085f 100644 --- a/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx +++ b/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx @@ -1,7 +1,10 @@ import type { SelectOption } from '@rocket.chat/fuselage'; import { + FieldLabel, + FieldRow, FieldGroup, Field, + FieldError, ButtonGroup, Button, Box, @@ -76,10 +79,10 @@ const CreateCloudWorkspaceForm = ({ - - {t('form.createCloudWorkspace.fields.orgEmail.label')} - - + + {t('form.createCloudWorkspace.fields.orgEmaillabel')} + + - + {errors?.organizationEmail && ( - {errors.organizationEmail.message} + {errors.organizationEmail.message} )} - + - {t('form.createCloudWorkspace.fields.workspaceName.label')} + {t('form.createCloudWorkspace.fields.workspaceNamelabel')} - - + + - + {errors.workspaceName && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} - + - {t('form.createCloudWorkspace.fields.workspaceUrl.label')} + {t('form.createCloudWorkspace.fields.workspaceUrllabel')} - - + + - + {errors?.workspaceURL && ( - {errors.workspaceURL.message} + {errors.workspaceURL.message} )} - + - {t('form.createCloudWorkspace.fields.serverRegion.label')} + {t('form.createCloudWorkspace.fields.serverRegionlabel')} - - + + )} /> - + - + - {t('form.createCloudWorkspace.fields.language.label')} + {t('form.createCloudWorkspace.fields.languagelabel')} - - + + )} /> - + @@ -201,7 +204,7 @@ const CreateCloudWorkspaceForm = ({ - + @@ -223,19 +226,19 @@ const CreateCloudWorkspaceForm = ({ - + {errors.agreement?.type === 'required' && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} - + {t('form.createCloudWorkspace.fields.keepMeInformed')} - + diff --git a/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx b/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx index 3bf542c439..eed996fcb3 100644 --- a/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx +++ b/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx @@ -7,6 +7,9 @@ import { PasswordInput, TextInput, Throbber, + FieldLabel, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; @@ -58,12 +61,12 @@ const CreateFirstMemberForm = ({ - + {t('form.createFirstMemberForm.fields.username.label')} - - + + - + {errors?.username && ( - {errors.username.message} + {errors.username.message} )} - + {t('form.createFirstMemberForm.fields.password.label')} - - + + - + {errors.password && ( - {errors.password.message} + {errors.password.message} )} diff --git a/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx b/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx index 0c03d0c277..d47e434970 100644 --- a/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx +++ b/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx @@ -4,6 +4,9 @@ import { PasswordInput, ButtonGroup, Button, + FieldLabel, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; @@ -47,10 +50,10 @@ const CreateNewPassword = ({ - + {t('form.createPasswordForm.fields.password.label')} - - + + - + {errors.password && ( - {errors.password.message} + {errors.password.message} )} - + {t('form.createPasswordForm.fields.confirmPassword.label')} - - + + - + {errors.passwordConfirmation && ( - {errors.passwordConfirmation.message} + {errors.passwordConfirmation.message} )} diff --git a/packages/onboarding-ui/src/forms/LoginForm/LoginForm.tsx b/packages/onboarding-ui/src/forms/LoginForm/LoginForm.tsx index e02dbb5d9d..ff4c0671b8 100644 --- a/packages/onboarding-ui/src/forms/LoginForm/LoginForm.tsx +++ b/packages/onboarding-ui/src/forms/LoginForm/LoginForm.tsx @@ -5,6 +5,9 @@ import { PasswordInput, Button, Box, + FieldLabel, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { Form, ActionLink } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; @@ -61,32 +64,32 @@ const LoginForm = ({ - {t('form.loginForm.fields.email.label')} - + {t('form.loginForm.fields.email.label')} + - - {errors.email && {errors.email.message}} + + {errors.email && {errors.email.message}} {!isPasswordLess && ( - + {t('form.loginForm.fields.password.label')} - - + + - + {(formError || errors.password) && ( - + {t('form.loginForm.fields.password.error')} - + )} )} diff --git a/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx b/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx index 602d5f423b..58c1a99e31 100644 --- a/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx +++ b/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx @@ -8,6 +8,9 @@ import { TextInput, Box, CheckBox, + FieldLabel, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; @@ -56,66 +59,66 @@ const NewAccountForm = ({ - + {t('form.newAccountForm.fields.name.label')} - - + + - - {errors.name && {errors.name.message}} + + {errors.name && {errors.name.message}} - + {t('form.newAccountForm.fields.email.label')} - - + + - - {errors?.email && {errors.email.message}} + + {errors?.email && {errors.email.message}} - + {t('form.newAccountForm.fields.password.label')} - - + + - + {errors.password && ( - {errors.password.message} + {errors.password.message} )} - + {t('form.newAccountForm.fields.confirmPassword.label')} - - + + - + {errors.confirmPassword && ( - {errors.confirmPassword.message} + {errors.confirmPassword.message} )} - + - + {errors.agreement?.type === 'required' && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} diff --git a/packages/onboarding-ui/src/forms/OrganizationInfoForm/OrganizationInfoForm.tsx b/packages/onboarding-ui/src/forms/OrganizationInfoForm/OrganizationInfoForm.tsx index 3eb40206e8..a2c5bd05b3 100644 --- a/packages/onboarding-ui/src/forms/OrganizationInfoForm/OrganizationInfoForm.tsx +++ b/packages/onboarding-ui/src/forms/OrganizationInfoForm/OrganizationInfoForm.tsx @@ -1,5 +1,8 @@ import type { SelectOption } from '@rocket.chat/fuselage'; import { + FieldError, + FieldLabel, + FieldRow, FieldGroup, Field, ButtonGroup, @@ -82,10 +85,10 @@ const OrganizationInfoForm = ({ - + {t('form.organizationInfoForm.fields.organizationName.label')} - - + + - + {errors.organizationName && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} - + {t('form.organizationInfoForm.fields.organizationIndustry.label')} - - + + )} /> - + {errors.organizationIndustry && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} - + {t('form.organizationInfoForm.fields.organizationSize.label')} - - + + )} /> - + {errors.organizationSize && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} - + {t('form.organizationInfoForm.fields.country.label')} - - + + )} /> - + {errors.country && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} diff --git a/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx b/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx index d3d99802c4..cd5479c776 100644 --- a/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx +++ b/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx @@ -5,7 +5,10 @@ import { Field, EmailInput, CheckBox, - Label, + Icon, + FieldLabel, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { useUniqueId, useBreakpoints } from '@rocket.chat/fuselage-hooks'; import { Form, ActionLink } from '@rocket.chat/layout'; @@ -77,15 +80,23 @@ const RegisterServerForm = ({ {!offline && ( - {t('form.registeredServerForm.fields.accountEmail.inputLabel')} - - + + + - + {errors.email && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} @@ -117,7 +128,7 @@ const RegisterServerForm = ({ {t('form.registeredServerForm.keepInformed')} - {' '} - - + + )} diff --git a/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx b/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx index 29b1950c25..59524ae65a 100644 --- a/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx +++ b/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx @@ -1,5 +1,9 @@ import type { SelectOption } from '@rocket.chat/fuselage'; import { + FieldDescription, + FieldError, + FieldLabel, + FieldRow, Button, Field, Box, @@ -58,10 +62,10 @@ const RequestTrialForm = ({
- + {t('form.requestTrialForm.fields.emailAddress.label')} - - + + - - {errors?.email && {errors.email.message}} + + {errors?.email && {errors.email.message}} - + {t('form.requestTrialForm.fields.organizationName.label')} - - + + - + {errors?.organizationName && ( - {t('component.form.requiredField')} + {t('component.form.requiredField')} )} - + {t('form.requestTrialForm.fields.organizationSize.label')} - - + + - + - + {t('form.requestTrialForm.fields.country.label')} - - + + - + @@ -187,12 +191,12 @@ const RequestTrialForm = ({ - + {t('form.requestTrialForm.hasWorkspace.label')} - - + + {t('form.requestTrialForm.hasWorkspace.description')} - + diff --git a/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx b/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx index 0c2fe3880f..3556364971 100644 --- a/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx +++ b/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx @@ -4,6 +4,10 @@ import { EmailInput, ButtonGroup, Button, + FieldLabel, + FieldDescription, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; @@ -44,13 +48,13 @@ const ResetPasswordForm = ({ - + {t('form.resetPasswordForm.fields.email.label')} - - + + {t('form.resetPasswordForm.content.subtitle')} - - + + - - {errors.email && {errors.email.message}} + + {errors.email && {errors.email.message}} diff --git a/packages/onboarding-ui/src/forms/TotpForm/TotpForm.tsx b/packages/onboarding-ui/src/forms/TotpForm/TotpForm.tsx index e182ae368b..095c546430 100644 --- a/packages/onboarding-ui/src/forms/TotpForm/TotpForm.tsx +++ b/packages/onboarding-ui/src/forms/TotpForm/TotpForm.tsx @@ -4,6 +4,9 @@ import { NumberInput, TextInput, Button, + FieldLabel, + FieldRow, + FieldError, } from '@rocket.chat/fuselage'; import { ActionLink, Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; @@ -50,15 +53,15 @@ const TotpForm = ({ {isBackupCode ? ( - + {t('form.totpForm.fields.backupCode.label')} - + ) : ( - + {t('form.totpForm.fields.totpCode.label')} - + )} - + {isBackupCode ? ( )} - + {errors.backupCode && ( - {errors.backupCode.message} + {errors.backupCode.message} )} {errors.totpCode && ( - {errors.totpCode.message} + {errors.totpCode.message} )}