Commit a2d3b211892afefe9fe4ccd041391af45501f4b6

Authored by Dmitriy Zaporozhets
1 parent 54fb0f85

User profile restyle. Feed(Atom) links for commits & issues

app/assets/images/rss_icon_gray.png 0 → 100644

844 Bytes

app/assets/stylesheets/application.css
... ... @@ -40,6 +40,9 @@
40 40 .append-bottom-10 {
41 41 margin-bottom:10px;
42 42 }
  43 +.append-bottom-20 {
  44 + margin-bottom:20px;
  45 +}
43 46 .prepend-top-10 {
44 47 margin-top:10px;
45 48 }
... ...
app/assets/stylesheets/projects.css.scss
... ... @@ -639,3 +639,11 @@ h4.middle-panel {
639 639 background: #4A2;
640 640 color: white;
641 641 }
  642 +
  643 +.rss-icon {
  644 + margin:0 15px;
  645 + padding:5px;
  646 + border:1px solid #ccc;
  647 + border-radius:3px;
  648 + float:left;
  649 +}
... ...
app/controllers/keys_controller.rb
... ... @@ -6,6 +6,10 @@ class KeysController < ApplicationController
6 6 @keys = current_user.keys.all
7 7 end
8 8  
  9 + def show
  10 + @key = current_user.keys.find(params[:id])
  11 + end
  12 +
9 13 def new
10 14 @key = current_user.keys.new
11 15  
... ...
app/models/user.rb
... ... @@ -46,6 +46,10 @@ class User < ActiveRecord::Base
46 46 admin
47 47 end
48 48  
  49 + def require_ssh_key?
  50 + keys.count == 0
  51 + end
  52 +
49 53 def can_create_project?
50 54 projects_limit >= my_own_projects.count
51 55 end
... ...
app/views/commits/index.html.haml
1 1 - content_for(:body_class, "project-page commits-page")
  2 +- if current_user.private_token
  3 + = content_for :rss_icon do
  4 + .rss-icon
  5 + = link_to project_commits_path(@project, :atom, { :private_token => current_user.private_token, :ref => @ref }) do
  6 + = image_tag "rss_icon_gray.png", :width => 16, :title => "feed"
2 7  
3   --#%a.right.button{:href => "#"} Download
4   --#-if can? current_user, :admin_project, @project
5   - %a.right.button.blue{:href => "#"} EDIT
6 8 - if params[:path]
7 9 %h2.icon
8 10 %span
... ...
app/views/issues/index.html.haml
  1 +- if current_user.private_token
  2 + = content_for :rss_icon do
  3 + .rss-icon
  4 + = link_to project_issues_path(@project, :atom, { :private_token => current_user.private_token }) do
  5 + = image_tag "rss_icon_gray.png", :width => 16, :title => "feed"
  6 +
1 7 %div#issues-table-holder
2 8 %table.round-borders#issues-table
3 9 %thead
... ...
app/views/keys/_show.html.haml
1   -%tr
2   - %td= truncate key.title, :lenght => 12
3   - %td= truncate key.key, :lenght => 1114
4   - %td= link_to 'Cancel', key, :confirm => 'Are you sure?', :method => :delete, :class => "grey-button negative delete-key", :id => "destroy_key_#{key.id}", :remote => true
  1 +%a.update-item{:href => key_path(key)}
  2 + %span.update-title
  3 + = key.title
  4 + %span.update-author
  5 + Added
  6 + = time_ago_in_words(key.created_at)
  7 + ago
... ...
app/views/keys/create.js.haml
1 1 - if @key.valid?
2 2 :plain
3 3 $("#new_key_dialog").dialog("close");
4   - $("#keys-table").append("#{escape_javascript(render(:partial => 'show', :locals => {:key => @key} ))}");
  4 + $("#keys-table .data").append("#{escape_javascript(render(:partial => 'show', :locals => {:key => @key} ))}");
5 5 $("#no_ssh_key_defined").hide();
6 6 - else
7 7 :plain
... ...
app/views/keys/index.html.haml
1   -%div#new-key-holder
  1 +%h2.icon
  2 + %span>
  3 + SSH Keys
  4 +%div#new-key-holder.right
