From e7aa8315af71339ecb6b01ae7da83f3c9b1e1957 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 27 Jun 2016 12:46:27 +0100 Subject: [PATCH 1/3] Added user avatar to header Closes #18543 --- .../stylesheets/framework/dropdowns.scss | 6 ++++-- app/assets/stylesheets/framework/header.scss | 21 +++++++++++++------ app/views/layouts/header/_default.html.haml | 14 ++++++++++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss index 00111dfa70..b39b8cbf50 100644 --- a/app/assets/stylesheets/framework/dropdowns.scss +++ b/app/assets/stylesheets/framework/dropdowns.scss @@ -20,7 +20,8 @@ } .open { - .dropdown-menu { + .dropdown-menu, + .dropdown-menu-nav { display: block; } @@ -66,7 +67,8 @@ } } -.dropdown-menu { +.dropdown-menu, +.dropdown-menu-nav { display: none; position: absolute; top: 100%; diff --git a/app/assets/stylesheets/framework/header.scss b/app/assets/stylesheets/framework/header.scss index c32ce5195c..0c60707184 100644 --- a/app/assets/stylesheets/framework/header.scss +++ b/app/assets/stylesheets/framework/header.scss @@ -60,7 +60,7 @@ header { margin: ($header-height - 28) / 2 0; margin-left: 10px; height: 28px; - width: 28px; + min-width: 28px; line-height: 28px; text-align: center; @@ -241,14 +241,23 @@ header { .navbar-collapse { padding-left: 5px; - li { + .nav > li { display: table-cell; width: 1%; - - a { - margin-left: 8px !important; - } } } } } + +.header-user { + .dropdown-menu-nav { + width: 140px; + margin-top: -5px; + } +} + +.header-user-avatar { + float: left; + margin-right: 5px; + border-radius: 50%; +} diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index 40a2c81eeb..5c76c4b8fa 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -38,9 +38,17 @@ = link_to sherlock_transactions_path, title: 'Sherlock Transactions', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = icon('tachometer fw') - %li - = link_to destroy_user_session_path, class: 'logout', method: :delete, title: 'Sign out', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do - = icon('sign-out') + %li.header-user.dropdown + = link_to current_user, class: "header-user-dropdown-toggle", data: { toggle: "dropdown" } do + = image_tag avatar_icon(current_user, 26), width: 26, height: 26, class: "header-user-avatar" + %span.caret + .dropdown-menu-nav.dropdown-menu-align-right + %ul + %li + = link_to "Profile", current_user + %li.divider + %li + = link_to "Sign out", destroy_user_session_path, method: :delete, title: 'Sign out' - else %li %div From a44988ae4abb494b1194bb575b2415ef0de68878 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 27 Jun 2016 14:31:19 +0100 Subject: [PATCH 2/3] Fixed logout tests --- app/views/layouts/header/_default.html.haml | 2 +- features/project/issues/issues.feature | 2 +- features/search.feature | 8 +++++--- spec/support/login_helpers.rb | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index 5c76c4b8fa..8118afabe5 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -48,7 +48,7 @@ = link_to "Profile", current_user %li.divider %li - = link_to "Sign out", destroy_user_session_path, method: :delete, title: 'Sign out' + = link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link", title: 'Sign out' - else %li %div diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature index 2259b7125c..358e622b73 100644 --- a/features/project/issues/issues.feature +++ b/features/project/issues/issues.feature @@ -219,8 +219,8 @@ Feature: Project Issues When I click button "Unsubscribe" Then I should see that I am unsubscribed + @javascript Scenario: I submit new unassigned issue as guest - Given I logout Given public project "Community" When I visit project "Community" page And I visit project "Community" issues page diff --git a/features/search.feature b/features/search.feature index a946a83652..818ef436db 100644 --- a/features/search.feature +++ b/features/search.feature @@ -73,13 +73,15 @@ Feature: Search Scenario: I logout and should see project I am looking for Given project "Shop" is public - And I logout + And I logout directly + And I visit dashboard search page And I search for "Sho" Then I should see "Shop" project link Scenario: I logout and should see issues I am looking for Given project "Shop" is public - And I logout + And I logout directly + And I visit dashboard search page And project has issues When I search for "Foo" And I click "Issues" link @@ -88,7 +90,7 @@ Feature: Search Scenario: I logout and should see project code I am looking for Given project "Shop" is public - And I logout + And I logout directly When I visit project "Shop" page And I search for "rspec" on project page Then I should see code results for project "Shop" diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 7a0f078c72..ffdf2bb0a8 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -39,7 +39,8 @@ module LoginHelpers # Requires Javascript driver. def logout - find(:css, ".fa.fa-sign-out").click + find(".header-user-dropdown-toggle").click + click_link "Sign out" end # Logout without JavaScript driver From e65a703122fa4fa6c2cce2aeb76904d630e1c389 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 29 Jun 2016 10:38:32 +0100 Subject: [PATCH 3/3] Updating padding in dropdown menu --- app/assets/stylesheets/framework/dropdowns.scss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss index b39b8cbf50..2a90a1fef3 100644 --- a/app/assets/stylesheets/framework/dropdowns.scss +++ b/app/assets/stylesheets/framework/dropdowns.scss @@ -79,7 +79,7 @@ margin-bottom: 0; font-size: 15px; font-weight: normal; - padding: 10px 0; + padding: 8px 0; background-color: $dropdown-bg; border: 1px solid $dropdown-border-color; border-radius: $border-radius-base; @@ -103,12 +103,12 @@ li { text-align: left; list-style: none; - padding: 0 10px; + padding: 0 8px; } .divider { height: 1px; - margin: 8px 10px; + margin: 8px; padding: 0; background-color: $dropdown-divider-color; } @@ -124,7 +124,7 @@ a { display: block; position: relative; - padding: 5px 10px; + padding: 5px 8px; color: $dropdown-link-color; line-height: initial; text-overflow: ellipsis;