Skip to content

Commit d6d729c

Browse files
ikavgodeadtrickster
authored andcommitted
ManagementUI - hide Delete button on queue details page if queue is protected
1 parent 64bee12 commit d6d729c

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

deps/rabbitmq_management/priv/www/js/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ function dispatcher_add(fun) {
7474
}
7575

7676
function dispatcher() {
77+
this.use('Title');
78+
this.setTitle('RabbitMQ - ');
7779
for (var i in dispatcher_modules) {
7880
dispatcher_modules[i](this);
7981
}
@@ -1763,6 +1765,10 @@ function select_queue_type(queuetype) {
17631765
update();
17641766
}
17651767

1768+
function is_internal(queue) {
1769+
return queue.internal;
1770+
}
1771+
17661772
function is_quorum(queue) {
17671773
if (queue["arguments"]) {
17681774
if (queue["arguments"]["x-queue-type"]) {

deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
</div>
196196
<% } %>
197197

198+
<% if (!is_internal(queue)) { %>
198199
<div class="section-hidden">
199200
<h2>Delete</h2>
200201
<div class="hider">
@@ -206,6 +207,7 @@
206207
</form>
207208
</div>
208209
</div>
210+
<% } %>
209211

210212
<% if (QUEUE_TYPE(queue).actions.purge) { %>
211213
<div class="section-hidden">

deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,15 @@ queue_with_totals(ReqData) ->
128128

129129
queue_with_totals(VHost, QName) ->
130130
Name = rabbit_misc:r(VHost, queue, QName),
131+
%% this somehow shares fields with mgmt_format:queue :-/
131132
case rabbit_amqqueue:lookup(Name) of
132133
{ok, Q} -> QueueInfo = rabbit_amqqueue:info(Q,
133134
[name, durable, auto_delete, exclusive,
134135
owner_pid, arguments, type, state,
135136
policy, totals, online, type_specific]),
137+
QueueInfo ++ [{internal, amqqueue:is_internal(Q)},
138+
{internal_owner, rabbit_mgmt_format:internal_owner(amqqueue:internal_owner(Q))}],
136139
rabbit_mgmt_format:queue_info(QueueInfo);
137140
{error, not_found} -> not_found
138141
end.
142+

deps/rabbitmq_management_agent/src/rabbit_mgmt_format.erl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-export([format/2, ip/1, ipb/1, amqp_table/1, tuple/1]).
1111
-export([parameter/1, now_to_str/0, now_to_str/1, strip_pids/1]).
1212
-export([protocol/1, resource/1, queue/1, queue/2, queue_state/1, queue_info/1]).
13-
-export([exchange/1, user/1, internal_user/1, binding/1, url/2]).
13+
-export([exchange/1, user/1, internal_user/1, binding/1, url/2, internal_owner/1]).
1414
-export([pack_binding_props/2, tokenise/1]).
1515
-export([to_amqp_table/1, listener/1, web_context/1, properties/1, basic_properties/1]).
1616
-export([record/2, to_basic_properties/1]).
@@ -392,10 +392,19 @@ queue(Q, Ctx) when ?is_amqqueue(Q) ->
392392
{exclusive, is_pid(ExclusiveOwner)},
393393
{owner_pid, ExclusiveOwner},
394394
{arguments, amqp_table(Arguments)},
395-
{pid, Pid}
395+
{pid, Pid},
396+
{internal, amqqueue:is_internal(Q)},
397+
{internal_owner, internal_owner(amqqueue:internal_owner(Q))}
396398
%% type specific stuff like, state, type, members etc is returned here
397399
| rabbit_queue_type:format(Q, Ctx)].
398400

401+
internal_owner(undefined) ->
402+
false;
403+
internal_owner(#resource{} = Owner) ->
404+
[{name, Owner#resource.name},
405+
{kind, Owner#resource.kind},
406+
{vhost, Owner#resource.virtual_host}].
407+
399408
queue_info(List) ->
400409
format(List, {fun format_exchange_and_queue/1, false}).
401410

0 commit comments

Comments
 (0)