From 56bd7b572de79a2751ffc3fc502c4c56fc519a70 Mon Sep 17 00:00:00 2001 From: David Kang Date: Tue, 20 Aug 2019 15:39:27 +0200 Subject: [PATCH] Move user info elements and add switch for beta program --- .../app/assets/stylesheets/webui2/user.scss | 4 - .../views/webui2/webui/user/_info.html.haml | 95 +++++++++---------- .../webui/users/user_home_page_spec.rb | 30 ++++++ .../webui/users/user_home_page_spec.rb | 2 + 4 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 src/api/spec/bootstrap/features/webui/users/user_home_page_spec.rb diff --git a/src/api/app/assets/stylesheets/webui2/user.scss b/src/api/app/assets/stylesheets/webui2/user.scss index d0c6b9853b1c..d7e989b04d76 100644 --- a/src/api/app/assets/stylesheets/webui2/user.scss +++ b/src/api/app/assets/stylesheets/webui2/user.scss @@ -1,7 +1,3 @@ -#home-login { - color: $gray-500; -} - .activity-percentil0 { background-color: #dcd5da; } diff --git a/src/api/app/views/webui2/webui/user/_info.html.haml b/src/api/app/views/webui2/webui/user/_info.html.haml index 9b6521539719..55aef0b66eb1 100644 --- a/src/api/app/views/webui2/webui/user/_info.html.haml +++ b/src/api/app/views/webui2/webui/user/_info.html.haml @@ -2,63 +2,58 @@ .card-body = image_tag_for(user) - %h4.home-usertitle.mt-4 - #home-realname - = user.realname - %h4.d-inline-block#home-login + %h4.mb-0.mt-4#home-realname + = user.realname + %h5.d-inline-block.mb-0.align-middle.text-muted#home-login = user.login - - role_titles.each do |title| - %span.badge.badge-secondary.align-top - = title.upcase - - if User.session = mail_to(user.email, title: "Send mail to #{user.name}", class: 'd-block') do %i.fas.fa-envelope = user.email + - role_titles.each do |title| + %span.badge.badge-secondary + = title.upcase - if groups.any? - Member of the #{'group'.pluralize(groups.size)} - %ul - - groups.each do |group| - %li - = link_to(group_show_path(group)) do - #{group.title} - %span.badge.badge-primary.align-top - #{group.tasks} #{'task'.pluralize(group.tasks)} + .mt-4 + Member of the #{'group'.pluralize(groups.size)} + %ul + - groups.each do |group| + %li + = link_to(group_show_path(group)) do + #{group.title} + %span.badge.badge-primary.align-baseline + #{group.tasks} #{'task'.pluralize(group.tasks)} - if is_user - - if user.in_beta? - %p - .badge.badge-info - In public beta program - = link_to(user_save_path(user: { login: user.login, in_beta: 0 }), method: :post, class: 'd-block') do - %i.fas.fa-sign-out-alt - Leave public beta program - - else - = link_to(user_save_path(user: { login: user.login, in_beta: 1 }), method: :post, class: 'd-block') do - %i.fas.fa-sign-in-alt - Join public beta program - - - if configuration.accounts_editable?(user) - - if account_edit_link.present? - = link_to(account_edit_link, class: 'd-block') do - %i.fas.fa-user-edit - Edit your account - - else - = link_to('#', data: { toggle: 'modal', target: '#edit-modal' }, class: 'd-block') do - %i.fas.fa-user-edit - Edit your account - - - if configuration.passwords_changable?(user) - = link_to('#', data: { toggle: 'modal', target: '#password-modal' }, class: 'd-block') do - %i.fas.fa-key - Change your password - = link_to(user_notifications_path, class: 'd-block') do - %i.fas.fa-bell - Change your notifications - - - if user.rss_token - = link_to(user_rss_notifications_path(token: user.rss_token.string, format: 'rss'), title: 'RSS Feed for Notifications', class: 'd-block') do - %i.fas.fa-rss-square - RSS for notifications + .mt-4#beta-program + = link_to(user_save_path(user: { login: user.login, in_beta: user.in_beta? ? 0 : 1 }), method: :post) do + %i.fas.text-primary{ class: "#{user.in_beta? ? 'fa-toggle-on' : 'fa-toggle-off'}" } + %span Public beta program + %i.fa.fa-question-circle.text-info{ data: { placement: 'top', toggle: 'popover', title: 'Public beta program', + content: 'Enabling the public beta program, you will be able to try the latest features ' + | + 'ongoing development and give us feedback on them.' } } | + + .mt-4 + - if configuration.accounts_editable?(user) + - if account_edit_link.present? + = link_to(account_edit_link, class: 'd-block') do + %i.fas.fa-user-edit + Edit your account + - else + = link_to('#', data: { toggle: 'modal', target: '#edit-modal' }, class: 'd-block') do + %i.fas.fa-user-edit + Edit your account + - if configuration.passwords_changable?(user) + = link_to('#', data: { toggle: 'modal', target: '#password-modal' }, class: 'd-block') do + %i.fas.fa-key + Change your password + = link_to(user_notifications_path, class: 'd-block') do + %i.fas.fa-bell + Change your notifications + - if user.rss_token + = link_to(user_rss_notifications_path(token: user.rss_token.string, format: 'rss'), + title: 'RSS Feed for Notifications', class: 'd-block') do + %i.fas.fa-rss-square + RSS for notifications diff --git a/src/api/spec/bootstrap/features/webui/users/user_home_page_spec.rb b/src/api/spec/bootstrap/features/webui/users/user_home_page_spec.rb new file mode 100644 index 000000000000..c80917c6076f --- /dev/null +++ b/src/api/spec/bootstrap/features/webui/users/user_home_page_spec.rb @@ -0,0 +1,30 @@ +require 'browser_helper' + +RSpec.feature "User's home project creation", type: :feature, js: true do + let!(:user) { create(:confirmed_user, login: 'Jim', realname: 'Jim Knopf', email: 'jim.knopf@puppenkiste.com') } + + describe 'as a logged-in user' do + before do + login user + visit home_path + end + + scenario 'public beta program' do + within('#beta-program') do + expect(page).to have_css('.fa-toggle-off') + end + + click_link('Public beta program') + expect(page).to have_text("User data for user 'Jim' successfully updated.") + within('#beta-program') do + expect(page).to have_css('.fa-toggle-on') + end + + click_link('Public beta program') + expect(page).to have_text("User data for user 'Jim' successfully updated.") + within('#beta-program') do + expect(page).to have_css('.fa-toggle-off') + end + end + end +end diff --git a/src/api/spec/features/webui/users/user_home_page_spec.rb b/src/api/spec/features/webui/users/user_home_page_spec.rb index ff5f430eef13..1d093c39dce5 100644 --- a/src/api/spec/features/webui/users/user_home_page_spec.rb +++ b/src/api/spec/features/webui/users/user_home_page_spec.rb @@ -68,6 +68,8 @@ end scenario 'public beta program' do + skip_if_bootstrap + # TODO: Change by have_text('In public beta program') when dropping old UI expect(page).not_to have_content(/(Participates in|In) public beta program/)