Commit bdcba438 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'project-deploy-keys-ui' into 'master'

Project deploy keys updated UI

Closes #13992

See merge request !3912
parents ed08bfdc 54493b9a
...@@ -202,8 +202,31 @@ ...@@ -202,8 +202,31 @@
min-width: 200px; min-width: 200px;
} }
.deploy-project-label { .deploy-key-content {
margin: 1px; @media (min-width: $screen-sm-min) {
float: left;
&:last-child {
float: right;
}
}
}
.deploy-key-projects {
@media (min-width: $screen-sm-min) {
line-height: 42px;
}
}
a.deploy-project-label {
padding: 5px;
margin-right: 5px;
color: $gl-gray;
background-color: $row-hover;
&:hover {
color: $gl-link-color;
}
} }
.vs-public { .vs-public {
......
...@@ -7,31 +7,24 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -7,31 +7,24 @@ class Projects::DeployKeysController < Projects::ApplicationController
layout "project_settings" layout "project_settings"
def index def index
@enabled_keys = @project.deploy_keys @key = DeployKey.new
set_index_vars
@available_keys = accessible_keys - @enabled_keys
@available_project_keys = current_user.project_deploy_keys - @enabled_keys
@available_public_keys = DeployKey.are_public - @enabled_keys
# Public keys that are already used by another accessible project are already
# in @available_project_keys.
@available_public_keys -= @available_project_keys
end end
def new def new
@key = @project.deploy_keys.new redirect_to namespace_project_deploy_keys_path(@project.namespace,
@project)
respond_with(@key)
end end
def create def create
@key = DeployKey.new(deploy_key_params) @key = DeployKey.new(deploy_key_params)
set_index_vars
if @key.valid? && @project.deploy_keys << @key if @key.valid? && @project.deploy_keys << @key
redirect_to namespace_project_deploy_keys_path(@project.namespace, redirect_to namespace_project_deploy_keys_path(@project.namespace,
@project) @project)
else else
render "new" render "index"
end end
end end
...@@ -51,6 +44,18 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -51,6 +44,18 @@ class Projects::DeployKeysController < Projects::ApplicationController
protected protected
def set_index_vars
@enabled_keys ||= @project.deploy_keys
@available_keys ||= accessible_keys - @enabled_keys
@available_project_keys ||= current_user.project_deploy_keys - @enabled_keys
@available_public_keys ||= DeployKey.are_public - @enabled_keys
# Public keys that are already used by another accessible project are already
# in @available_project_keys.
@available_public_keys -= @available_project_keys
end
def accessible_keys def accessible_keys
@accessible_keys ||= current_user.accessible_deploy_keys @accessible_keys ||= current_user.accessible_deploy_keys
end end
......
%li %li
.pull-right .pull-left.append-right-10.hidden-xs
= icon "key", class: "key-icon"
.deploy-key-content.key-list-item-info
%strong.title
= deploy_key.title
.description
= deploy_key.fingerprint
.deploy-key-content.prepend-left-default.deploy-key-projects
- deploy_key.projects.each do |project|
- if can?(current_user, :read_project, project)
= link_to namespace_project_path(project.namespace, project), class: "label deploy-project-label" do
= project.name_with_namespace
.deploy-key-content
%span.key-created-at
created #{time_ago_with_tooltip(deploy_key.created_at)}
.visible-xs-block.visible-sm-block
- if @available_keys.include?(deploy_key) - if @available_keys.include?(deploy_key)
= link_to enable_namespace_project_deploy_key_path(@project.namespace, @project, deploy_key), class: 'btn btn-sm', method: :put do = link_to enable_namespace_project_deploy_key_path(@project.namespace, @project, deploy_key), class: "btn btn-sm prepend-left-10", method: :put do
= icon('plus')
Enable Enable
- else - else
- if deploy_key.destroyed_when_orphaned? && deploy_key.almost_orphaned? - if deploy_key.destroyed_when_orphaned? && deploy_key.almost_orphaned?
= link_to 'Remove', disable_namespace_project_deploy_key_path(@project.namespace, @project, deploy_key), data: { confirm: 'You are going to remove deploy key. Are you sure?'}, method: :put, class: "btn btn-remove delete-key btn-sm pull-right" = link_to disable_namespace_project_deploy_key_path(@project.namespace, @project, deploy_key), data: { confirm: "You are going to remove deploy key. Are you sure?" }, method: :put, class: "btn btn-warning btn-sm prepend-left-10" do
Remove
- else - else
= link_to disable_namespace_project_deploy_key_path(@project.namespace, @project, deploy_key), class: 'btn btn-sm', method: :put do = link_to disable_namespace_project_deploy_key_path(@project.namespace, @project, deploy_key), class: "btn btn-warning btn-sm prepend-left-10", method: :put do
= icon('power-off')
Disable Disable
= icon('key')
%strong= deploy_key.title
%br
%code.key-fingerprint= deploy_key.fingerprint
%p.light.prepend-top-10
- if deploy_key.public?
%span.label.label-info.deploy-project-label
Public deploy key
- deploy_key.projects.each do |project|
- if can?(current_user, :read_project, project)
%span.label.label-gray.deploy-project-label
= link_to namespace_project_path(project.namespace, project) do
= project.name_with_namespace
%small.pull-right
Created #{time_ago_with_tooltip(deploy_key.created_at)}
%div = form_for [@project.namespace.becomes(Namespace), @project, @key], url: namespace_project_deploy_keys_path, html: { class: "js-requires-input" } do |f|
= form_for [@project.namespace.becomes(Namespace), @project, @key], url: namespace_project_deploy_keys_path, html: { class: 'deploy-key-form form-horizontal js-requires-input' } do |f|
= form_errors(@key) = form_errors(@key)
.form-group .form-group
= f.label :title, class: "control-label" = f.label :title, class: "label-light"
.col-sm-10= f.text_field :title, class: 'form-control', autofocus: true, required: true = f.text_field :title, class: 'form-control', autofocus: true, required: true
.form-group .form-group
= f.label :key, class: "control-label" = f.label :key, class: "label-light"
.col-sm-10 = f.text_area :key, class: "form-control", rows: 5, required: true
%p.light .form-group
%p.light.append-bottom-0
Paste a machine public key here. Read more about how to generate it Paste a machine public key here. Read more about how to generate it
= link_to "here", help_page_path("ssh", "README") = link_to "here", help_page_path("ssh", "README")
= f.text_area :key, class: "form-control thin_area", rows: 5, required: true = f.submit "Add key", class: "btn-create btn"
.form-actions
= f.submit 'Create Deploy Key', class: "btn-create btn"
= link_to "Cancel", namespace_project_deploy_keys_path(@project.namespace, @project), class: "btn btn-cancel"
- page_title "Deploy Keys" - page_title "Deploy Keys"
%h3.page-title .row.prepend-top-default
Deploy keys allow read-only access to the repository .col-lg-3.profile-settings-sidebar
%h4.prepend-top-0
= link_to new_namespace_project_deploy_key_path(@project.namespace, @project), class: "btn btn-new pull-right", title: "New Deploy Key" do = page_title
%i.fa.fa-plus %p
New Deploy Key Deploy keys allow read-only access to your repository. Deploy keys can be used for CI, staging or production servers. You can create a deploy key or add an existing one.
.col-lg-9
%p.light %h5.prepend-top-0
Deploy keys can be used for CI, staging or production servers. Create a new deploy key for this project
You can create a deploy key or add an existing one = render "form"
.col-lg-9.col-lg-offset-3
%hr.clearfix %hr
.col-lg-9.col-lg-offset-3.append-bottom-default.deploy-keys
.row %h5.prepend-top-0
.col-md-6.enabled-keys Enabled deploy keys for this project (#{@enabled_keys.size})
%h5 - if @enabled_keys.any?
%strong.cgreen Enabled deploy keys %ul.well-list
for this project
%ul.bordered-list
= render @enabled_keys = render @enabled_keys
- if @enabled_keys.blank? - else
.light-well .profile-settings-message.text-center
.nothing-here-block Create a #{link_to 'new deploy key', new_namespace_project_deploy_key_path(@project.namespace, @project)} or add an existing one No deploy keys found. Create one with the form above or add existing one below.
.col-md-6.available-keys %h5.prepend-top-default
- # If there are available public deploy keys but no available project deploy keys, only public deploy keys are shown. Deploy keys from projects you have access to (#{@available_project_keys.size})
- if @available_project_keys.any? || @available_public_keys.blank? - if @available_project_keys.any?
%h5 %ul.well-list
%strong Deploy keys
from projects you have access to
%ul.bordered-list
= render @available_project_keys = render @available_project_keys
- if @available_project_keys.blank? - else
.light-well .profile-settings-message.text-center
.nothing-here-block Deploy keys from projects you have access to will be displayed here No deploy keys from your projects could be found. Create one with the form above or add existing one below.
- if @available_public_keys.any? - if @available_public_keys.any?
%h5 %h5.prepend-top-default
%strong Public deploy keys Public deploy keys available to any project (#{@available_public_keys.size})
available to any project %ul.well-list
%ul.bordered-list
= render @available_public_keys = render @available_public_keys
...@@ -21,7 +21,6 @@ Feature: Project Deploy Keys ...@@ -21,7 +21,6 @@ Feature: Project Deploy Keys
Scenario: I add new deploy key Scenario: I add new deploy key
Given I visit project deploy keys page Given I visit project deploy keys page
When I click 'New Deploy Key'
And I submit new deploy key And I submit new deploy key
Then I should be on deploy keys page Then I should be on deploy keys page
And I should see newly created deploy key And I should see newly created deploy key
......
...@@ -8,19 +8,19 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -8,19 +8,19 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end end
step 'I should see project deploy key' do step 'I should see project deploy key' do
page.within '.enabled-keys' do page.within '.deploy-keys' do
expect(page).to have_content deploy_key.title expect(page).to have_content deploy_key.title
end end
end end
step 'I should see other project deploy key' do step 'I should see other project deploy key' do
page.within '.available-keys' do page.within '.deploy-keys' do
expect(page).to have_content other_deploy_key.title expect(page).to have_content other_deploy_key.title
end end
end end
step 'I should see public deploy key' do step 'I should see public deploy key' do
page.within '.available-keys' do page.within '.deploy-keys' do
expect(page).to have_content public_deploy_key.title expect(page).to have_content public_deploy_key.title
end end
end end
...@@ -32,7 +32,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -32,7 +32,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
step 'I submit new deploy key' do step 'I submit new deploy key' do
fill_in "deploy_key_title", with: "laptop" fill_in "deploy_key_title", with: "laptop"
fill_in "deploy_key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop" fill_in "deploy_key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop"
click_button "Create" click_button "Add key"
end end
step 'I should be on deploy keys page' do step 'I should be on deploy keys page' do
...@@ -40,7 +40,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -40,7 +40,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end end
step 'I should see newly created deploy key' do step 'I should see newly created deploy key' do
page.within '.enabled-keys' do page.within '.deploy-keys' do
expect(page).to have_content(deploy_key.title) expect(page).to have_content(deploy_key.title)
end end
end end
...@@ -56,7 +56,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -56,7 +56,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end end
step 'I should only see the same deploy key once' do step 'I should only see the same deploy key once' do
page.within '.available-keys' do page.within '.deploy-keys' do
expect(page).to have_selector('ul li', count: 1) expect(page).to have_selector('ul li', count: 1)
end end
end end
...@@ -66,7 +66,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -66,7 +66,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end end
step 'I click attach deploy key' do step 'I click attach deploy key' do
page.within '.available-keys' do page.within '.deploy-keys' do
click_link 'Enable' click_link 'Enable'
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