Commit 492f3a47 authored by Marin Jankovski's avatar Marin Jankovski

Add user key actions to admins.

parent 75043a9e
...@@ -11,6 +11,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -11,6 +11,7 @@ class Admin::UsersController < Admin::ApplicationController
def show def show
@personal_projects = user.personal_projects @personal_projects = user.personal_projects
@joined_projects = user.projects.joined(@user) @joined_projects = user.projects.joined(@user)
@ssh_keys = user.keys.order('id DESC')
end end
def new def new
...@@ -107,6 +108,27 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -107,6 +108,27 @@ class Admin::UsersController < Admin::ApplicationController
end end
end end
def show_key
@key = user.keys.find(params[:key_id])
respond_to do |format|
format.html { render 'key' }
format.js { render nothing: true }
end
end
def remove_key
key = user.keys.find(params[:key_id])
respond_to do |format|
if key.destroy
format.html { redirect_to [:admin, user], notice: 'User key was successfully removed.' }
else
format.html { redirect_to [:admin, user], alert: 'Failed to remove user key.' }
end
end
end
protected protected
def user def user
...@@ -118,7 +140,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -118,7 +140,7 @@ class Admin::UsersController < Admin::ApplicationController
:email, :remember_me, :bio, :name, :username, :email, :remember_me, :bio, :name, :username,
:skype, :linkedin, :twitter, :website_url, :color_scheme_id, :theme_id, :force_random_password, :skype, :linkedin, :twitter, :website_url, :color_scheme_id, :theme_id, :force_random_password,
:extern_uid, :provider, :password_expires_at, :avatar, :hide_no_ssh_key, :extern_uid, :provider, :password_expires_at, :avatar, :hide_no_ssh_key,
:projects_limit, :can_create_group, :admin :projects_limit, :can_create_group, :admin, :key_id
) )
end end
end end
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
%a{"data-toggle" => "tab", href: "#groups"} Groups %a{"data-toggle" => "tab", href: "#groups"} Groups
%li %li
%a{"data-toggle" => "tab", href: "#projects"} Projects %a{"data-toggle" => "tab", href: "#projects"} Projects
%li
%a{"data-toggle" => "tab", href: "#ssh-keys"} SSH keys
.tab-content .tab-content
#account.tab-pane.active #account.tab-pane.active
...@@ -217,3 +219,28 @@ ...@@ -217,3 +219,28 @@
- if tm.respond_to? :project - if tm.respond_to? :project
= link_to project_team_member_path(project, @user), data: { confirm: remove_from_project_team_message(project, @user) }, remote: true, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from project' do = link_to project_team_member_path(project, @user), data: { confirm: remove_from_project_team_message(project, @user) }, remote: true, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from project' do
%i.fa.fa-times %i.fa.fa-times
#ssh-keys.tab-pane
- if @ssh_keys.any?
.panel.panel-default
%table.table
%thead.panel-heading
%tr
%th Title
%th Fingerprint
%th
%tbody
- @ssh_keys.each do |key|
%tr
%td
= link_to user_key_admin_user_path(@user, key) do
%strong= key.title
%td
%span
(#{key.fingerprint})
%span.cgray
added #{time_ago_with_tooltip(key.created_at)}
%td
= link_to 'Remove', remove_user_key_admin_user_path(@user, key), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-small btn-remove delete-key pull-right"
- else
.nothing-here-block User has no ssh keys
...@@ -84,6 +84,8 @@ Gitlab::Application.routes.draw do ...@@ -84,6 +84,8 @@ Gitlab::Application.routes.draw do
put :team_update put :team_update
put :block put :block
put :unblock put :unblock
get 'key/:key_id', action: 'show_key', as: 'user_key'
delete 'key/:key_id', action: 'remove_key', as: 'remove_user_key'
delete 'remove/:email_id', action: 'remove_email', as: 'remove_email' delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment