-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Rewrite custom OAuth Modals to react (#26204)
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
- Loading branch information
1 parent
9083271
commit 2ad84c3
Showing
3 changed files
with
98 additions
and
55 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
apps/meteor/client/views/admin/settings/groups/CreateOAuthModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { TextInput, Field } from '@rocket.chat/fuselage'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import React, { ReactElement, useState, FormEvent } from 'react'; | ||
|
||
import GenericModal from '../../../../components/GenericModal'; | ||
|
||
type CreateOAuthModalProps = { | ||
onConfirm: (text: string) => Promise<void>; | ||
onClose: () => void; | ||
}; | ||
|
||
const CreateOAuthModal = ({ onConfirm, onClose }: CreateOAuthModalProps): ReactElement => { | ||
const [text, setText] = useState<string>(''); | ||
const [error, setError] = useState<string>(''); | ||
const t = useTranslation(); | ||
|
||
const handleConfirm = (): void => { | ||
if (!text.length) { | ||
setError(t('Name_cant_be_empty')); | ||
return; | ||
} | ||
onConfirm(text); | ||
}; | ||
|
||
return ( | ||
<GenericModal title={t('Add_custom_oauth')} confirmText={t('Add')} onCancel={onClose} onClose={onClose} onConfirm={handleConfirm}> | ||
<Field> | ||
<Field.Label>{t('Give_a_unique_name_for_the_custom_oauth')}</Field.Label> | ||
<Field.Row> | ||
<TextInput | ||
error={error} | ||
placeholder={t('Custom_oauth_unique_name')} | ||
value={text} | ||
onChange={(e: FormEvent<HTMLInputElement>): void => { | ||
setText(e.currentTarget.value); | ||
setError(''); | ||
}} | ||
/> | ||
</Field.Row> | ||
{error && <Field.Error>{error}</Field.Error>} | ||
</Field> | ||
</GenericModal> | ||
); | ||
}; | ||
|
||
export default CreateOAuthModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters