From ddfc83af6fecde20b980d00d83fd3937b022bec3 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 21 Oct 2022 14:14:38 +0200 Subject: [PATCH] chg: [navigation:socialProvider] Improved UI for SSO profile management --- src/Controller/Component/Navigation/Users.php | 1 + src/View/Helper/SocialProviderHelper.php | 5 ++++ .../element/layouts/header/header-profile.php | 27 +++++++++++++++++++ webroot/css/layout.css | 4 +++ 4 files changed, 37 insertions(+) diff --git a/src/Controller/Component/Navigation/Users.php b/src/Controller/Component/Navigation/Users.php index 4b1837b..c14ec70 100644 --- a/src/Controller/Component/Navigation/Users.php +++ b/src/Controller/Component/Navigation/Users.php @@ -72,6 +72,7 @@ class UsersNavigation extends BaseNavigation return []; }); if ( + !empty($this->loggedUser['social_profile']) && !empty(Configure::read('keycloak.enabled')) && !empty(Configure::read('keycloak.provider.baseUrl')) && !empty(Configure::read('keycloak.provider.realm')) && diff --git a/src/View/Helper/SocialProviderHelper.php b/src/View/Helper/SocialProviderHelper.php index df5c52b..effb8c5 100644 --- a/src/View/Helper/SocialProviderHelper.php +++ b/src/View/Helper/SocialProviderHelper.php @@ -13,6 +13,11 @@ class SocialProviderHelper extends Helper 'keycloak' => '/img/keycloak_logo.png', ]; + public function hasSocialProfile($identity): bool + { + return !empty($identity['social_profile']); + } + public function getIcon($identity) { if (!empty($identity['social_profile'])) { diff --git a/templates/element/layouts/header/header-profile.php b/templates/element/layouts/header/header-profile.php index 146aa3e..197eb8e 100644 --- a/templates/element/layouts/header/header-profile.php +++ b/templates/element/layouts/header/header-profile.php @@ -1,5 +1,6 @@
@@ -29,6 +30,32 @@ use Cake\Routing\Router; + SocialProvider->hasSocialProfile($this->request->getAttribute('identity'))) && + !empty(Configure::read('keycloak.enabled')) && + !empty(Configure::read('keycloak.provider.baseUrl')) && + !empty(Configure::read('keycloak.provider.realm')) && + !empty($this->request->getAttribute('identity')['id']) + ): + ?> + + SocialProvider->getIcon($this->request->getAttribute('identity')))): ?> + SocialProvider->getIcon($this->request->getAttribute('identity')) ?> + + + + + + diff --git a/webroot/css/layout.css b/webroot/css/layout.css index 4625b2b..9762b1b 100644 --- a/webroot/css/layout.css +++ b/webroot/css/layout.css @@ -513,6 +513,10 @@ ul.sidebar-elements > li.category > span.category-divider > hr { padding: 2px; border-radius: 0 0 0 5px; } +.header-breadcrumb-children .dropdown-menu .dropdown-item { + display: flex; + align-items: center; +} .header-breadcrumb-children .dropdown-menu .dropdown-item > i { min-width: 25px; }