diff --git a/client/components/admin/settings/Field.js b/client/components/admin/settings/Field.js
deleted file mode 100644
index c6042406831..00000000000
--- a/client/components/admin/settings/Field.js
+++ /dev/null
@@ -1,104 +0,0 @@
-import React from 'react';
-
-import { Button } from '../../basic/Button';
-import { Icon } from '../../basic/Icon';
-import { MarkdownText } from '../../basic/MarkdownText';
-import { RawText } from '../../basic/RawText';
-import { useTranslation } from '../../providers/TranslationProvider';
-import { useFieldActions } from './EditingState';
-
-
-function GenericSettingInput({ _id, value, placeholder, readonly, autocomplete, disabled, onChange }) {
- const handleChange = (event) => {
- const { value } = event.currentTarget;
- onChange({ value });
- };
-
- return ;
-}
-
-function BooleanSettingInput({ _id, disabled, readonly, autocomplete, value, onChange }) {
- const t = useTranslation();
-
- const handleChange = (event) => {
- const value = event.currentTarget.value === '1';
- onChange({ value });
- };
-
- return <>
-
-
- >;
-}
-
-export function Field({ field }) {
- const t = useTranslation();
- const { update, reset, disabled } = useFieldActions(field);
-
- const inputProps = { ...field, disabled, onChange: update };
-
- const {
- _id,
- disableReset,
- readonly,
- type,
- value,
- packageValue,
- blocked,
- changed,
- i18nLabel,
- i18nDescription,
- alert,
- } = field;
-
- const hasResetButton = !disableReset && !readonly && type !== 'asset' && value !== packageValue && !blocked;
- const onResetButtonClick = () => {
- reset();
- };
-
- return
-
-
- {(type === 'boolean' &&
)
- ||
}
- {/* {setting.type === 'string' &&
} */}
- {/* {setting.type === 'relativeUrl' &&
} */}
- {/* {setting.type === 'password' &&
} */}
- {/* {setting.type === 'int' &&
} */}
- {/* {setting.type === 'select' &&
} */}
- {/* {setting.type === 'language' &&
} */}
- {/* {setting.type === 'color' &&
} */}
- {/* {setting.type === 'font' &&
} */}
- {/* {setting.type === 'code' &&
} */}
- {/* {setting.type === 'action' &&
} */}
- {/* {setting.type === 'asset' &&
} */}
- {/* {setting.type === 'roomPick' &&
} */}
-
- {t.has(i18nDescription) &&
- {t(i18nDescription)}
-
}
-
- {alert &&
-
- {t(alert)}
-
}
-
-
- {hasResetButton &&
}
- className='reset-setting'
- data-setting={_id}
- cancel
- onClick={onResetButtonClick}
- />}
-
;
-}
diff --git a/client/components/admin/settings/ResetSettingButton.js b/client/components/admin/settings/ResetSettingButton.js
new file mode 100644
index 00000000000..bc9ca48d70e
--- /dev/null
+++ b/client/components/admin/settings/ResetSettingButton.js
@@ -0,0 +1,18 @@
+import { Text } from '@rocket.chat/fuselage';
+import React from 'react';
+
+import { Icon } from '../../basic/Icon';
+import { useTranslation } from '../../providers/TranslationProvider';
+
+export function ResetSettingButton({ onClick }) {
+ const t = useTranslation();
+
+ return
+
+ ;
+}
diff --git a/client/components/admin/settings/Section.js b/client/components/admin/settings/Section.js
index 53366647957..9016ce101e0 100644
--- a/client/components/admin/settings/Section.js
+++ b/client/components/admin/settings/Section.js
@@ -1,9 +1,14 @@
-import { Accordion, Button, Paragraph } from '@rocket.chat/fuselage';
+import { Accordion, Button, FieldGroup, Paragraph } from '@rocket.chat/fuselage';
import React from 'react';
+import styled from 'styled-components';
import { useTranslation } from '../../providers/TranslationProvider';
import { useBulkActions } from './EditingState';
-import { Field } from './Field';
+import { SettingField } from './SettingField';
+
+const Wrapper = styled.div`
+ max-width: 543px;
+`;
export function Section({ children, hasReset = true, help, section, solo }) {
const t = useTranslation();
@@ -14,21 +19,23 @@ export function Section({ children, hasReset = true, help, section, solo }) {
};
return
- {help && {help}}
-
-
- {section.fields.map((field) => )}
-
- {hasReset && }
-
- {children}
-
+
+ {help && {help}}
+
+
+ {section.fields.map((field) => )}
+
+ {hasReset && section.changed && }
+
+ {children}
+
+
;
}
diff --git a/client/components/admin/settings/SettingField.js b/client/components/admin/settings/SettingField.js
new file mode 100644
index 00000000000..5722611d012
--- /dev/null
+++ b/client/components/admin/settings/SettingField.js
@@ -0,0 +1,68 @@
+import {
+ Callout,
+ Field,
+} from '@rocket.chat/fuselage';
+import React from 'react';
+
+import { MarkdownText } from '../../basic/MarkdownText';
+import { RawText } from '../../basic/RawText';
+import { useTranslation } from '../../providers/TranslationProvider';
+import { useFieldActions } from './EditingState';
+import { GenericSettingInput } from './inputs/GenericSettingInput';
+import { BooleanSettingInput } from './inputs/BooleanSettingInput';
+import { StringSettingInput } from './inputs/StringSettingInput';
+
+export function SettingField({ field }) {
+ const t = useTranslation();
+ const { update, reset, disabled } = useFieldActions(field);
+
+ const {
+ _id,
+ disableReset,
+ readonly,
+ type,
+ value,
+ packageValue,
+ blocked,
+ i18nLabel,
+ i18nDescription,
+ alert,
+ } = field;
+
+ const label = (i18nLabel && t(i18nLabel)) || (_id || t(_id));
+ const hint = t.has(i18nDescription) && {t(i18nDescription)};
+ const callout = alert && {t(alert)};
+
+ const hasResetButton = !disableReset && !readonly && type !== 'asset' && value !== packageValue && !blocked;
+ const onResetButtonClick = () => {
+ reset();
+ };
+
+ const inputProps = {
+ ...field,
+ label,
+ disabled,
+ onChange: update,
+ hasResetButton,
+ onResetButtonClick,
+ };
+
+ return
+ {(type === 'boolean' && )
+ || (type === 'string' && )
+ // || (type === 'relativeUrl' && )
+ // || (type === 'password' && )
+ // || (type === 'int' && )
+ // || (type === 'select' && )
+ // || (type === 'language' && )
+ // || (type === 'color' && )
+ // || (type === 'font' && )
+ // || (type === 'code' && )
+ // || (type === 'action' && )
+ // || (type === 'asset' && )
+ // || (type === 'roomPick' && )
+ || }
+ {hint && {hint}}
+ {callout && }
+ ;
+}
diff --git a/client/components/admin/settings/inputs.js b/client/components/admin/settings/inputs.js
index 9f5dfaa0ca2..445f3201ed1 100644
--- a/client/components/admin/settings/inputs.js
+++ b/client/components/admin/settings/inputs.js
@@ -10,20 +10,19 @@ import { useReactiveValue } from '../../../hooks/useReactiveValue';
import { Button } from '../../basic/Button';
import { handleError } from '../../../../app/utils/client';
-export function StringSettingInput({ setting, onUpdate }) {
- const {
- _id,
- multiline,
- value,
- placeholder,
- readonly,
- autocomplete,
- disabled,
- } = setting;
-
+export function StringSettingInput({
+ _id,
+ multiline,
+ value,
+ placeholder,
+ readonly,
+ autocomplete,
+ disabled,
+ onChange,
+}) {
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
if (multiline) {
@@ -53,74 +52,70 @@ export function StringSettingInput({ setting, onUpdate }) {
/>;
}
-export function RelativeUrlSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- placeholder,
- readonly,
- autocomplete,
- disabled,
- } = setting;
-
+export function RelativeUrlSettingInput({
+ _id,
+ value,
+ placeholder,
+ readonly,
+ autocomplete,
+ disabled,
+ onChange,
+}) {
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
return ;
}
-export function PasswordSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- placeholder,
- readonly,
- autocomplete,
- disabled,
- } = setting;
-
+export function PasswordSettingInput({
+ _id,
+ value,
+ placeholder,
+ readonly,
+ autocomplete,
+ disabled,
+ onChange,
+}) {
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
return ;
}
-export function IntSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- placeholder,
- readonly,
- autocomplete,
- disabled,
- } = setting;
-
+export function IntSettingInput({
+ _id,
+ value,
+ placeholder,
+ readonly,
+ autocomplete,
+ disabled,
+ onChange,
+}) {
const handleChange = (event) => {
const value = parseInt(event.currentTarget.value, 10);
- onUpdate({ value });
+ onChange({ value });
};
return ;
}
-export function SelectSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- readonly,
- values,
- disabled,
- } = setting;
-
+export function SelectSettingInput({
+ _id,
+ value,
+ readonly,
+ values,
+ disabled,
+ onChange,
+}) {
const t = useTranslation();
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
return
@@ -133,14 +128,13 @@ export function SelectSettingInput({ setting, onUpdate }) {
;
}
-export function LanguageSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- readonly,
- disabled,
- } = setting;
-
+export function LanguageSettingInput({
+ _id,
+ value,
+ readonly,
+ disabled,
+ onChange,
+}) {
const languages = useReactiveValue(() => {
const languages = TAPi18n.getLanguages();
@@ -159,7 +153,7 @@ export function LanguageSettingInput({ setting, onUpdate }) {
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
return
@@ -172,26 +166,25 @@ export function LanguageSettingInput({ setting, onUpdate }) {
;
}
-export function ColorSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- editor,
- allowedTypes,
- autocomplete,
- disabled,
- } = setting;
-
+export function ColorSettingInput({
+ _id,
+ value,
+ editor,
+ allowedTypes,
+ autocomplete,
+ disabled,
+ onChange,
+}) {
const t = useTranslation();
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
const handleEditorTypeChange = (event) => {
const editor = event.currentTarget.value.trim();
- onUpdate({ editor });
+ onChange({ editor });
};
return <>
@@ -214,31 +207,28 @@ export function ColorSettingInput({ setting, onUpdate }) {
>;
}
-export function FontSettingInput({ setting, onUpdate }) {
- const {
- _id,
- value,
- placeholder,
- readonly,
- autocomplete,
- disabled,
- } = setting;
-
+export function FontSettingInput({
+ _id,
+ value,
+ placeholder,
+ readonly,
+ autocomplete,
+ disabled,
+ onChange,
+}) {
const handleChange = (event) => {
const { value } = event.currentTarget;
- onUpdate({ value });
+ onChange({ value });
};
return ;
}
-export function CodeSettingInput({ setting }) {
- const {
- _id,
- i18nLabel,
- disabled,
- } = setting;
-
+export function CodeSettingInput({
+ _id,
+ i18nLabel,
+ disabled,
+}) {
const t = useTranslation();
return disabled
@@ -254,13 +244,12 @@ export function CodeSettingInput({ setting }) {
;
}
-export function ActionSettingInput({ setting, didSectionChange }) {
- const {
- value,
- actionText,
- disabled,
- } = setting;
-
+export function ActionSettingInput({
+ value,
+ actionText,
+ disabled,
+ didSectionChange,
+}) {
const t = useTranslation();
const handleClick = async () => {
@@ -283,12 +272,10 @@ export function ActionSettingInput({ setting, didSectionChange }) {
: ;
}
-export function AssetSettingInput({ setting }) {
- const {
- value,
- fileConstraints,
- } = setting;
-
+export function AssetSettingInput({
+ value,
+ fileConstraints,
+}) {
const t = useTranslation();
return value.url
?
@@ -309,11 +296,7 @@ export function AssetSettingInput({ setting }) {
;
}
-export function RoomPickSettingInput({ setting }) {
- const {
- _id,
- } = setting;
-
+export function RoomPickSettingInput({ _id }) {
// const collection = usePrivateSettingsCollection();
const [selectedRooms] = useState({});
diff --git a/client/components/admin/settings/inputs/BooleanSettingInput.js b/client/components/admin/settings/inputs/BooleanSettingInput.js
new file mode 100644
index 00000000000..14e6d906205
--- /dev/null
+++ b/client/components/admin/settings/inputs/BooleanSettingInput.js
@@ -0,0 +1,39 @@
+import {
+ Field,
+ Label,
+ ToggleSwitch,
+} from '@rocket.chat/fuselage';
+import React from 'react';
+
+import { ResetSettingButton } from '../ResetSettingButton';
+
+export function BooleanSettingInput({
+ _id,
+ label,
+ disabled,
+ readonly,
+ autocomplete,
+ value,
+ onChange,
+ hasResetButton,
+ onResetButtonClick,
+}) {
+ const handleChange = (event) => {
+ const value = event.currentTarget.checked;
+ onChange({ value });
+ };
+
+ return
+
+ {hasResetButton && }
+ ;
+}
diff --git a/client/components/admin/settings/inputs/GenericSettingInput.js b/client/components/admin/settings/inputs/GenericSettingInput.js
new file mode 100644
index 00000000000..2aefb25f01b
--- /dev/null
+++ b/client/components/admin/settings/inputs/GenericSettingInput.js
@@ -0,0 +1,42 @@
+import {
+ Field,
+ Label,
+ TextInput,
+} from '@rocket.chat/fuselage';
+import React from 'react';
+
+import { ResetSettingButton } from '../ResetSettingButton';
+
+export function GenericSettingInput({
+ _id,
+ label,
+ value,
+ placeholder,
+ readonly,
+ autocomplete,
+ disabled,
+ onChange,
+ hasResetButton,
+ onResetButtonClick,
+}) {
+ const handleChange = (event) => {
+ const { value } = event.currentTarget;
+ onChange({ value });
+ };
+
+ return <>
+
+
+ {hasResetButton && }
+
+
+ >;
+}
diff --git a/client/components/admin/settings/inputs/StringSettingInput.js b/client/components/admin/settings/inputs/StringSettingInput.js
new file mode 100644
index 00000000000..37abe1c836b
--- /dev/null
+++ b/client/components/admin/settings/inputs/StringSettingInput.js
@@ -0,0 +1,55 @@
+import {
+ Field,
+ Label,
+ TextAreaInput,
+ TextInput,
+} from '@rocket.chat/fuselage';
+import React from 'react';
+
+import { ResetSettingButton } from '../ResetSettingButton';
+
+export function StringSettingInput({
+ _id,
+ label,
+ disabled,
+ multiline,
+ placeholder,
+ readonly,
+ autocomplete,
+ value,
+ onChange,
+ hasResetButton,
+ onResetButtonClick,
+}) {
+ const handleChange = (event) => {
+ const { value } = event.currentTarget;
+ onChange({ value });
+ };
+
+ return <>
+
+
+ {hasResetButton && }
+
+ {multiline
+ ?
+ : }
+ >;
+}
diff --git a/package-lock.json b/package-lock.json
index ed631a8abda..c4c051273a7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2370,19 +2370,19 @@
}
},
"@rocket.chat/fuselage": {
- "version": "0.2.0-alpha.13",
- "resolved": "https://registry.npmjs.org/@rocket.chat/fuselage/-/fuselage-0.2.0-alpha.13.tgz",
- "integrity": "sha512-sWdUNfUBwCUetNPGPP1k2BJdLYvypfwQ+k3aiapHz+MFw4ugtTgwHG7ulW5ygbGrijGHv6pDE6+U68FcCxzZOg==",
+ "version": "0.2.0-dev.46",
+ "resolved": "https://registry.npmjs.org/@rocket.chat/fuselage/-/fuselage-0.2.0-dev.46.tgz",
+ "integrity": "sha512-XxIG+hRUuEi9iL4yKfpXHpDrgiB+hrJ00faErDjgjF59YVjXo+pODVcqNJTl4UpOvdLitRpqAPm17ZIppV+msA==",
"requires": {
- "@rocket.chat/fuselage-tokens": "^0.2.0-alpha.13",
- "@rocket.chat/icons": "^0.2.0-alpha.13",
+ "@rocket.chat/fuselage-tokens": "^0.2.0-dev.46+56baa80",
+ "@rocket.chat/icons": "^0.2.0-dev.46+56baa80",
"invariant": "^2.2.4"
},
"dependencies": {
"@rocket.chat/icons": {
- "version": "0.2.0-alpha.13",
- "resolved": "https://registry.npmjs.org/@rocket.chat/icons/-/icons-0.2.0-alpha.13.tgz",
- "integrity": "sha512-woGEqtzyU/j+IQLgg7Cj6N7phTifUyC3TAbFdU/3XhzChRDbC7kxx8QjHAQgsLpri9JZWtm24YLEYJNpdGFQ4Q=="
+ "version": "0.2.0-dev.46",
+ "resolved": "https://registry.npmjs.org/@rocket.chat/icons/-/icons-0.2.0-dev.46.tgz",
+ "integrity": "sha512-a04ggaeXxDErOWN1j61A9lRM0tE2yg5P/TBr0QAHQle07H/1g9ZNZlHWV/BLEnUimDmts/yvHo5l1ofSyVnsEQ=="
}
}
},
@@ -2392,9 +2392,9 @@
"integrity": "sha512-LdLpDVkNhKRxXzNrtMy+Lqyo34+BVeBFYf93gLTSCSauNwtLouNiOQXJphHz2CZKsE+FJ3M1FeXUTEJ2QOZpzg=="
},
"@rocket.chat/fuselage-tokens": {
- "version": "0.2.0-alpha.13",
- "resolved": "https://registry.npmjs.org/@rocket.chat/fuselage-tokens/-/fuselage-tokens-0.2.0-alpha.13.tgz",
- "integrity": "sha512-0Vagl3+i6aR5FA7uqCsf5am+M+cB4EMCZGs+Lcw5PAfKl7We3TjpZBUIpAJbNsiG/OsmRSSpL0SiaSfuPF7/Bw=="
+ "version": "0.2.0-dev.46",
+ "resolved": "https://registry.npmjs.org/@rocket.chat/fuselage-tokens/-/fuselage-tokens-0.2.0-dev.46.tgz",
+ "integrity": "sha512-lh4L/Ju5RCW+LzIdQwAFeKd5eKzsiZyOLFJYx8WuA7No50/7eJO4Kcz+OJPHG+PvuVFdTbF557QhWH1ZvuazHQ=="
},
"@rocket.chat/icons": {
"version": "0.2.0-alpha.9",
diff --git a/package.json b/package.json
index fbe32d6b2fd..63b7454611d 100644
--- a/package.json
+++ b/package.json
@@ -151,7 +151,7 @@
"@google-cloud/storage": "^2.3.1",
"@google-cloud/vision": "^0.23.0",
"@rocket.chat/apps-engine": "^1.7.0",
- "@rocket.chat/fuselage": "^0.2.0-alpha.13",
+ "@rocket.chat/fuselage": "^0.2.0-dev.46",
"@rocket.chat/fuselage-hooks": "^0.2.0-dev.32",
"@rocket.chat/icons": "^0.2.0-alpha.9",
"@slack/client": "^4.8.0",