From e062603ff266bda9b57d949e21a12d0bfcd96f0a Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Thu, 26 Aug 2021 14:15:28 +0200 Subject: [PATCH] Remove useless React fragments (#1062) --- .eslintrc.js | 2 + src/PageHeader.tsx | 50 +- src/client-scopes/ClientScopesSection.tsx | 44 +- src/client-scopes/add/MapperDialog.tsx | 4 +- src/client-scopes/details/MapperList.tsx | 8 +- src/client-scopes/details/MappingDetails.tsx | 54 +- src/clients/ClientSettings.tsx | 418 +++++---- src/clients/ClientsSection.tsx | 32 +- src/clients/add/CapabilityConfig.tsx | 500 ++++++----- src/clients/credentials/SignedJWT.tsx | 90 +- src/clients/keys/Keys.tsx | 47 +- src/clients/scopes/ClientScopes.tsx | 40 +- .../service-account/ServiceAccount.tsx | 24 +- .../attribute-form/AttributeForm.tsx | 194 ++--- .../bread-crumb/GroupBreadCrumbs.tsx | 58 +- .../bread-crumb/PageBreadCrumbs.tsx | 2 +- src/components/error/ErrorRenderer.tsx | 8 +- src/components/group/GroupPickerDialog.tsx | 4 +- src/components/help-enabler/HelpItem.tsx | 46 +- .../list-empty-state/ListEmptyState.tsx | 72 +- .../table-toolbar/KeycloakDataTable.tsx | 7 +- .../table-toolbar/PaginatingTableToolbar.tsx | 2 +- src/components/table-toolbar/TableToolbar.tsx | 57 +- src/components/view-header/ViewHeader.tsx | 2 +- src/dashboard/Dashboard.tsx | 8 +- src/events/AdminEvents.tsx | 302 ++++--- src/groups/GroupTable.tsx | 20 +- src/groups/Members.tsx | 8 +- src/groups/SearchGroups.tsx | 20 +- .../IdentityProvidersSection.tsx | 32 +- .../add/AdvancedSettings.tsx | 4 + .../add/ExtendedNonDiscoverySettings.tsx | 167 ++-- .../icons/FontAwesomeIcon.tsx | 2 +- src/realm-roles/AliasRendererComponent.tsx | 2 +- src/realm-roles/AssociatedRolesTab.tsx | 187 ++-- src/realm-roles/RoleAttributes.tsx | 192 ++--- src/realm-roles/RolesList.tsx | 6 +- src/realm-roles/UsersInRoleTab.tsx | 162 ++-- src/realm-settings/GeneralTab.tsx | 313 ++++--- src/realm-settings/KeysListTab.tsx | 234 +++-- src/realm-settings/KeysProvidersTab.tsx | 124 ++- src/realm-settings/LoginTab.tsx | 365 ++++---- src/realm-settings/RealmSettingsSection.tsx | 24 +- src/realm-settings/SessionsTab.tsx | 690 ++++++++------- src/realm-settings/ThemesTab.tsx | 606 +++++++------ src/realm-settings/TokensTab.tsx | 812 +++++++++--------- .../event-config/EventsTypeTable.tsx | 16 +- .../aes-generated/AESGeneratedForm.tsx | 26 +- .../ecdsa-generated/ECDSAGeneratedForm.tsx | 26 +- .../hmac-generated/HMACGeneratedForm.tsx | 26 +- .../java-keystore/JavaKeystoreForm.tsx | 26 +- .../rsa-generated/RSAGeneratedForm.tsx | 26 +- .../key-providers/rsa/RSAForm.tsx | 26 +- .../kerberos/KerberosSettingsRequired.tsx | 4 +- .../mappers/LdapMapperHardcodedLdapGroup.tsx | 52 +- .../ldap/mappers/LdapMapperList.tsx | 4 +- .../mappers/LdapMapperMsadUserAccount.tsx | 56 +- .../ldap/mappers/LdapMapperUserAttribute.tsx | 60 +- src/user-federation/shared/SettingsCache.tsx | 12 +- src/user/UserForm.tsx | 42 +- src/user/UserGroups.tsx | 24 +- src/user/UsersSection.tsx | 14 +- 62 files changed, 3157 insertions(+), 3328 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f7cdd0c04e..d385f0e8ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,8 @@ module.exports = { // react/prop-types cannot handle generic props, so we need to disable it. // https://github.com/yannickcr/eslint-plugin-react/issues/2777#issuecomment-814968432 "react/prop-types": "off", + // Prevent fragments from being added that have only a single child. + "react/jsx-no-useless-fragment": "error" }, overrides: [ { diff --git a/src/PageHeader.tsx b/src/PageHeader.tsx index a235d816d9..d193c0d9ea 100644 --- a/src/PageHeader.tsx +++ b/src/PageHeader.tsx @@ -27,37 +27,27 @@ export const Header = () => { const adminClient = useAdminClient(); const { t } = useTranslation(); - const ManageAccountDropdownItem = () => { - return ( - <> - {adminClient.keycloak && ( - adminClient.keycloak?.accountManagement()} - > - {t("manageAccount")} - - )} - - ); - }; + const ManageAccountDropdownItem = () => + adminClient.keycloak ? ( + adminClient.keycloak?.accountManagement()} + > + {t("manageAccount")} + + ) : null; - const SignOutDropdownItem = () => { - return ( - <> - {adminClient.keycloak && ( - adminClient.keycloak?.logout({ redirectUri: "" })} - > - {t("signOut")} - - )} - - ); - }; + const SignOutDropdownItem = () => + adminClient.keycloak ? ( + adminClient.keycloak?.logout({ redirectUri: "" })} + > + {t("signOut")} + + ) : null; const ServerInfoDropdownItem = () => { const { realm } = useRealm(); diff --git a/src/client-scopes/ClientScopesSection.tsx b/src/client-scopes/ClientScopesSection.tsx index 8e0ff6a0eb..637251ddd3 100644 --- a/src/client-scopes/ClientScopesSection.tsx +++ b/src/client-scopes/ClientScopesSection.tsx @@ -107,22 +107,20 @@ export const ClientScopesSection = () => { }); const TypeSelector = (scope: ClientScopeDefaultOptionalType) => ( - <> - { - try { - await changeScope(adminClient, scope, value); - addAlert(t("clientScopeSuccess"), AlertVariant.success); - refresh(); - } catch (error) { - addError("client-scopes:clientScopeError", error); - } - }} - /> - + { + try { + await changeScope(adminClient, scope, value); + addAlert(t("clientScopeSuccess"), AlertVariant.success); + refresh(); + } catch (error) { + addError("client-scopes:clientScopeError", error); + } + }} + /> ); const ClientScopeDetailLink = ({ @@ -130,14 +128,12 @@ export const ClientScopesSection = () => { type, name, }: ClientScopeDefaultOptionalType) => ( - <> - - {name} - - + + {name} + ); return ( <> diff --git a/src/client-scopes/add/MapperDialog.tsx b/src/client-scopes/add/MapperDialog.tsx index f0e8b4dbd6..17c8eb08b8 100644 --- a/src/client-scopes/add/MapperDialog.tsx +++ b/src/client-scopes/add/MapperDialog.tsx @@ -128,10 +128,10 @@ export const AddMapperDialog = (props: AddMapperDialogProps) => { - <>{mapper.name} + {mapper.name} , - <>{mapper.helpText} + {mapper.helpText} , ]} /> diff --git a/src/client-scopes/details/MapperList.tsx b/src/client-scopes/details/MapperList.tsx index e7141ee709..66715979b6 100644 --- a/src/client-scopes/details/MapperList.tsx +++ b/src/client-scopes/details/MapperList.tsx @@ -99,11 +99,9 @@ export const MapperList = ({ clientScope, refresh }: MapperListProps) => { ); const MapperLink = ({ id, name }: Row) => ( - <> - - {name} - - + + {name} + ); return ( diff --git a/src/client-scopes/details/MappingDetails.tsx b/src/client-scopes/details/MappingDetails.tsx index eeebda7958..8cd2b010bd 100644 --- a/src/client-scopes/details/MappingDetails.tsx +++ b/src/client-scopes/details/MappingDetails.tsx @@ -164,40 +164,36 @@ export const MappingDetails = () => { onSubmit={handleSubmit(save)} role="manage-clients" > - <> - {!mapperId.match(isGuid) && ( - - } - fieldId="name" - isRequired + {!mapperId.match(isGuid) && ( + + } + fieldId="name" + isRequired + validated={ + errors.name ? ValidatedOptions.error : ValidatedOptions.default + } + helperTextInvalid={t("common:required")} + > + - - - )} - + /> + + )} { ); return ( - <> - -
- - - - - - } - > - +
+ + + + + - - - } - > - - - - } - > - - - - } - > - - - - } - > - - - - - - } - fieldId="loginTheme" - > - ( - - )} - /> - - - ( - - )} - /> - - - ( - onChange("" + value)} - isDisabled={!consentRequired} - /> - )} - /> - - -