Skip to content

Commit

Permalink
chore: Field normalization (#31182)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris authored Dec 13, 2023
1 parent b8e1c81 commit bfbfb8b
Show file tree
Hide file tree
Showing 59 changed files with 1,499 additions and 1,432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,14 @@ const CreateDiscussion = ({ onClose, defaultParentRoom, parentMessageId, nameSug
)}
</Field>
<Field>
<Box display='flex' alignItems='center' flexDirection='row' justifyContent='spaceBetween' flexGrow={1}>
<FieldRow>
<FieldLabel htmlFor={encryptedField}>{t('Encrypted')}</FieldLabel>
<FieldRow>
<Controller
control={control}
name='encrypted'
render={({ field: { value, ...field } }) => <ToggleSwitch id={encryptedField} {...field} checked={value} />}
/>
</FieldRow>
</Box>
<Controller
control={control}
name='encrypted'
render={({ field: { value, ...field } }) => <ToggleSwitch id={encryptedField} {...field} checked={value} />}
/>
</FieldRow>
</Field>
<Field>
<FieldLabel htmlFor={discussionField} required>
Expand Down
206 changes: 103 additions & 103 deletions apps/meteor/client/components/Omnichannel/modals/CloseChatModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,121 +136,121 @@ const CloseChatModal = ({
}
}, [transcriptEmail, setValue, visitorEmail, subject, t]);

