The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/admin/settings/inputs/ActionSettingInput.js

44 lines
1.0 KiB

import { Button, Field } from '@rocket.chat/fuselage';
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import React from 'react';
import toastr from 'toastr';
import { useTranslation } from '../../../providers/TranslationProvider';
import { handleError } from '../../../../../app/utils/client';
export function ActionSettingInput({
_id,
actionText,
value,
disabled,
sectionChanged,
}) {
const t = useTranslation();
const handleClick = async () => {
Meteor.call(value, (err, data) => {
if (err) {
err.details = Object.assign(err.details || {}, {
errorTitle: 'Error',
});
handleError(err);
return;
}
const args = [data.message].concat(data.params);
toastr.success(TAPi18n.__.apply(TAPi18n, args), TAPi18n.__('Success'));
});
};
return <>
<Button
data-qa-setting-id={_id}
children={t(actionText)}
disabled={disabled || sectionChanged}
primary
onClick={handleClick}
/>
{sectionChanged && <Field.Hint>{t('Save_to_enable_this_action')}</Field.Hint>}
</>;
}