Commit 3832b2aa679d71dc857f4a6083f0038a2eeb7a9f

Authored by Dmitriy Zaporozhets
1 parent 3707cc11

Improve Profile#account page

app/helpers/profile_helper.rb
@@ -4,4 +4,16 @@ module ProfileHelper @@ -4,4 +4,16 @@ module ProfileHelper
4 'active' 4 'active'
5 end 5 end
6 end 6 end
  7 +
  8 + def show_profile_username_tab?
  9 + current_user.can_change_username?
  10 + end
  11 +
  12 + def show_profile_social_tab?
  13 + Gitlab.config.omniauth.enabled && !current_user.ldap_user?
  14 + end
  15 +
  16 + def show_profile_remove_tab?
  17 + Gitlab.config.gitlab.signup_enabled && !current_user.ldap_user?
  18 + end
7 end 19 end
app/views/profiles/account.html.haml
@@ -5,91 +5,128 @@ @@ -5,91 +5,128 @@
5 - if current_user.ldap_user? 5 - if current_user.ldap_user?
6 Some options are unavailable for LDAP accounts 6 Some options are unavailable for LDAP accounts
7 %hr 7 %hr
8 -- unless current_user.ldap_user?  
9 - - if Gitlab.config.omniauth.enabled  
10 - %fieldset  
11 - %legend Social Accounts  
12 - .oauth_select_holder  
13 - %p.hint Tip: Click on icon to activate signin with one of the following services  
14 - - enabled_social_providers.each do |provider|  
15 - %span{class: oauth_active_class(provider) }  
16 - = link_to authbutton(provider, 32), omniauth_authorize_path(User, provider)  
17 8
18 9
19 - %fieldset.update-password  
20 - %legend Password  
21 - = form_for @user, url: update_password_profile_path, method: :put do |f|  
22 - .padded  
23 - %p.slead After a successful password update you will be redirected to login page where you should login with your new password  
24 - -if @user.errors.any?  
25 - .alert.alert-error  
26 - %ul  
27 - - @user.errors.full_messages.each do |msg|  
28 - %li= msg 10 +.row
  11 + .span2
  12 + %ul.nav.nav-pills.nav-stacked.nav-stacked-menu
  13 + %li.active
  14 + = link_to '#tab-token', 'data-toggle' => 'tab' do
  15 + Private Token
  16 + %li
  17 + = link_to '#tab-password', 'data-toggle' => 'tab' do
  18 + Password
29 19
30 - .control-group  
31 - = f.label :password  
32 - .controls= f.password_field :password, required: true  
33 - .control-group  
34 - = f.label :password_confirmation  
35 - .controls  
36 - = f.password_field :password_confirmation, required: true  
37 - .control-group  
38 - .controls  
39 - = f.submit 'Save password', class: "btn btn-save" 20 + - if show_profile_social_tab?
  21 + %li
  22 + = link_to '#tab-social', 'data-toggle' => 'tab' do
  23 + Social Accounts
40 24
  25 + - if show_profile_username_tab?
  26 + %li
  27 + = link_to '#tab-username', 'data-toggle' => 'tab' do
  28 + Change Username
41 29
  30 + - if show_profile_remove_tab?
  31 + %li
  32 + = link_to '#tab-remove', 'data-toggle' => 'tab' do
  33 + Remove Account
  34 + .span10
  35 + .tab-content
  36 + .tab-pane.active#tab-token
  37 + %fieldset.update-token
  38 + %legend
  39 + Private token
  40 + %span.cred.pull-right
  41 + keep it secret!
  42 + %div
  43 + = form_for @user, url: reset_private_token_profile_path, method: :put do |f|
  44 + .data
  45 + %p.slead
  46 + Your private token is used to access application resources without authentication.
  47 + %br
  48 + It can be used for atom feeds or the API.
  49 + %p.cgray
  50 + - if current_user.private_token
  51 + = text_field_tag "token", current_user.private_token, class: "input-xxlarge large_text input-xpadding"
  52 + = f.submit 'Reset', confirm: "Are you sure?", class: "btn btn-primary btn-build-token"
  53 + - else
  54 + %span You don`t have one yet. Click generate to fix it.
  55 + = f.submit 'Generate', class: "btn success btn-build-token"
42 56
43 -%fieldset.update-token  
44 - %legend  
45 - Private token  
46 - %span.cred.pull-right  
47 - keep it secret!  
48 - .padded  
49 - = form_for @user, url: reset_private_token_profile_path, method: :put do |f|  
50 - .data  
51 - %p.slead  
52 - Your private token is used to access application resources without authentication.  
53 - %br  
54 - It can be used for atom feeds or the API.  
55 - %p.cgray  
56 - - if current_user.private_token  
57 - = text_field_tag "token", current_user.private_token, class: "input-xxlarge large_text input-xpadding"  
58 - = f.submit 'Reset', confirm: "Are you sure?", class: "btn btn-primary btn-build-token"  
59 - - else  
60 - %span You don`t have one yet. Click generate to fix it.  
61 - = f.submit 'Generate', class: "btn success btn-build-token" 57 + .tab-pane#tab-password
  58 + %fieldset.update-password
  59 + %legend Password
  60 + = form_for @user, url: update_password_profile_path, method: :put do |f|
  61 + %div
  62 + %p.slead After a successful password update you will be redirected to login page where you should login with your new password
  63 + -if @user.errors.any?
  64 + .alert.alert-error
  65 + %ul
  66 + - @user.errors.full_messages.each do |msg|
  67 + %li= msg
  68 + .control-group
  69 + = f.label :password
  70 + .controls= f.password_field :password, required: true
  71 + .control-group
  72 + = f.label :password_confirmation
  73 + .controls
  74 + = f.password_field :password_confirmation, required: true
  75 + .control-group
  76 + .controls
  77 + = f.submit 'Save password', class: "btn btn-save"
