From a2d3b211892afefe9fe4ccd041391af45501f4b6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 19 Dec 2011 23:32:59 +0200 Subject: [PATCH] User profile restyle. Feed(Atom) links for commits & issues --- app/assets/images/rss_icon_gray.png | Bin 0 -> 844 bytes app/assets/stylesheets/application.css | 3 + app/assets/stylesheets/projects.css.scss | 8 +++ app/controllers/keys_controller.rb | 4 ++ app/models/user.rb | 4 ++ app/views/commits/index.html.haml | 8 ++- app/views/issues/index.html.haml | 6 ++ app/views/keys/_show.html.haml | 11 +-- app/views/keys/create.js.haml | 2 +- app/views/keys/index.html.haml | 18 ++--- app/views/keys/show.html.haml | 10 +++ app/views/layouts/_head_panel.html.erb | 2 +- app/views/layouts/_middle_panel.html.haml | 5 +- app/views/profile/password.html.haml | 78 ++++++++++++---------- app/views/profile/show.html.haml | 65 +++++++++--------- spec/requests/keys_spec.rb | 15 ++++- 16 files changed, 147 insertions(+), 92 deletions(-) create mode 100644 app/assets/images/rss_icon_gray.png create mode 100644 app/views/keys/show.html.haml diff --git a/app/assets/images/rss_icon_gray.png b/app/assets/images/rss_icon_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..90e509aa4bd1feadf19b1603495b9f8dd1e5bbca GIT binary patch literal 844 zcmV-S1GD^zP)Px$R!~e-MTUlk|NsB6u&{i5e6g{yuCA_?m6fuxvaPMHudlDGtE;N2s->l+qN1X# ztgNZ2si>%^qobprpP#3vr>3T+oSdANmX@TXq@A6eprD|dnwp`Zp_!SPn3$N8larpF zo|2N1mzS53k&&C5n~;!@l$4Z%gM*8Ui;s_wiHV7ahlh=gjkB|}fq{X7f`W{UjEIPc zj*gCng@uHKgo=uadwY9;fPne=`P9_Z?(Xi-&(HSu_RP%8w6wIozP|JG^V-_lwY9a) z&CT50+gwv`E7Pn@9*!+%gegDy5Ha5-QC^L(9nN>f62+ozrVk^xw**5 z$iu_K$H&L?^z^~O!T0y~x3{;uySwM-=eD-C!otGF#>Tw7yyN5J+uPg9%F4jNz`eb_ z;^N}j+1a?bxZvR6#Kgqq<>l4Y)y2id=H}+p)6>}4*!cMP|NsA9GJwqh0004WQchC< zK<3zH00001VoOIv0Eh)0NB{r;32;bRa{vGf6951U69E94oEQKA00(qQO+^RW3=4L_7@Lu}}v2a=Az#upfNy$H-R(Ig6@= my_own_projects.count end diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml index 274f8c22..bce1fefd 100644 --- a/app/views/commits/index.html.haml +++ b/app/views/commits/index.html.haml @@ -1,8 +1,10 @@ - content_for(:body_class, "project-page commits-page") +- if current_user.private_token + = content_for :rss_icon do + .rss-icon + = link_to project_commits_path(@project, :atom, { :private_token => current_user.private_token, :ref => @ref }) do + = image_tag "rss_icon_gray.png", :width => 16, :title => "feed" --#%a.right.button{:href => "#"} Download --#-if can? current_user, :admin_project, @project - %a.right.button.blue{:href => "#"} EDIT - if params[:path] %h2.icon %span diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index 42a7b7ed..473c8136 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -1,3 +1,9 @@ +- if current_user.private_token + = content_for :rss_icon do + .rss-icon + = link_to project_issues_path(@project, :atom, { :private_token => current_user.private_token }) do + = image_tag "rss_icon_gray.png", :width => 16, :title => "feed" + %div#issues-table-holder %table.round-borders#issues-table %thead diff --git a/app/views/keys/_show.html.haml b/app/views/keys/_show.html.haml index fb359989..3d506e42 100644 --- a/app/views/keys/_show.html.haml +++ b/app/views/keys/_show.html.haml @@ -1,4 +1,7 @@ -%tr - %td= truncate key.title, :lenght => 12 - %td= truncate key.key, :lenght => 1114 - %td= link_to 'Cancel', key, :confirm => 'Are you sure?', :method => :delete, :class => "grey-button negative delete-key", :id => "destroy_key_#{key.id}", :remote => true +%a.update-item{:href => key_path(key)} + %span.update-title + = key.title + %span.update-author + Added + = time_ago_in_words(key.created_at) + ago diff --git a/app/views/keys/create.js.haml b/app/views/keys/create.js.haml index a995c355..0e8757f8 100644 --- a/app/views/keys/create.js.haml +++ b/app/views/keys/create.js.haml @@ -1,7 +1,7 @@ - if @key.valid? :plain $("#new_key_dialog").dialog("close"); - $("#keys-table").append("#{escape_javascript(render(:partial => 'show', :locals => {:key => @key} ))}"); + $("#keys-table .data").append("#{escape_javascript(render(:partial => 'show', :locals => {:key => @key} ))}"); $("#no_ssh_key_defined").hide(); - else :plain diff --git a/app/views/keys/index.html.haml b/app/views/keys/index.html.haml index 8c43ce9b..933eef63 100644 --- a/app/views/keys/index.html.haml +++ b/app/views/keys/index.html.haml @@ -1,16 +1,16 @@ -%div#new-key-holder +%h2.icon + %span> + SSH Keys +%div#new-key-holder.right = link_to "Add new", new_key_path, :remote => true, :class => "grey-button" %br -%table.round-borders#keys-table - %tr - %th title - %th key - %th Actions - - @keys.each do |key| - = render(:partial => 'show', :locals => {:key => key}) +%div#keys-table{ :class => "update-data ui-box ui-box-small ui-box-big" } + .data + - @keys.each do |key| + = render(:partial => 'show', :locals => {:key => key}) :javascript $('.delete-key').live('ajax:success', function() { - $(this).closest('tr').fadeOut(); }); + $(this).closest('.update-item').fadeOut(); }); diff --git a/app/views/keys/show.html.haml b/app/views/keys/show.html.haml new file mode 100644 index 00000000..9dcaa093 --- /dev/null +++ b/app/views/keys/show.html.haml @@ -0,0 +1,10 @@ +.ui-box.width-100p + %h3= @key.title + .data + %pre= @key.key + .clear + .buttons + = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => "red-button delete-key right" + .clear + + diff --git a/app/views/layouts/_head_panel.html.erb b/app/views/layouts/_head_panel.html.erb index 5ad82ecd..70484df5 100644 --- a/app/views/layouts/_head_panel.html.erb +++ b/app/views/layouts/_head_panel.html.erb @@ -47,7 +47,7 @@ <% end %> <% end %> -<% if current_user.keys.all.empty? %> +<% if current_user.require_ssh_key? %>

No SSH Key is defined. You won't be able to use any Git command!. Click <%=link_to( 'here', keys_path ) %> to add one!

diff --git a/app/views/layouts/_middle_panel.html.haml b/app/views/layouts/_middle_panel.html.haml index 662b4f3c..181f846a 100644 --- a/app/views/layouts/_middle_panel.html.haml +++ b/app/views/layouts/_middle_panel.html.haml @@ -1,7 +1,10 @@ %h4.middle-panel - .project_name= truncate @project.name, :length => 20 + .project_name + = truncate @project.name, :length => 20 .git_url_wrapper %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"} + = yield :rss_icon + - if @project.repo_exists? .right= render :partial => "projects/refs", :locals => { :destination => controller.controller_name == "commits" ? "commits" : "tree" } diff --git a/app/views/profile/password.html.haml b/app/views/profile/password.html.haml index 0fd20ce2..893263f7 100644 --- a/app/views/profile/password.html.haml +++ b/app/views/profile/password.html.haml @@ -1,40 +1,44 @@ -%p Note: after success password update you will be redirected to login page where you should login with new password -= form_for @user, :url => profile_password_path, :method => :put do |f| - -if @user.errors.any? - #error_explanation - %h2= "#{pluralize(@user.errors.count, "error")} prohibited this password from being saved:" - %ul - - @user.errors.full_messages.each do |msg| - %li= msg +.ui-box.width-100p.append-bottom-20 + %h3 Password + = form_for @user, :url => profile_password_path, :method => :put do |f| + .data + %p After successfull password update you will be redirected to login page where you should login with new password + -if @user.errors.any? + #error_explanation + %ul + - @user.errors.full_messages.each do |msg| + %li= msg - .form-row - = f.label :password - %br - = f.password_field :password - .form-row - = f.label :password_confirmation - %br - = f.password_field :password_confirmation - .actions - = f.submit 'Save', :class => "grey-button" + .form-row + = f.label :password + %br + = f.password_field :password + .form-row + = f.label :password_confirmation + %br + = f.password_field :password_confirmation + .buttons + = f.submit 'Save', :class => "grey-button" +.clear -%br -%br -%br - -= form_for @user, :url => profile_reset_private_token_path, :method => :put do |f| - %p - Current private token: - - if current_user.private_token - %strong - = current_user.private_token - %em.cred - keep it in secret! - - else - %strong don`t have - .actions - - if current_user.private_token - = f.submit 'Reset', :confirm => "Are you sure?", :class => "grey-button" - - else - = f.submit 'Generate', :class => "grey-button" +.ui-box.width-100p + %h3 + Private token + %em.cred.right + keep it in secret! + = form_for @user, :url => profile_reset_private_token_path, :method => :put do |f| + .data + %p Private token used to access application resources without authentication. + %p For example its required to access commits feed. + %hr + %p.cgray + - if current_user.private_token + = text_field_tag "token", current_user.private_token + - else + You don`t have one yet. Click generate to fix it. + .buttons + - if current_user.private_token + = f.submit 'Reset', :confirm => "Are you sure?", :class => "grey-button" + - else + = f.submit 'Generate', :class => "positive-button" diff --git a/app/views/profile/show.html.haml b/app/views/profile/show.html.haml index 375883fe..15233f70 100644 --- a/app/views/profile/show.html.haml +++ b/app/views/profile/show.html.haml @@ -1,36 +1,33 @@ -%h2.icon - %span> - = @user.name +.ui-box.width-100p + %h3= @user.name + = form_for @user, :url => profile_edit_path, :method => :put do |f| + .data + -if @user.errors.any? + #error_explanation + %ul + - @user.errors.full_messages.each do |msg| + %li= msg -.clear - -= form_for @user, :url => profile_edit_path, :method => :put do |f| - -if @user.errors.any? - #error_explanation - %ul - - @user.errors.full_messages.each do |msg| - %li= msg - - .form-row - = f.label :name - %br - = f.text_field :name - .form-row - = f.label :email - %br - = f.text_field :email - .form-row - = f.label :skype - %br - = f.text_field :skype - .form-row - = f.label :linkedin - %br - = f.text_field :linkedin - .form-row - = f.label :twitter - %br - = f.text_field :twitter - .actions - = f.submit 'Save', :class => "grey-button" + .form-row + = f.label :name + %br + = f.text_field :name + .form-row + = f.label :email + %br + = f.text_field :email + .form-row + = f.label :skype + %br + = f.text_field :skype + .form-row + = f.label :linkedin + %br + = f.text_field :linkedin + .form-row + = f.label :twitter + %br + = f.text_field :twitter + .buttons + = f.submit 'Save', :class => "grey-button" diff --git a/spec/requests/keys_spec.rb b/spec/requests/keys_spec.rb index 6ce22b30..be1f42a4 100644 --- a/spec/requests/keys_spec.rb +++ b/spec/requests/keys_spec.rb @@ -16,9 +16,11 @@ describe "Issues" do it { should have_content(@key.title) } describe "Destroy" do + before { visit key_path(@key) } + it "should remove entry" do expect { - click_link "destroy_key_#{@key.id}" + click_link "Remove" }.to change { @user.keys.count }.by(-1) end end @@ -47,8 +49,17 @@ describe "Issues" do page.should_not have_content("Add new public key") page.should have_content "laptop" - page.should have_content "publickey234=" end end end + + describe "Show page" do + before do + @key = Factory :key, :user => @user + visit key_path(@key) + end + + it { page.should have_content @key.title } + it { page.should have_content @key.key[0..10] } + end end