Commit 2f76a90f authored by o's avatar o

separate reserved emails and deleted resources + resource deletion undo

parent 24181be6
Pipeline #4719 passed with stages
in 20 minutes and 1 second
......@@ -357,6 +357,10 @@ module ApiBackend
post(['resource', 'purge'], {uid: uid})
end
def resource_undelete(uid)
post(['resource', 'undelete'], {uid: uid})
end
def resource_delete(uid)
post(['resource', 'delete'], {uid: uid})
end
......@@ -368,6 +372,14 @@ module ApiBackend
def resource_remove_owner(uid, user)
post(['resource', 'remove_owner'], {uid: uid, owner: user})
end
def reserved_identifiers()
get ['users_admin', 'reserved_identifiers']
end
def release_reserved_identifier(kind, id)
post(['users_admin', 'release_reserved_identifier'], {release: {kind => id}})
end
end
def api
......
class ReservedIdentifiersController < ApplicationController
include ApiBackend
def resource_list
['schleuder', 'mailman']
end
helper_method :resource_list
def show
begin
@resource_name = params[:resource_name]
if !['email'].include? @resource_name
@resource_name = 'email'
end
@reserved_identifiers = api.reserved_identifiers
rescue ApiBackend::ApiError
flash[:danger] = :failed
redirect_to root_path
end
end
def release
api.release_reserved_identifier(params[:resource_name], params[:identifier])
redirect_to :reserved_identifiers
rescue ApiError => e
flash[:danger] = e.api_msg
redirect_to :reserved_identifiers
end
end
......@@ -39,6 +39,9 @@ class ResourcesAdminController < ApplicationController
elsif params[:purge].present?
@res = api.resource_purge(uid)
@resource_action='deleted'
elsif params[:undelete].present?
@res = api.resource_undelete(uid)
@resource_action='deleted'
elsif params[:create].present?
if resource_list.include? @resource_name
data = {}
......
......@@ -4,6 +4,7 @@
users: {label: :manage_users},
domains: {label: :manage_domains},
resources_admin: {},
reserved_identifiers: {},
jabber_ids: {label: :manage_jabber_ids},
jabber_domains: {label: :manage_jabber_domains},
} %>
......
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<% ['email'].each do |pane| %>
<a class="nav-item nav-link <%= if pane == @resource_name then "active" else "" end %>"
href="?resource_name=<%= pane %>"
role="tab">
<%= pane %>
</a>
<% end %>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane show active" role="tabpanel">
<p><ul>
<% @reserved_identifiers[@resource_name].each do |res| %>
<li>
<%= res %>
<% resource_ui_id = SecureRandom.hex(32) %>
<%= form_tag do %>
<%= hidden_field_tag 'resource_name', @resource_name %>
<%= hidden_field_tag 'identifier', res %>
<button type="button" class="btn btn-warning" onclick="
style.display='none';
document.getElementById('delete_<%= resource_ui_id %>').style.display='inline';
"><%= t :delete %></button>
<%= submit_tag(t(:delete),
name: "delete",
id: "delete_#{resource_ui_id}",
class: "btn btn-danger", style: "display:none") %>
<% end %>
</li>
<% end %>
</ul></p>
</div>
</div>
params:
<pre>
<%= @params.to_yaml %>
</pre>
res:
<pre>
<%= @res.to_yaml %>
</pre>
......@@ -8,7 +8,7 @@
<%= hidden_field_tag 'uid', res['uid'] %>
<div class="tooltipsummary">
<b><%= res['resource']['email'] %></b>
<b><%= res['uid'].split(":")[1..-1].join(":") %></b>
<span class="tooltiptext"><%= res['resource'].to_json %></span>
</div>
......
......@@ -7,7 +7,7 @@
<%= hidden_field_tag 'uid', res['uid'] %>
<div class="tooltipsummary">
<b><%= res['email'] %></b>
<b><%= res['uid'].split(":")[1..-1].join(":") %></b>
<% if res['resource'].present? %>
<span class="tooltiptext"><%= res['resource'].to_json %></span>
<% end %>
......@@ -24,5 +24,6 @@
name: "purge",
id: "purge_#{resource_ui_id}",
class: "btn btn-danger", style: "display:none") %>
<%= submit_tag(t(:undelete), name: 'undelete', class: "btn btn-primary") %>
<% end %>
<% end %>
......@@ -107,6 +107,9 @@ Rails.application.routes.draw do
post '/resources_admin', to: 'resources_admin#update'
end
get '/reserved_identifiers', to: 'reserved_identifiers#show'
post '/reserved_identifiers', to: 'reserved_identifiers#release'
get '/invites', to: 'invites#generate'
post '/invites', to: 'invites#show'
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