62 78
  79 + - if show_profile_social_tab?
  80 + .tab-pane#tab-social
  81 + %fieldset
  82 + %legend Social Accounts
  83 + .oauth_select_holder
  84 + %p.hint Tip: Click on icon to activate signin with one of the following services
  85 + - enabled_social_providers.each do |provider|
  86 + %span{class: oauth_active_class(provider) }
  87 + = link_to authbutton(provider, 32), omniauth_authorize_path(User, provider)
63 88
64 -- if current_user.can_change_username?  
65 - %fieldset.update-username  
66 - %legend  
67 - Username  
68 - %small.cred.pull-right  
69 - Changing your username can have unintended side effects!  
70 - = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f|  
71 - .padded  
72 - = f.label :username  
73 - .controls  
74 - = f.text_field :username, required: true  
75 -    
76 - %span.loading-gif.hide= image_tag "ajax_loader.gif"  
77 - %span.update-success.cgreen.hide  
78 - %i.icon-ok  
79 - Saved  
80 - %span.update-failed.cred.hide  
81 - %i.icon-remove  
82 - Failed  
83 - %ul.cred  
84 - %li This will change the web URL for personal projects.  
85 - %li This will change the git path to repositories for personal projects.  
86 - .controls  
87 - = f.submit 'Save username', class: "btn btn-save" 89 + - if show_profile_username_tab?
  90 + .tab-pane#tab-username
  91 + %fieldset.update-username
  92 + %legend
  93 + Username
  94 + %small.cred.pull-right
  95 + Changing your username can have unintended side effects!
  96 + = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f|
  97 + %div
  98 + .control-group
  99 + = f.label :username
  100 + .controls
  101 + = f.text_field :username, required: true
  102 +  
  103 + %span.loading-gif.hide= image_tag "ajax_loader.gif"
  104 + %span.update-success.cgreen.hide
  105 + %i.icon-ok
  106 + Saved
  107 + %span.update-failed.cred.hide
  108 + %i.icon-remove
  109 + Failed
  110 + %ul.cred
  111 + %li This will change the web URL for personal projects.
  112 + %li This will change the git path to repositories for personal projects.
  113 + .controls
  114 + = f.submit 'Save username', class: "btn btn-save"
88 115
89 -- if gitlab_config.signup_enabled && !current_user.ldap_user?  
90 - %fieldset.remove-account  
91 - %legend  
92 - Remove account  
93 - %small.cred.pull-right  
94 - Before removing the account you must remove all projects!  
95 - = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right" 116 + - if show_profile_remove_tab?
  117 + .tab-pane#tab-remove
  118 + %fieldset.remove-account
  119 + %legend
  120 + Remove account
  121 + %div
  122 + %p Deleting an account has the following effects:
  123 + %ul
  124 + %li All user content like authored issues, snippets, comments will be removed
  125 + - rp = current_user.personal_projects.count
  126 + - unless rp.zero?
  127 + %li #{pluralize rp, 'personal project'} will be removed and cannot be restored
  128 + - if current_user.solo_owned_groups.present?
  129 + %li
  130 + Next groups will be abandoned. You should transfer or remove them:
  131 + %strong #{current_user.solo_owned_groups.map(&:name).join(', ')}
  132 + = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove"