Commit dc37c8aaae29f2340ba3fd0bcda08c937010abde

Authored by Dmitriy Zaporozhets
1 parent 8f9a450e

Refactored profile area

app/assets/stylesheets/common.scss
... ... @@ -699,7 +699,14 @@ li.note {
699 699 .active {
700 700 img {
701 701 border:1px solid #ccc;
  702 + background:$hover;
702 703 @include border-radius(5px);
703 704 }
704 705 }
705 706 }
  707 +
  708 +.btn-build-token {
  709 + float: left;
  710 + padding: 6px 20px;
  711 + margin-right: 12px;
  712 +}
... ...
app/assets/stylesheets/main.scss
... ... @@ -161,6 +161,11 @@ $hover: #fdf5d9;
161 161 @import "sections/notes.scss";
162 162  
163 163 /**
  164 + * This file represent profile styles
  165 + */
  166 +@import "sections/profile.scss";
  167 +
  168 +/**
164 169 * Devise styles
165 170 */
166 171 @import "sections/login.scss";
... ...
app/assets/stylesheets/sections/profile.scss 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +.profile_history {
  2 + .event_feed {
  3 + min-height:20px;
  4 + .avatar {
  5 + width:20px;
  6 + }
  7 + }
  8 +}
... ...
app/controllers/profile_controller.rb
... ... @@ -32,10 +32,14 @@ class ProfileController < ApplicationController
32 32  
33 33 def reset_private_token
34 34 current_user.reset_authentication_token!
35   - redirect_to profile_token_path
  35 + redirect_to profile_account_path
36 36 end
37 37  
38   - private
  38 + def history
  39 + @events = current_user.recent_events.page(params[:page]).per(20)
  40 + end
  41 +
  42 + private
39 43  
40 44 def user
41 45 @user = current_user
... ...
app/helpers/application_helper.rb
... ... @@ -104,7 +104,8 @@ module ApplicationHelper
104 104  
105 105 # Profile Area
106 106 when :profile; current_page?(controller: "profile", action: :show)
107   - when :password; current_page?(controller: "profile", action: :password)
  107 + when :history; current_page?(controller: "profile", action: :history)
  108 + when :account; current_page?(controller: "profile", action: :account)
108 109 when :token; current_page?(controller: "profile", action: :token)
109 110 when :design; current_page?(controller: "profile", action: :design)
110 111 when :ssh_keys; controller.controller_name == "keys"
... ...
app/views/layouts/profile.html.haml
... ... @@ -9,20 +9,20 @@
9 9 %li.home{class: tab_class(:profile)}
10 10 = link_to "Profile", profile_path
11 11  
12   - %li{class: tab_class(:password)}
13   - = link_to "Authentication", profile_password_path
  12 + %li{class: tab_class(:account)}
  13 + = link_to "Account", profile_account_path
14 14  
15 15 %li{class: tab_class(:ssh_keys)}
16 16 = link_to keys_path do
17 17 SSH Keys
18 18 %span.count= current_user.keys.count
19 19  
20   - %li{class: tab_class(:token)}
21   - = link_to "Token", profile_token_path
22   -
23 20 %li{class: tab_class(:design)}
24 21 = link_to "Design", profile_design_path
25 22  
  23 + %li{class: tab_class(:history)}
  24 + = link_to "History", profile_history_path
  25 +
