From eb2cbc5164d65c1c1dc58bc59b96282fb2e6375d Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Fri, 10 Feb 2017 22:28:36 +1100 Subject: [PATCH 1/2] add options dropdown to email items convert Email field to dropdown if multiple emails, add link to Emails page --- app/views/profiles/emails/_options.html.haml | 16 ++++++++++++++++ app/views/profiles/emails/index.html.haml | 20 +++++++++++--------- app/views/profiles/show.html.haml | 15 ++++++++++++++- 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 app/views/profiles/emails/_options.html.haml diff --git a/app/views/profiles/emails/_options.html.haml b/app/views/profiles/emails/_options.html.haml new file mode 100644 index 000000000000..1dc31d03f483 --- /dev/null +++ b/app/views/profiles/emails/_options.html.haml @@ -0,0 +1,16 @@ +- if email != current_user.email or email != current_user.public_email && email != current_user.notification_email + .dropdown.inline.prepend-left-10 + %button.dropdown-toggle.btn.btn-sm{ 'data-toggle' => 'dropdown' } + %span.light + Options + = icon('chevron-down') + %ul.dropdown-menu.dropdown-menu-align-right + - if email.email != current_user.email + %li + = link_to 'Make primary email', profile_email_path(email), method: :put + - if email.email != current_user.public_email + %li + = link_to 'Make public email', profile_email_path(email), method: :put + - if email.email != current_user.notification_email + %li + = link_to 'Make notification email', profile_email_path(email), method: :put diff --git a/app/views/profiles/emails/index.html.haml b/app/views/profiles/emails/index.html.haml index dc499be885bd..d18392bf3a7b 100644 --- a/app/views/profiles/emails/index.html.haml +++ b/app/views/profiles/emails/index.html.haml @@ -32,18 +32,20 @@ %ul.well-list %li = @primary + %span.label.label-success Primary Email + - if @primary === current_user.public_email + %span.label.label-info Public Email + - if @primary === current_user.notification_email + %span.label.label-info Notification Email %span.pull-right - %span.label.label-success Primary Email - - if @primary === current_user.public_email - %span.label.label-info Public Email - - if @primary === current_user.notification_email - %span.label.label-info Notification Email + = render 'options', current_user: current_user, email: current_user - @emails.each do |email| %li = email.email + - if email.email === current_user.public_email + %span.label.label-info Public Email + - if email.email === current_user.notification_email + %span.label.label-info Notification Email %span.pull-right - - if email.email === current_user.public_email - %span.label.label-info Public Email - - if email.email === current_user.notification_email - %span.label.label-info Notification Email + = render 'options', current_user: current_user, email: email = link_to 'Remove', profile_email_path(email), data: { confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-sm btn-warning prepend-left-10' diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index d551754a2e53..ebbea583470b 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -57,7 +57,20 @@ - if @user.temp_oauth_email? = f.text_field :email, class: "form-control", required: true, value: nil - else - = f.text_field :email, class: "form-control", required: true + - if @user.all_emails.length <= 1 + = f.text_field :email, class: "form-control", required: true, readonly: true + - else + .dropdown + %button.dropdown-toggle.form-control{ 'data-toggle' => 'dropdown' } + %span.light + = @user.email + = icon('chevron-down') + %ul.dropdown-menu + - @user.all_emails.each do |email| + %li + = link_to email, profile_email_path(email), method: :put + %li + = link_to 'Manage', profile_emails_path() - if @user.unconfirmed_email.present? %span.help-block Please click the link in the confirmation email before continuing. It was sent to -- GitLab From 12584acc95fcb6bba0cd8871799c777de8129a82 Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Tue, 14 Feb 2017 00:22:50 +1100 Subject: [PATCH 2/2] update other email fields to use dropdowns with Manage link --- .../stylesheets/framework/dropdowns.scss | 6 +++-- app/assets/stylesheets/pages/profile.scss | 14 +++++++++++ .../profiles/notifications/show.html.haml | 18 +++++++++++++- app/views/profiles/show.html.haml | 24 +++++++++++++++---- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss index ff31e7f7b3dc..6fbe6b6b8e91 100644 --- a/app/assets/stylesheets/framework/dropdowns.scss +++ b/app/assets/stylesheets/framework/dropdowns.scss @@ -41,6 +41,7 @@ border: 1px solid $border-color; border-radius: $border-radius-base; white-space: nowrap; + position: relative; &[disabled] { background-color: $input-bg-disabled; @@ -79,8 +80,9 @@ .fa-chevron-down { font-size: $dropdown-chevron-size; position: relative; - top: -3px; - margin-left: 5px; + top: calc(50% - 0.5em); + right: 1em; + position: absolute; } &:hover { diff --git a/app/assets/stylesheets/pages/profile.scss b/app/assets/stylesheets/pages/profile.scss index 8031c4467a47..b872dc98d574 100644 --- a/app/assets/stylesheets/pages/profile.scss +++ b/app/assets/stylesheets/pages/profile.scss @@ -70,6 +70,20 @@ } } +.account-well-flex { + display: -webkit-flex; + display: flex; + + *:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + + *:last-child { + margin-left: auto; + } +} + .profile-link-holder { display: inline; diff --git a/app/views/profiles/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml index 5c5e59403658..9f340163c570 100644 --- a/app/views/profiles/notifications/show.html.haml +++ b/app/views/profiles/notifications/show.html.haml @@ -24,7 +24,23 @@ = form_for @user, url: profile_notifications_path, method: :put, html: { class: 'update-notifications prepend-top-default' } do |f| .form-group = f.label :notification_email, class: "label-light" - = f.select :notification_email, @user.all_emails, { include_blank: false }, class: "select2" + - if @user.all_emails.length <= 1 + .account-well.account-well-flex + %span= @user.notification_email + = link_to 'Manage', profile_emails_path() + - else + .dropdown + %button.dropdown-toggle.wide{ 'data-toggle' => 'dropdown' } + %span.light + = @user.email + = icon('chevron-down') + %ul.dropdown-menu.dropdown-menu-full-width + - @user.all_emails.each do |email| + %li + = link_to email, profile_email_path(email), method: :put + %li.separator + %li + = link_to 'Manage', profile_emails_path() = label_tag :global_notification_level, "Global notification level", class: "label-light" %br diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index ebbea583470b..e9fcdfa992cb 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -58,17 +58,20 @@ = f.text_field :email, class: "form-control", required: true, value: nil - else - if @user.all_emails.length <= 1 - = f.text_field :email, class: "form-control", required: true, readonly: true + .account-well.account-well-flex + %span= @user.email + = link_to 'Manage', profile_emails_path() - else .dropdown - %button.dropdown-toggle.form-control{ 'data-toggle' => 'dropdown' } + %button.dropdown-toggle.wide{ 'data-toggle' => 'dropdown' } %span.light = @user.email = icon('chevron-down') - %ul.dropdown-menu + %ul.dropdown-menu.dropdown-menu-full-width - @user.all_emails.each do |email| %li = link_to email, profile_email_path(email), method: :put + %li.separator %li = link_to 'Manage', profile_emails_path() - if @user.unconfirmed_email.present? @@ -83,7 +86,20 @@ %span.help-block We also use email for avatar detection if no avatar is uploaded. .form-group = f.label :public_email, class: "label-light" - = f.select :public_email, options_for_select(@user.all_emails, selected: @user.public_email), { include_blank: 'Do not show on profile' }, class: "select2" + .dropdown + %button.dropdown-toggle.wide{ 'data-toggle' => 'dropdown' } + %span.light + = 'Do not show on profile' + = icon('chevron-down') + %ul.dropdown-menu.dropdown-menu-full-width + %li + = link_to 'Do not show on profile', profile_email_path(''), method: :put + - @user.all_emails.each do |email| + %li + = link_to email, profile_email_path(email), method: :put + %li.separator + %li + = link_to 'Manage', profile_emails_path() %span.help-block This email will be displayed on your public profile. .form-group = f.label :skype, class: "label-light" -- GitLab