2 5 = link_to "Add new", new_key_path, :remote => true, :class => "grey-button"
3 6 %br
4 7  
5   -%table.round-borders#keys-table
6   - %tr
7   - %th title
8   - %th key
9   - %th Actions
10   - - @keys.each do |key|
11   - = render(:partial => 'show', :locals => {:key => key})
  8 +%div#keys-table{ :class => "update-data ui-box ui-box-small ui-box-big" }
  9 + .data
  10 + - @keys.each do |key|
  11 + = render(:partial => 'show', :locals => {:key => key})
12 12  
13 13 :javascript
14 14 $('.delete-key').live('ajax:success', function() {
15   - $(this).closest('tr').fadeOut(); });
  15 + $(this).closest('.update-item').fadeOut(); });
16 16  
... ...
app/views/keys/show.html.haml 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +.ui-box.width-100p
  2 + %h3= @key.title
  3 + .data
  4 + %pre= @key.key
  5 + .clear
  6 + .buttons
  7 + = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => "red-button delete-key right"
  8 + .clear
  9 +
  10 +
... ...
app/views/layouts/_head_panel.html.erb
... ... @@ -47,7 +47,7 @@
47 47 <% end %>
48 48 <% end %>
49 49  
50   -<% if current_user.keys.all.empty? %>
  50 +<% if current_user.require_ssh_key? %>
51 51 <div id="no_ssh_key_defined" class="big-message error">
52 52 <p>No SSH Key is defined. You won't be able to use any Git command!. Click <%=link_to( 'here', keys_path ) %> to add one!
53 53 </div>
... ...
app/views/layouts/_middle_panel.html.haml
1 1 %h4.middle-panel
2   - .project_name= truncate @project.name, :length => 20
  2 + .project_name
  3 + = truncate @project.name, :length => 20
3 4 .git_url_wrapper
4 5 %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"}
  6 + = yield :rss_icon
  7 +
5 8 - if @project.repo_exists?
6 9 .right= render :partial => "projects/refs", :locals => { :destination => controller.controller_name == "commits" ? "commits" : "tree" }
7 10  
... ...
app/views/profile/password.html.haml
1   -%p Note: after success password update you will be redirected to login page where you should login with new password
2   -= form_for @user, :url => profile_password_path, :method => :put do |f|
3   - -if @user.errors.any?
4   - #error_explanation
5   - %h2= "#{pluralize(@user.errors.count, "error")} prohibited this password from being saved:"
6   - %ul
7   - - @user.errors.full_messages.each do |msg|
8   - %li= msg
  1 +.ui-box.width-100p.append-bottom-20
  2 + %h3 Password
  3 + = form_for @user, :url => profile_password_path, :method => :put do |f|
  4 + .data
  5 + %p After successfull password update you will be redirected to login page where you should login with new password
  6 + -if @user.errors.any?
  7 + #error_explanation
  8 + %ul
  9 + - @user.errors.full_messages.each do |msg|
  10 + %li= msg
9 11  
10   - .form-row
11   - = f.label :password
12   - %br
13   - = f.password_field :password
14   - .form-row
15   - = f.label :password_confirmation
16   - %br
17   - = f.password_field :password_confirmation
18   - .actions
19   - = f.submit 'Save', :class => "grey-button"
  12 + .form-row
  13 + = f.label :password
  14 + %br
  15 + = f.password_field :password
  16 + .form-row
  17 + = f.label :password_confirmation
  18 + %br
  19 + = f.password_field :password_confirmation
  20 + .buttons
  21 + = f.submit 'Save', :class => "grey-button"
  22 +.clear
