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

Regression: Creating Custom status #28292

Merged
merged 2 commits into from Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,6 +1,6 @@
import type { IUserStatus } from '@rocket.chat/core-typings';
import type { SelectOption } from '@rocket.chat/fuselage';
import { Button, ButtonGroup, TextInput, Field, Select, Icon } from '@rocket.chat/fuselage';
import { FieldGroup, Button, ButtonGroup, TextInput, Field, Select, Icon } from '@rocket.chat/fuselage';
import { useSetModal, useRoute, useToastMessageDispatch, useTranslation, useEndpoint } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useCallback } from 'react';
Expand Down Expand Up @@ -87,47 +87,49 @@ const CustomUserStatusForm = ({ onClose, onReload, status }: CustomUserStatusFor

return (
<VerticalBar.ScrollableContent>
<Field is='form' onSubmit={handleSubmit(handleSave)}>
<Field.Label>{t('Name')}</Field.Label>
<Field.Row>
<TextInput {...register('name', { required: true })} placeholder={t('Name')} />
</Field.Row>
{errors?.name && <Field.Error>{t('error-the-field-is-required', { field: t('Name') })}</Field.Error>}
</Field>
<Field>
<Field.Label>{t('Presence')}</Field.Label>
<Field.Row>
<Controller
name='statusType'
control={control}
rules={{ required: true }}
render={({ field }): ReactElement => <Select {...field} placeholder={t('Presence')} options={presenceOptions} />}
/>
</Field.Row>
{errors?.statusType && <Field.Error>{t('error-the-field-is-required', { field: t('Presence') })}</Field.Error>}
</Field>
<Field>
<Field.Row>
<ButtonGroup stretch w='full'>
<Button onClick={onClose}>{t('Cancel')}</Button>
<Button primary type='submit' disabled={!isDirty}>
{t('Save')}
</Button>
</ButtonGroup>
</Field.Row>
</Field>
{_id && (
<FieldGroup is='form' onSubmit={handleSubmit(handleSave)}>
<Field>
<Field.Label>{t('Name')}</Field.Label>
<Field.Row>
<TextInput {...register('name', { required: true })} placeholder={t('Name')} />
</Field.Row>
{errors?.name && <Field.Error>{t('error-the-field-is-required', { field: t('Name') })}</Field.Error>}
</Field>
<Field>
<Field.Label>{t('Presence')}</Field.Label>
<Field.Row>
<Controller
name='statusType'
control={control}
rules={{ required: true }}
render={({ field }): ReactElement => <Select {...field} placeholder={t('Presence')} options={presenceOptions} />}
/>
</Field.Row>
{errors?.statusType && <Field.Error>{t('error-the-field-is-required', { field: t('Presence') })}</Field.Error>}
</Field>
<Field>
<Field.Row>
<ButtonGroup stretch w='full'>
<Button danger onClick={handleDeleteStatus}>
<Icon name='trash' mie='x4' />
{t('Delete')}
<Button onClick={onClose}>{t('Cancel')}</Button>
<Button primary type='submit' disabled={!isDirty}>
{t('Save')}
</Button>
</ButtonGroup>
</Field.Row>
</Field>
)}
{_id && (
<Field>
<Field.Row>
<ButtonGroup stretch w='full'>
<Button danger onClick={handleDeleteStatus}>
<Icon name='trash' mie='x4' />
{t('Delete')}
</Button>
</ButtonGroup>
</Field.Row>
</Field>
)}
</FieldGroup>
</VerticalBar.ScrollableContent>
);
};
Expand Down