26 26  
27 27 .content
28 28 = yield
... ...
app/views/profile/account.html.haml 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +- if Gitlab.config.omniauth_enabled?
  2 + %fieldset
  3 + %legend
  4 + %h3.page_title Social Accounts
  5 + .oauth_select_holder
  6 + %p.hint Tip: Click on icon to activate sigin with one of the following services
  7 + - User.omniauth_providers.each do |provider|
  8 + %span{class: oauth_active_class(provider) }
  9 + = link_to authbutton(provider, 32), omniauth_authorize_path(User, provider)
  10 +
  11 +
  12 +%fieldset
  13 + %legend
  14 + %h3.page_title
  15 + Private token
  16 + %span.cred.right
  17 + keep it in secret!
  18 + .padded
  19 + = form_for @user, url: profile_reset_private_token_path, method: :put do |f|
  20 + .data
  21 + %p.slead
  22 + Private token used to access application resources without authentication.
  23 + %br
  24 + It can be used for atom feed or API
  25 + %p.cgray
  26 + - if current_user.private_token
  27 + = text_field_tag "token", current_user.private_token, class: "xxlarge large_text"
  28 + = f.submit 'Reset', confirm: "Are you sure?", class: "btn primary btn-build-token"
  29 + - else
  30 + %span You don`t have one yet. Click generate to fix it.
  31 + = f.submit 'Generate', class: "btn success btn-build-token"
  32 +
  33 +%fieldset
  34 + %legend
  35 + %h3.page_title Password
  36 + = form_for @user, url: profile_password_path, method: :put do |f|
  37 + .padded
  38 + %p.slead After successful password update you will be redirected to login page where you should login with new password
  39 + -if @user.errors.any?
  40 + .alert-message.block-message.error
  41 + %ul
  42 + - @user.errors.full_messages.each do |msg|
  43 + %li= msg
  44 +
  45 + .clearfix
  46 + = f.label :password
  47 + .input= f.password_field :password
  48 + .clearfix
  49 + = f.label :password_confirmation
  50 + .input= f.password_field :password_confirmation
  51 + .actions
  52 + = f.submit 'Save', class: "btn save-btn"
  53 +
  54 +
  55 +
  56 +
  57 +
... ...
app/views/profile/history.html.haml 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +.profile_history
  2 + = render @events
  3 +%hr
  4 += paginate @events, theme: "gitlab"
  5 +
... ...
app/views/profile/password.html.haml
... ... @@ -1,29 +0,0 @@
1   -- if Gitlab.config.omniauth_enabled?
2   - %h3.page_title Accounts
3   - %hr
4   - %p.hint Tip: Click on icon to activate sigin with one of the following services
5   - .oauth_select_holder
6   - - User.omniauth_providers.each do |provider|
7   - %span{class: oauth_active_class(provider) }
8   - = link_to authbutton(provider, 32), omniauth_authorize_path(User, provider)
9   -
10   -.clearfix.prepend-top-20
11   -%h3.page_title Password
12   -%hr
13   -
14   -= form_for @user, url: profile_password_path, method: :put do |f|
15   - %p.slead After successful password update you will be redirected to login page where you should login with new password
16   - -if @user.errors.any?
17   - .alert-message.block-message.error
18   - %ul
19   - - @user.errors.full_messages.each do |msg|
20   - %li= msg
21   -
22   - .clearfix
23   - = f.label :password
24   - .input= f.password_field :password
25   - .clearfix
26   - = f.label :password_confirmation
27   - .input= f.password_field :password_confirmation
28   - .actions
29   - = f.submit 'Save', class: "btn save-btn"
app/views/profile/show.html.haml
... ... @@ -33,13 +33,13 @@
33 33 %ul
34 34 -unless Gitlab.config.disable_gravatar?
35 35 %li
36   - %p.hint You can change your avatar at gravatar.com
  36 + %p.hint You can change your avatar at #{link_to "gravatar.com", "http://gravatar.com"}
37 37  
38 38 - if Gitlab.config.omniauth_enabled? && @user.provider?
39 39 %li
40 40 %p.hint
41 41 You can login through #{@user.provider.titleize}!
42   - = link_to "click here to change", profile_password_path
  42 + = link_to "click here to change", profile_account_path
43 43  
44 44 %hr
45 45 .row
... ...
app/views/profile/token.html.haml
... ... @@ -1,23 +0,0 @@
1   -%h3.page_title
2   - Private token
3   - %span.cred.right
4   - keep it in secret!
5   -%hr
6   -= form_for @user, url: profile_reset_private_token_path, method: :put do |f|
7   - .data
8   - %p.slead
9   - Private token used to access application resources without authentication.
10   - %br
11   - It can be used for atom feed or API
12   - %p.cgray
13   - - if current_user.private_token
14   - = text_field_tag "token", current_user.private_token, class: "xxlarge large_text"
15   - - else
16   - You don`t have one yet. Click generate to fix it.
17   - .actions
18   - - if current_user.private_token
19   - = f.submit 'Reset', confirm: "Are you sure?", class: "btn"
20   - - else
21   - = f.submit 'Generate', class: "btn primary"
22   -
23   -
config/routes.rb
... ... @@ -63,7 +63,8 @@ Gitlab::Application.routes.draw do
63 63 #
64 64 # Profile Area
65 65 #
66   - get "profile/password", :to => "profile#password"
  66 + get "profile/account", :to => "profile#account"
  67 + get "profile/history", :to => "profile#history"
67 68 put "profile/password", :to => "profile#password_update"
68 69 get "profile/token", :to => "profile#token"
69 70 put "profile/reset_private_token", :to => "profile#reset_private_token"
... ...
features/profile/profile.feature
... ... @@ -12,7 +12,7 @@ Feature: Profile
12 12 And I should see new contact info
13 13  
14 14 Scenario: I change my password
15   - Given I visit profile password page
  15 + Given I visit profile account page
16 16 Then I change my password
17 17 And I should be redirected to sign in page
18 18  
... ...
features/steps/shared/paths.rb
... ... @@ -21,8 +21,8 @@ module SharedPaths
21 21 visit profile_path
22 22 end
23 23  
24   - Given 'I visit profile password page' do
25   - visit profile_password_path
  24 + Given 'I visit profile account page' do
  25 + visit profile_account_path
26 26 end
27 27  
28 28 Given 'I visit profile token page' do
... ...
spec/requests/security/profile_access_spec.rb
... ... @@ -28,8 +28,8 @@ describe "Users Security" do
28 28 it { should be_denied_for :visitor }
29 29 end
30 30  
31   - describe "GET /profile/password" do
32   - subject { profile_password_path }
  31 + describe "GET /profile/account" do
  32 + subject { profile_account_path }
33 33  
34 34 it { should be_allowed_for @u1 }
35 35 it { should be_allowed_for :admin }
... ...