From 70d2fde4922eadb50fb720c9afa7a1ce38b1f20f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 3 Mar 2016 15:49:00 -0500 Subject: [PATCH] Restructure SSH key table partial rendering Prior, we were double-checking `@keys.any?`, and unnecessarily assigning `is_admin` in a view where it wasn't needed. --- app/views/profiles/keys/_key_table.html.haml | 12 +++++++++--- app/views/profiles/keys/index.html.haml | 10 +--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/views/profiles/keys/_key_table.html.haml b/app/views/profiles/keys/_key_table.html.haml index 233d79d9467..296cafa6e31 100644 --- a/app/views/profiles/keys/_key_table.html.haml +++ b/app/views/profiles/keys/_key_table.html.haml @@ -1,5 +1,11 @@ -- is_admin = defined?(admin) ? true : false +- is_admin = local_assigns.fetch(:admin, false) + - if @keys.any? %ul.well-list - - @keys.each do |key| - = render 'profiles/keys/key', key: key, is_admin: is_admin + = render partial: 'profiles/keys/key', collection: @keys, locals: { is_admin: is_admin } +- else + %p.profile-settings-message.text-center + - if is_admin + There are no SSH keys associated with this account. + - else + There are no SSH keys with access to your account. diff --git a/app/views/profiles/keys/index.html.haml b/app/views/profiles/keys/index.html.haml index 127c4a5b102..e0f8c9a5733 100644 --- a/app/views/profiles/keys/index.html.haml +++ b/app/views/profiles/keys/index.html.haml @@ -1,6 +1,5 @@ - page_title "SSH Keys" - header_title page_title, profile_keys_path -- is_admin = defined?(admin) ? true : false .row.prepend-top-default .col-lg-3.profile-settings-sidebar @@ -19,11 +18,4 @@ %h5 Your SSH keys (#{@keys.count}) %div.append-bottom-default - - if @keys.any? - = render 'key_table' - - else - %p.profile-settings-message.text-center - - if is_admin - User has no ssh keys - - else - There are no SSH keys with access to your account. + = render 'key_table'