Commit ed56d9ba authored by Stan Hu's avatar Stan Hu

Add ability to edit a GeoNode

If you get the primary URL wrong, there's no way to recover. This change
also makes it possible to remove nodes, as long as the node isn't a secondary.

Closes #2856
parent 85608902
class Admin::GeoNodesController < Admin::ApplicationController
before_action :check_license, except: [:index, :destroy]
before_action :load_node, only: [:destroy, :repair, :toggle, :status]
before_action :load_node, only: [:destroy, :edit, :update, :repair, :toggle, :status]
def index
@nodes = GeoNode.all.order(:id)
......@@ -22,6 +22,15 @@ class Admin::GeoNodesController < Admin::ApplicationController
end
end
def update
if @node.update_attributes(geo_node_params.except(:geo_node_key_attributes))
flash[:notice] = 'GeoNode was successfully updated.'
redirect_to admin_geo_nodes_path
else
render 'edit'
end
end
def destroy
@node.destroy
......
= form_for geo_node, as: :geo_node, url: admin_geo_nodes_path, html: { class: 'form-horizontal' } do |f|
- if geo_node.errors.any?
.alert.alert-danger
- geo_node.errors.full_messages.each do |msg|
%p= msg
- disable_key_edit = defined?(edit) && edit
- if geo_node.errors.any?
.alert.alert-danger
- geo_node.errors.full_messages.each do |msg|
%p= msg
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= form.label :primary do
= form.check_box :primary
%strong This is a primary node
.form-group
= form.label :url, 'URL', class: 'control-label'
.col-sm-10
= form.text_field :url, class: 'form-control'
= form.fields_for :geo_node_key, geo_node.geo_node_key, include_id: !disable_key_edit do |fg|
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :primary do
= f.check_box :primary
%strong This is a primary node
.form-group
= f.label :url, 'URL', class: 'control-label'
= fg.label :key, 'Public Key', class: 'control-label'
.col-sm-10
= f.text_field :url, class: 'form-control'
= f.fields_for :geo_node_key, geo_node.geo_node_key do |fg|
.form-group
= fg.label :key, 'Public Key', class: 'control-label'
.col-sm-10
= fg.text_area :key, class: 'form-control thin_area', rows: 5
= fg.text_area :key, class: 'form-control thin_area', rows: 5, disabled: disable_key_edit
- unless disable_key_edit
%p.help-block
Paste a machine public key here for the GitLab user this node runs on. Read more about how to generate it
= link_to "here", help_page_path("ssh/README")
.form-actions
= f.submit 'Add Node', class: 'btn btn-create'
%hr
- page_title 'Edit Geo Node'
%h3.page-title
Edit Geo Node
= form_for [:admin, @node], html: { class: 'form-horizontal' } do |f|
= render partial: 'form', locals: { form: f, geo_node: @node, edit: true }
.form-actions
= f.submit 'Save changes', class: 'btn btn-create'
= link_to 'Cancel', admin_geo_nodes_path, class: 'btn btn-cancel'
%hr
......@@ -8,7 +8,13 @@
%hr
= render partial: 'form', locals: {geo_node: @node} if Gitlab::Geo.license_allows?
- if Gitlab::Geo.license_allows?
= form_for [:admin, @node], as: :geo_node, url: admin_geo_nodes_path, html: { class: 'form-horizontal' } do |f|
= render partial: 'form', locals: { form: f, geo_node: @node, add_key: true }
.form-actions
= f.submit 'Add Node', class: 'btn btn-create'
%hr
- if @nodes.any?
.panel.panel-default
......@@ -52,11 +58,12 @@
%p
.js-health
- if Gitlab::Geo.primary?
- unless Gitlab::Geo.secondary?
.node-actions
- if Gitlab::Geo.license_allows?
- if node.missing_oauth_application?
= link_to "Repair authentication", repair_admin_geo_node_path(node), method: :post, title: 'OAuth application is missing', class: 'btn btn-default btn-sm'
- if node.secondary?
= toggle_node_button(node)
= link_to "Edit", edit_admin_geo_node_path(node), class: 'btn btn-sm'
= link_to "Remove", admin_geo_node_path(node), data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-remove btn-sm'
......@@ -125,7 +125,7 @@ namespace :admin do
get :download, on: :member
end
resources :geo_nodes, only: [:index, :create, :destroy] do
resources :geo_nodes, only: [:index, :create, :edit, :update, :destroy] do
member do
post :repair
post :toggle
......
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