Skip to content

Commit

Permalink
Add keys to user setting page
Browse files Browse the repository at this point in the history
Keys' form is added to same page as index. Moved aside bar on user
settings page to a partial. A few changes in style to set active class
of aside bar.
  • Loading branch information
sonalkr132 committed Jul 22, 2015
1 parent ff2e446 commit ad45ec2
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,4 @@ DEPENDENCIES
will_paginate

BUNDLED WITH
1.10.2
1.10.5
2 changes: 1 addition & 1 deletion app/assets/javascripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $("document").ready( function(){
if(articleContent === "login"){
$(".wrapper nav").css("display", "none");
}
var toolbarDivs = $("section.toolbar div, section.action div");
var toolbarDivs = $("section.toolbar div, section.action div, aside nav ul li");
toolbarDivs.each(function(){
if($(this).attr("data") === articleContent){
$(this).addClass("active");
Expand Down
7 changes: 3 additions & 4 deletions app/assets/stylesheets/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ $nprogress-color: red;
}
}
}

table {
width: 100%;
}
section{
background-color: white;
padding: 0.25em;
Expand Down Expand Up @@ -100,9 +102,6 @@ $nprogress-color: red;
}
}
}
table {
width: 100%;
}
}
}
aside{
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ class KeysController < ApplicationController
before_filter :authenticate_user!

def index
@keys = current_user.keys
end

def new
@key = current_user.keys.new
current_user.keys.delete @key # remove new key from collection
@keys = current_user.keys
end

def create
Expand Down
16 changes: 16 additions & 0 deletions app/views/devise/registrations/_user_aside.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%aside
%h1
User Settings
%nav
%ul
%li{ data: 'profile' }
= link_to 'Profile', edit_user_registration_path
%li{ data: 'identities' }
= link_to 'Identities', identities_path
%li{ data: 'keys' }
= link_to 'SSH Keys', keys_path
-#
%li
= link_to 'Passwords'
%li
= link_to 'Projects', identities_path
19 changes: 2 additions & 17 deletions app/views/devise/registrations/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- content_for :title do
= current_user.username.titleize

%article
%article.user{ data: 'profile' }
%header
%h1
= avatar current_user.email
Expand Down Expand Up @@ -37,19 +37,4 @@
%div
= f.submit 'Update'

%aside
%h1
User Settings
%nav
%ul
%li.active
= link_to 'Profile', edit_user_registration_path
%li
= link_to 'Identities', identities_path
-#
%li
= link_to 'Passwords'
%li
= link_to 'SSH Keys', identities_path
%li
= link_to 'Projects', identities_path
= render 'user_aside'
17 changes: 2 additions & 15 deletions app/views/identities/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- content_for :title do
= current_user.username.titleize

%article.user{ data: 'settings' }
%article.user{ data: 'identities' }
%header
%h1
= avatar current_user.email
Expand Down Expand Up @@ -29,17 +29,4 @@
- @allowedmethods.each do |method|
%div
= link_to(method.to_s.capitalize, "/auth/#{method}")
%aside
%h1
User Settings
%nav
%ul
%li
= link_to 'Profile', edit_user_registration_path
%li.active
= link_to 'Identities', identities_path
-#
%li
= link_to 'SSH Keys', identities_path
%li
= link_to 'Projects', identities_path
= render 'devise/registrations/user_aside'
11 changes: 11 additions & 0 deletions app/views/keys/_new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%p
%strong Add keys to your account
= form_for @key do |f|
- @key.errors.full_messages.each do |msg|
%p.error_message
= msg
= f.label :title
= f.text_field :title, placeholder: 'Title', autofocus: true
= f.label :key
= f.text_area :key, rows: 8
= f.submit 'Add key'
10 changes: 6 additions & 4 deletions app/views/keys/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- content_for :title do
= current_user.username.titleize

%article.user{ data: 'settings' }
%article.user{ data: 'keys' }
%header
%h1
= avatar current_user.email
Expand All @@ -17,13 +17,14 @@
%section
%div
.option
= render 'new'
- if @keys.any?
%table
%thead
%tr
%th Title
%th Fingerprint
%th Added at
%th Added
%th
%tbody
- @keys.each do |key|
Expand All @@ -34,11 +35,12 @@
%code= key.fingerprint
%td
%span
added #{distance_of_time_in_words_to_now key.created_at}
#{distance_of_time_in_words_to_now key.created_at} ago
%td
= link_to 'Remove',
key_path(key),
data: { confirm: 'Are you sure?' },
method: :delete
- else
There are no SSH keys with access to your account.
There are no SSH keys with access to your account.
= render 'devise/registrations/user_aside'
24 changes: 0 additions & 24 deletions app/views/keys/new.html.haml

This file was deleted.

2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


resources :projects
resources :keys, only: [:new, :create, :index, :destroy]
resources :keys, only: [:create, :index, :destroy]
resources :identities, only: [:destroy,:index]
resources :comments, only: [:new, :create, :destroy]
resources :glitterposts
Expand Down

0 comments on commit ad45ec2

Please sign in to comment.