-
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: Convert apps/meteor/client/views/admin/settings/inputs folder (#…
- Loading branch information
1 parent
75c7f4d
commit 99a3651
Showing
24 changed files
with
389 additions
and
155 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
apps/meteor/client/views/admin/settings/inputs/ActionSettingInput.js
This file was deleted.
Oops, something went wrong.
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
42 changes: 42 additions & 0 deletions
42
apps/meteor/client/views/admin/settings/inputs/ActionSettingInput.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,42 @@ | ||
import { Button, Field } from '@rocket.chat/fuselage'; | ||
import { useMethod, ServerMethods, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts'; | ||
import React, { ReactElement } from 'react'; | ||
|
||
import type keys from '../../../../../packages/rocketchat-i18n/i18n/en.i18n.json'; | ||
|
||
type ActionSettingInputProps = { | ||
_id: string; | ||
actionText: keyof typeof keys; | ||
value: keyof ServerMethods; | ||
disabled: boolean; | ||
sectionChanged: boolean; | ||
}; | ||
function ActionSettingInput({ _id, actionText, value, disabled, sectionChanged }: ActionSettingInputProps): ReactElement { | ||
const t = useTranslation(); | ||
|
||
const dispatchToastMessage = useToastMessageDispatch(); | ||
const actionMethod = useMethod(value); | ||
|
||
const handleClick = async (): Promise<void> => { | ||
try { | ||
const data: { message: keyof typeof keys; params: string[] } = await actionMethod(); | ||
|
||
dispatchToastMessage({ type: 'success', message: t(data.message, ...data.params) }); | ||
} catch (error) { | ||
dispatchToastMessage({ type: 'error', message: String(error) }); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Field.Row> | ||
<Button data-qa-setting-id={_id} disabled={disabled || sectionChanged} primary onClick={handleClick}> | ||
{t(actionText)} | ||
</Button> | ||
</Field.Row> | ||
{sectionChanged && <Field.Hint>{t('Save_to_enable_this_action')}</Field.Hint>} | ||
</> | ||
); | ||
} | ||
|
||
export default ActionSettingInput; |
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
27 changes: 23 additions & 4 deletions
27
...in/settings/inputs/BooleanSettingInput.js → ...n/settings/inputs/BooleanSettingInput.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
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
Oops, something went wrong.