20 23  
21   -%br
22   -%br
23   -%br
24   -
25   -= form_for @user, :url => profile_reset_private_token_path, :method => :put do |f|
26   - %p
27   - Current private token:
28   - - if current_user.private_token
29   - %strong
30   - = current_user.private_token
31   - %em.cred
32   - keep it in secret!
33   - - else
34   - %strong don`t have
35   - .actions
36   - - if current_user.private_token
37   - = f.submit 'Reset', :confirm => "Are you sure?", :class => "grey-button"
38   - - else
39   - = f.submit 'Generate', :class => "grey-button"
  24 +.ui-box.width-100p
  25 + %h3
  26 + Private token
  27 + %em.cred.right
  28 + keep it in secret!
  29 + = form_for @user, :url => profile_reset_private_token_path, :method => :put do |f|
  30 + .data
  31 + %p Private token used to access application resources without authentication.
  32 + %p For example its required to access commits feed.
  33 + %hr
  34 + %p.cgray
  35 + - if current_user.private_token
  36 + = text_field_tag "token", current_user.private_token
  37 + - else
  38 + You don`t have one yet. Click generate to fix it.
  39 + .buttons
  40 + - if current_user.private_token
  41 + = f.submit 'Reset', :confirm => "Are you sure?", :class => "grey-button"
  42 + - else
  43 + = f.submit 'Generate', :class => "positive-button"
40 44  
... ...
app/views/profile/show.html.haml
1   -%h2.icon
2   - %span>
3   - = @user.name
  1 +.ui-box.width-100p
  2 + %h3= @user.name
  3 + = form_for @user, :url => profile_edit_path, :method => :put do |f|
  4 + .data
  5 + -if @user.errors.any?
  6 + #error_explanation
  7 + %ul
  8 + - @user.errors.full_messages.each do |msg|
  9 + %li= msg
4 10  
5   -.clear
6   -
7   -= form_for @user, :url => profile_edit_path, :method => :put do |f|
8   - -if @user.errors.any?
9   - #error_explanation
10   - %ul
11   - - @user.errors.full_messages.each do |msg|
12   - %li= msg
13   -
14   - .form-row
15   - = f.label :name
16   - %br
17   - = f.text_field :name
18   - .form-row
19   - = f.label :email
20   - %br
21   - = f.text_field :email
22   - .form-row
23   - = f.label :skype
24   - %br
25   - = f.text_field :skype
26   - .form-row
27   - = f.label :linkedin
28   - %br
29   - = f.text_field :linkedin
30   - .form-row
31   - = f.label :twitter
32   - %br
33   - = f.text_field :twitter
34   - .actions
35   - = f.submit 'Save', :class => "grey-button"
  11 + .form-row
  12 + = f.label :name
  13 + %br
  14 + = f.text_field :name
  15 + .form-row
  16 + = f.label :email
  17 + %br
  18 + = f.text_field :email
  19 + .form-row
  20 + = f.label :skype
  21 + %br
  22 + = f.text_field :skype
  23 + .form-row
  24 + = f.label :linkedin
  25 + %br
  26 + = f.text_field :linkedin
  27 + .form-row
  28 + = f.label :twitter
  29 + %br
  30 + = f.text_field :twitter
  31 + .buttons
  32 + = f.submit 'Save', :class => "grey-button"
36 33  
... ...
spec/requests/keys_spec.rb
... ... @@ -16,9 +16,11 @@ describe &quot;Issues&quot; do
16 16 it { should have_content(@key.title) }
17 17  
18 18 describe "Destroy" do
  19 + before { visit key_path(@key) }
  20 +
19 21 it "should remove entry" do
20 22 expect {
21   - click_link "destroy_key_#{@key.id}"
  23 + click_link "Remove"
22 24 }.to change { @user.keys.count }.by(-1)
23 25 end
24 26 end
... ... @@ -47,8 +49,17 @@ describe &quot;Issues&quot; do
47 49  
48 50 page.should_not have_content("Add new public key")
49 51 page.should have_content "laptop"
50   - page.should have_content "publickey234="
51 52 end
52 53 end
53 54 end
  55 +
  56 + describe "Show page" do
  57 + before do
  58 + @key = Factory :key, :user => @user
  59 + visit key_path(@key)
  60 + end
  61 +
  62 + it { page.should have_content @key.title }
  63 + it { page.should have_content @key.key[0..10] }
  64 + end
54 65 end
... ...