From cd8796bf0b22239db286464a4282b515ca535af2 Mon Sep 17 00:00:00 2001 From: Zubair Imtiaz <106450046+ZubairImtiaz3@users.noreply.github.com> Date: Mon, 18 Dec 2023 05:26:57 +0500 Subject: [PATCH] [MM-56011] Migrated radio_setting.tsx from Class to Functional Component #25603 (#25668) * Added cancel button in the delete category modal * fix lint error * fix eslint issues * migrated from class to functional component * updateCode * used react.memo * updateSnapshots --------- Co-authored-by: Mattermost Build --- .../message_export_settings.test.jsx.snap | 4 +- .../schema_admin_settings.test.jsx.snap | 2 +- .../custom_plugin_settings.test.tsx.snap | 4 +- .../admin_console/radio_setting.tsx | 82 ++++++++++--------- 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.jsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.jsx.snap index ab26dc6f56..0e30831f84 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.jsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.jsx.snap @@ -288,7 +288,7 @@ exports[`components/MessageExportSettings should match snapshot, disabled, globa - - - - - { - public static defaultProps: Partial = { - disabled: false, +const RadioSetting = ({ + id, + label, + values, + value, + setByEnv, + disabled = false, + helpText, + onChange, +}: Props) => { + const handleChange = (e: React.ChangeEvent) => { + onChange(id, e.target.value); }; - private handleChange = (e: React.ChangeEvent) => { - this.props.onChange(this.props.id, e.target.value); - }; + const options = values.map(({value: optionValue, text}) => ( +
+ +
+ )); - render(): JSX.Element { - const options = []; - for (const {value, text} of this.props.values) { - options.push( -
- -
, - ); - } + return ( + + {options} + + ); +}; - return ( - - {options} - - ); - } -} +export default React.memo(RadioSetting);