return commentRequired || tagRequired || canSendTranscript ? (
<Modal wrapperFunction={(props) => <Box is='form' onSubmit={handleSubmit(onSubmit)} {...props} />}>
<Modal.Header>
<Modal.Icon name='baloon-close-top-right' />
<Modal.Title>{t('Wrap_up_conversation')}</Modal.Title>
<Modal.Close onClick={onCancel} />
</Modal.Header>
<Modal.Content fontScale='p2'>
<Box color='annotation'>{t('Close_room_description')}</Box>
<FieldGroup>
<Field>
<FieldLabel required={commentRequired}>{t('Comment')}</FieldLabel>
<FieldRow>
<TextInput
{...register('comment')}
error={
errors.comment &&
t('error-the-field-is-required', {
field: t('Comment'),
})
}
flexGrow={1}
placeholder={t('Please_add_a_comment')}
/>
</FieldRow>
<FieldError>{errors.comment?.message}</FieldError>
</Field>
<Field>
<Tags tagRequired={tagRequired} tags={tags} handler={handleTags} {...(department && { department: department._id })} />
<FieldError>{errors.tags?.message}</FieldError>
</Field>
{canSendTranscript && (
<>
<Field>
<Divider />
<FieldLabel marginBlockStart={8}>{t('Chat_transcript')}</FieldLabel>
</Field>
{canSendTranscriptPDF && (
<Field marginBlockStart={10}>
<FieldRow>
<CheckBox id='transcript-pdf' {...register('transcriptPDF', { value: userTranscriptPDF })} />
<FieldLabel htmlFor='transcript-pdf' color='default' fontScale='c1'>
{t('Omnichannel_transcript_pdf')}
</FieldLabel>
</FieldRow>
if (commentRequired || tagRequired || canSendTranscript) {
return (
<Modal wrapperFunction={(props) => <Box is='form' onSubmit={handleSubmit(onSubmit)} {...props} />}>
<Modal.Header>
<Modal.Icon name='baloon-close-top-right' />
<Modal.Title>{t('Wrap_up_conversation')}</Modal.Title>
<Modal.Close onClick={onCancel} />
</Modal.Header>
<Modal.Content fontScale='p2'>
<Box color='annotation'>{t('Close_room_description')}</Box>
<FieldGroup>
<Field>
<FieldLabel required={commentRequired}>{t('Comment')}</FieldLabel>
<FieldRow>
<TextInput
{...register('comment')}
error={
errors.comment &&
t('error-the-field-is-required', {
field: t('Comment'),
})
}
flexGrow={1}
placeholder={t('Please_add_a_comment')}
/>
</FieldRow>
<FieldError>{errors.comment?.message}</FieldError>
</Field>
<Field>
<Tags tagRequired={tagRequired} tags={tags} handler={handleTags} {...(department && { department: department._id })} />
<FieldError>{errors.tags?.message}</FieldError>
</Field>
{canSendTranscript && (
<>
<Field>
<Divider />
<FieldLabel marginBlockStart={8}>{t('Chat_transcript')}</FieldLabel>
</Field>
)}
{canSendTranscriptEmail && (
<>
{canSendTranscriptPDF && (
<Field marginBlockStart={10}>
<FieldRow>
<CheckBox id='transcript-email' {...register('transcriptEmail', { value: userTranscriptEmail })} />
<FieldLabel htmlFor='transcript-email' color='default' fontScale='c1'>
{t('Omnichannel_transcript_email')}
</FieldLabel>
<FieldLabel htmlFor='transcript-pdf'>{t('Omnichannel_transcript_pdf')}</FieldLabel>
<CheckBox id='transcript-pdf' {...register('transcriptPDF', { value: userTranscriptPDF })} />
</FieldRow>
</Field>
{transcriptEmail && (
<>
<Field marginBlockStart={14}>
<FieldLabel required>{t('Contact_email')}</FieldLabel>
<FieldRow>
<EmailInput value={visitorEmail} required disabled flexGrow={1} />
</FieldRow>
</Field>
<Field marginBlockStart={12}>
<FieldLabel required>{t('Subject')}</FieldLabel>
<FieldRow>
<TextInput
{...register('subject', { required: true })}
className='active'
error={
errors.subject &&
t('error-the-field-is-required', {
field: t('Subject'),
})
}
flexGrow={1}
/>
</FieldRow>
<FieldError>{errors.subject?.message}</FieldError>
</Field>
</>
)}
</>
)}
<Field marginBlockStart={16}>
<FieldLabel color='annotation' fontScale='c1'>
{canSendTranscriptPDF && canSendTranscriptEmail
? t('These_options_affect_this_conversation_only_To_set_default_selections_go_to_My_Account_Omnichannel')
: t('This_option_affect_this_conversation_only_To_set_default_selection_go_to_My_Account_Omnichannel')}
</FieldLabel>
</Field>
</>
)}
</FieldGroup>
</Modal.Content>
<Modal.Footer>
<Modal.FooterControllers>
<Button onClick={onCancel}>{t('Cancel')}</Button>
<Button type='submit' disabled={cannotSubmit} primary>
{t('Confirm')}
</Button>
</Modal.FooterControllers>
</Modal.Footer>
</Modal>
) : (
)}
{canSendTranscriptEmail && (
<>
<Field marginBlockStart={10}>
<FieldRow>
<FieldLabel htmlFor='transcript-email'>{t('Omnichannel_transcript_email')}</FieldLabel>
<CheckBox id='transcript-email' {...register('transcriptEmail', { value: userTranscriptEmail })} />
</FieldRow>
</Field>
{transcriptEmail && (
<>
<Field marginBlockStart={14}>
<FieldLabel required>{t('Contact_email')}</FieldLabel>
<FieldRow>
<EmailInput value={visitorEmail} required disabled flexGrow={1} />
</FieldRow>
</Field>
<Field marginBlockStart={12}>
<FieldLabel required>{t('Subject')}</FieldLabel>
<FieldRow>
<TextInput
{...register('subject', { required: true })}
className='active'
error={
errors.subject &&
t('error-the-field-is-required', {
field: t('Subject'),
})
}
flexGrow={1}
/>
</FieldRow>
<FieldError>{errors.subject?.message}</FieldError>
</Field>
</>
)}
</>
)}
<Field marginBlockStart={16}>
<FieldLabel color='annotation' fontScale='c1'>
{canSendTranscriptPDF && canSendTranscriptEmail
? t('These_options_affect_this_conversation_only_To_set_default_selections_go_to_My_Account_Omnichannel')
: t('This_option_affect_this_conversation_only_To_set_default_selection_go_to_My_Account_Omnichannel')}
</FieldLabel>
</Field>
</>
)}
</FieldGroup>
</Modal.Content>
<Modal.Footer>
<Modal.FooterControllers>
<Button onClick={onCancel}>{t('Cancel')}</Button>
<Button type='submit' disabled={cannotSubmit} primary>
{t('Confirm')}
</Button>
</Modal.FooterControllers>
</Modal.Footer>
</Modal>
);
}

return (
<GenericModal
variant='warning'
title={t('Are_you_sure_you_want_to_close_this_chat')}
onConfirm={(): Promise<void> => onConfirm()}
onCancel={onCancel}
onClose={onCancel}
confirmText={t('Confirm')}
></GenericModal>
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,8 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
<FieldHint id={`${topicId}-hint`}>{t('Channel_what_is_this_channel_about')}</FieldHint>
</Field>
<Field>
<Box display='flex' justifyContent='space-between' alignItems='start'>
<Box display='flex' flexDirection='column' width='full'>
<FieldLabel htmlFor={privateId}>{t('Private')}</FieldLabel>
<FieldHint id={`${privateId}-hint`}>
{isPrivate ? t('Only_invited_users_can_acess_this_channel') : t('Everyone_can_access_this_channel')}
</FieldHint>
</Box>
<FieldRow>
<FieldLabel htmlFor={privateId}>{t('Private')}</FieldLabel>
<Controller
control={control}
name='isPrivate'
Expand All @@ -261,14 +256,14 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
/>
)}
/>
</Box>
</FieldRow>
<FieldHint id={`${privateId}-hint`}>
{isPrivate ? t('Only_invited_users_can_acess_this_channel') : t('Everyone_can_access_this_channel')}
</FieldHint>
</Field>
<Field>
<Box display='flex' justifyContent='space-between' alignItems='start'>
<Box display='flex' flexDirection='column' width='full'>
<FieldLabel htmlFor={federatedId}>{t('Federation_Matrix_Federated')}</FieldLabel>
<FieldHint id={`${federatedId}-hint`}>{t(getFederationHintKey(federatedModule, federationEnabled))}</FieldHint>
</Box>
<FieldRow>
<FieldLabel htmlFor={federatedId}>{t('Federation_Matrix_Federated')}</FieldLabel>
<Controller
control={control}
name='federated'
Expand All @@ -283,16 +278,12 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
/>
)}
/>
</Box>
</FieldRow>
<FieldHint id={`${federatedId}-hint`}>{t(getFederationHintKey(federatedModule, federationEnabled))}</FieldHint>
</Field>
<Field>
<Box display='flex' justifyContent='space-between' alignItems='start'>
<Box display='flex' flexDirection='column' width='full'>
<FieldLabel htmlFor={readOnlyId}>{t('Read_only')}</FieldLabel>
<FieldHint id={`${readOnlyId}-hint`}>
{readOnly ? t('Only_authorized_users_can_write_new_messages') : t('All_users_in_the_channel_can_write_new_messages')}
</FieldHint>
</Box>
<FieldRow>
<FieldLabel htmlFor={readOnlyId}>{t('Read_only')}</FieldLabel>
<Controller
control={control}
name='readOnly'
Expand All @@ -307,16 +298,14 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
/>
)}
/>
</Box>
</FieldRow>
<FieldHint id={`${readOnlyId}-hint`}>
{readOnly ? t('Only_authorized_users_can_write_new_messages') : t('All_users_in_the_channel_can_write_new_messages')}
</FieldHint>
</Field>
<Field>
<Box display='flex' justifyContent='space-between' alignItems='start'>
<Box display='flex' flexDirection='column' width='full'>
<FieldLabel htmlFor={encryptedId}>{t('Encrypted')}</FieldLabel>
<FieldDescription id={`${encryptedId}-hint`}>
{isPrivate ? t('Encrypted_channel_Description') : t('Encrypted_not_available')}
</FieldDescription>
</Box>
<FieldRow>
<FieldLabel htmlFor={encryptedId}>{t('Encrypted')}</FieldLabel>
<Controller
control={control}
name='encrypted'
Expand All @@ -332,14 +321,14 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
/>
)}
/>
</Box>
</FieldRow>
<FieldDescription id={`${encryptedId}-hint`}>
{isPrivate ? t('Encrypted_channel_Description') : t('Encrypted_not_available')}
</FieldDescription>
</Field>
<Field>
<Box display='flex' justifyContent='space-between' alignItems='start'>
<Box display='flex' flexDirection='column' width='full'>
<FieldLabel htmlFor={broadcastId}>{t('Broadcast')}</FieldLabel>
<FieldHint id={`${broadcastId}-hint`}>{t('Broadcast_channel_Description')}</FieldHint>
</Box>
<FieldRow>
<FieldLabel htmlFor={broadcastId}>{t('Broadcast')}</FieldLabel>
<Controller
control={control}
name='broadcast'
Expand All @@ -354,7 +343,8 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
/>
)}
/>
</Box>
</FieldRow>
<FieldHint id={`${broadcastId}-hint`}>{t('Broadcast_channel_Description')}</FieldHint>
</Field>
<Field>
<FieldLabel htmlFor={addMembersId}>{t('Add_members')}</FieldLabel>
Expand Down
Loading

0 comments on commit bfbfb8b

Please sign in to comment.