From ef161bbb31872222076e1ebda60324e835513aca Mon Sep 17 00:00:00 2001 From: Zalax Date: Wed, 27 Oct 2021 15:39:35 +0200 Subject: [PATCH] Improve SSO display on login page (#150) sort SSO providers by alphabetical order, and reset provider list on homeserver change (to avoid having them if the homeserver is invalid) --- src/app/molecules/sso-buttons/SSOButtons.jsx | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/app/molecules/sso-buttons/SSOButtons.jsx b/src/app/molecules/sso-buttons/SSOButtons.jsx index 47d001c7..af6cb927 100644 --- a/src/app/molecules/sso-buttons/SSOButtons.jsx +++ b/src/app/molecules/sso-buttons/SSOButtons.jsx @@ -10,6 +10,9 @@ function SSOButtons({ homeserver }) { const [identityProviders, setIdentityProviders] = useState([]); useEffect(() => { + // Reset sso proviers to avoid displaying sso icons if the homeserver is not valid + setIdentityProviders([]); + // If the homeserver passed in is not a fully-qualified domain name, do not update. if (!homeserver.match('^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\\.[a-zA-Z]{2,})+$')) { return; @@ -49,16 +52,19 @@ function SSOButtons({ homeserver }) { OR
- {identityProviders.sort((idp) => !!idp.imageSrc).map((idp) => ( - - ))} + {identityProviders + // Sort by alphabetical order + .sort((idp, idp2) => !!idp.imageSrc && idp.name > idp2.name) + .map((idp) => ( + + ))}
);