From 6ba3ac4a025551a908fe59d06b9567f4731df5ac Mon Sep 17 00:00:00 2001 From: Syed Ali Abbas Zaidi <88369802+Syed-Ali-Abbas-Zaidi@users.noreply.github.com> Date: Tue, 5 Mar 2024 00:44:05 +0500 Subject: [PATCH] [MM-56848] Convert `./components/admin_console/settings_group.tsx` from Class Component to Function Component (#26258) Co-authored-by: Mattermost Build --- .../bleve_settings.test.tsx.snap | 8 +- .../cluster_settings.test.tsx.snap | 16 ++-- .../database_settings.test.tsx.snap | 4 +- .../elasticsearch_settings.test.tsx.snap | 8 +- .../message_export_settings.test.tsx.snap | 24 ++--- .../__snapshots__/push_settings.test.tsx.snap | 8 +- .../schema_admin_settings.test.tsx.snap | 4 +- .../custom_plugin_settings.test.tsx.snap | 8 +- .../plugin_management.test.tsx.snap | 60 ++++++------ .../admin_console/settings_group.tsx | 94 +++++++++---------- 10 files changed, 117 insertions(+), 117 deletions(-) diff --git a/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap index d6e3f18d96..b98aebf1c3 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/bleve_settings.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/BleveSettings should match snapshot, disabled 1`] = ` id="admin.bleve.title" /> - + - +
@@ -266,7 +266,7 @@ exports[`components/BleveSettings should match snapshot, enabled 1`] = ` id="admin.bleve.title" /> - + - +
diff --git a/webapp/channels/src/components/admin_console/__snapshots__/cluster_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/cluster_settings.test.tsx.snap index f66fa9c552..75c3e7ae53 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/cluster_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/cluster_settings.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/ClusterSettings should match snapshot, compression disabled id="admin.advance.cluster" /> - +
- +
@@ -308,7 +308,7 @@ exports[`components/ClusterSettings should match snapshot, compression enabled 1 id="admin.advance.cluster" /> - +
- +
@@ -601,7 +601,7 @@ exports[`components/ClusterSettings should match snapshot, encryption disabled 1 id="admin.advance.cluster" /> - +
- +
@@ -894,7 +894,7 @@ exports[`components/ClusterSettings should match snapshot, encryption enabled 1` id="admin.advance.cluster" /> - +
- +
diff --git a/webapp/channels/src/components/admin_console/__snapshots__/database_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/database_settings.test.tsx.snap index 1ae6bd6c3f..2aaf26305a 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/database_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/database_settings.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/DatabaseSettings should match snapshot 1`] = ` id="admin.database.title" /> - +
@@ -422,7 +422,7 @@ exports[`components/DatabaseSettings should match snapshot 1`] = `
-
+
diff --git a/webapp/channels/src/components/admin_console/__snapshots__/elasticsearch_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/elasticsearch_settings.test.tsx.snap index d4739229ba..902e46f466 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/elasticsearch_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/elasticsearch_settings.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/ElasticSearchSettings should match snapshot, disabled 1`] = id="admin.elasticsearch.title" /> - + - +
@@ -521,7 +521,7 @@ exports[`components/ElasticSearchSettings should match snapshot, enabled 1`] = ` id="admin.elasticsearch.title" /> - + - +
diff --git a/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.tsx.snap index 4a2f063ca4..b0d486303b 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/message_export_settings.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/MessageExportSettings should match snapshot, disabled, actia id="admin.complianceExport.title" /> - + - +
@@ -195,7 +195,7 @@ exports[`components/MessageExportSettings should match snapshot, disabled, globa id="admin.complianceExport.title" /> - + - - + - +
@@ -489,7 +489,7 @@ exports[`components/MessageExportSettings should match snapshot, enabled, actian id="admin.complianceExport.title" /> - + - +
@@ -669,7 +669,7 @@ exports[`components/MessageExportSettings should match snapshot, enabled, global id="admin.complianceExport.title" /> - + - - + - +
diff --git a/webapp/channels/src/components/admin_console/__snapshots__/push_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/push_settings.test.tsx.snap index 96976b7e49..6c6d55464d 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/push_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/push_settings.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/PushSettings should match snapshot, licensed 1`] = ` id="admin.environment.pushNotificationServer" /> - + - +
@@ -215,7 +215,7 @@ exports[`components/PushSettings should match snapshot, unlicensed 1`] = ` id="admin.environment.pushNotificationServer" /> - + - +
diff --git a/webapp/channels/src/components/admin_console/__snapshots__/schema_admin_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/schema_admin_settings.test.tsx.snap index a8911434e4..b22a9ba75a 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/schema_admin_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/schema_admin_settings.test.tsx.snap @@ -106,7 +106,7 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with onSubmit={[Function]} role="form" > - - +
diff --git a/webapp/channels/src/components/admin_console/custom_plugin_settings/__snapshots__/custom_plugin_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/custom_plugin_settings/__snapshots__/custom_plugin_settings.test.tsx.snap index 94d7163855..0dfc585892 100644 --- a/webapp/channels/src/components/admin_console/custom_plugin_settings/__snapshots__/custom_plugin_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/custom_plugin_settings/__snapshots__/custom_plugin_settings.test.tsx.snap @@ -18,7 +18,7 @@ exports[`components/admin_console/CustomPluginSettings should match snapshot wit onSubmit={[Function]} role="form" > -
-
+
@@ -318,7 +318,7 @@ exports[`components/admin_console/CustomPluginSettings should match snapshot wit onSubmit={[Function]} role="form" > -
-
+
diff --git a/webapp/channels/src/components/admin_console/plugin_management/__snapshots__/plugin_management.test.tsx.snap b/webapp/channels/src/components/admin_console/plugin_management/__snapshots__/plugin_management.test.tsx.snap index 25e3a740a7..5c60a9b187 100644 --- a/webapp/channels/src/components/admin_console/plugin_management/__snapshots__/plugin_management.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/plugin_management/__snapshots__/plugin_management.test.tsx.snap @@ -21,7 +21,7 @@ exports[`components/PluginManagement should match snapshot 1`] = `
- @@ -302,7 +302,7 @@ exports[`components/PluginManagement should match snapshot 1`] = `
- +
- @@ -650,7 +650,7 @@ exports[`components/PluginManagement should match snapshot when \`Enable Marketp
- +
- @@ -746,7 +746,7 @@ exports[`components/PluginManagement should match snapshot when \`Enable Plugins
-
+
- @@ -1094,7 +1094,7 @@ exports[`components/PluginManagement should match snapshot when \`Enable Remote
- +
- @@ -1444,7 +1444,7 @@ exports[`components/PluginManagement should match snapshot when \`Require Signat
- +
- @@ -1796,7 +1796,7 @@ exports[`components/PluginManagement should match snapshot, No installed plugins />
- +
- @@ -2144,7 +2144,7 @@ exports[`components/PluginManagement should match snapshot, allow insecure URL e
- +
- @@ -2469,7 +2469,7 @@ exports[`components/PluginManagement should match snapshot, disabled 1`] = ` setByEnv={false} value="marketplace.example.com" /> - +
- @@ -2817,7 +2817,7 @@ exports[`components/PluginManagement should match snapshot, text entered into th
- +
- @@ -3172,7 +3172,7 @@ exports[`components/PluginManagement should match snapshot, upload disabled 1`]
- +
- @@ -3583,7 +3583,7 @@ exports[`components/PluginManagement should match snapshot, with installed plugi
- +
- @@ -3962,7 +3962,7 @@ exports[`components/PluginManagement should match snapshot, with installed plugi
- +
- @@ -4341,7 +4341,7 @@ exports[`components/PluginManagement should match snapshot, with installed plugi
- +
- @@ -4720,7 +4720,7 @@ exports[`components/PluginManagement should match snapshot, with installed plugi
- +
- @@ -5131,7 +5131,7 @@ exports[`components/PluginManagement should match snapshot, with installed plugi
- +
{ - render(): React.ReactNode { - const {show = true, container = true} = this.props; +const SettingsGroup = ({ + show = true, + container = true, + header, + title, + subtitle, + children, +}: Props) => { + let wrapperClass = ''; + let contentClass = ''; - let wrapperClass = ''; - let contentClass = ''; + if (!show) { + return null; + } - if (!show) { - return null; - } + if (container) { + wrapperClass = 'admin-console__wrapper'; + contentClass = 'admin-console__content'; + } - if (container) { - wrapperClass = 'admin-console__wrapper'; - contentClass = 'admin-console__content'; - } + let sectionTitle = null; + if (!header && title) { + sectionTitle =
{title}
; + } - let header = null; - if (this.props.header) { - header =

{this.props.header}

; - } + let sectionSubtitle = null; + if (!header && subtitle) { + sectionSubtitle = ( +
{subtitle}
+ ); + } - let title = null; - if (!this.props.header && this.props.title) { - title =
{this.props.title}
; - } - - let subtitle = null; - if (!this.props.header && this.props.subtitle) { - subtitle = ( -
{this.props.subtitle}
- ); - } - - let sectionHeader = null; - if (title || subtitle) { - sectionHeader = ( -
- {title} - {subtitle} -
- ); - } - - return ( -
-
- {header} - {sectionHeader} - {this.props.children} -
+ let sectionHeader = null; + if (sectionTitle || sectionSubtitle) { + sectionHeader = ( +
+ {sectionTitle} + {sectionSubtitle}
); } -} + + return ( +
+
+ {header ?

{header}

: null} + {sectionHeader} + {children} +
+
+ ); +}; + +export default memo(SettingsGroup);