Protected queues - do not render Delete button for internal queues

with fix for rabbit_mgmt_wm_queue by MK
This commit is contained in:
Iliia Khaprov 2025-05-18 23:23:55 +02:00
parent abe306ed8e
commit 5fd3bddcfe
No known key found for this signature in database
GPG Key ID: 4DCFF8F358E49AED
4 changed files with 22 additions and 4 deletions

View File

@ -1759,6 +1759,10 @@ function select_queue_type(queuetype) {
update(); update();
} }
function is_internal(queue) {
return queue.internal;
}
function get_queue_type (queue) { function get_queue_type (queue) {
return queue.type; return queue.type;
} }

View File

@ -395,6 +395,7 @@
</div> </div>
<% } %> <% } %>
<% if (!is_internal(queue)) { %>
<div class="section-hidden" id="delete"> <div class="section-hidden" id="delete">
<h2>Delete</h2> <h2>Delete</h2>
<div class="hider"> <div class="hider">
@ -406,6 +407,7 @@
</form> </form>
</div> </div>
</div> </div>
<% } %>
<% if (!is_stream(queue)) { %> <% if (!is_stream(queue)) { %>
<div class="section-hidden"> <div class="section-hidden">

View File

@ -128,11 +128,14 @@ queue_with_totals(ReqData) ->
queue_with_totals(VHost, QName) -> queue_with_totals(VHost, QName) ->
Name = rabbit_misc:r(VHost, queue, QName), Name = rabbit_misc:r(VHost, queue, QName),
%% this somehow shares fields with mgmt_format:queue :-/
case rabbit_amqqueue:lookup(Name) of case rabbit_amqqueue:lookup(Name) of
{ok, Q} -> QueueInfo = rabbit_amqqueue:info(Q, {ok, Q} -> QueueInfo0 = rabbit_amqqueue:info(Q,
[name, durable, auto_delete, exclusive, [name, durable, auto_delete, exclusive,
owner_pid, arguments, type, state, owner_pid, arguments, type, state,
policy, totals, online, type_specific]), policy, totals, online, type_specific]),
rabbit_mgmt_format:queue_info(QueueInfo); QueueInfo1 = QueueInfo0 ++ [{internal, amqqueue:is_internal(Q)},
{internal_owner, rabbit_mgmt_format:internal_owner(amqqueue:internal_owner(Q))}],
rabbit_mgmt_format:queue_info(QueueInfo1);
{error, not_found} -> not_found {error, not_found} -> not_found
end. end.

View File

@ -10,7 +10,7 @@
-export([format/2, ip/1, ipb/1, amqp_table/1, tuple/1]). -export([format/2, ip/1, ipb/1, amqp_table/1, tuple/1]).
-export([parameter/1, now_to_str/0, now_to_str/1, strip_pids/1]). -export([parameter/1, now_to_str/0, now_to_str/1, strip_pids/1]).
-export([protocol/1, resource/1, queue/1, queue/2, queue_state/1, queue_info/1]). -export([protocol/1, resource/1, queue/1, queue/2, queue_state/1, queue_info/1]).
-export([exchange/1, user/1, internal_user/1, binding/1, url/2]). -export([exchange/1, user/1, internal_user/1, binding/1, url/2, internal_owner/1]).
-export([pack_binding_props/2, tokenise/1]). -export([pack_binding_props/2, tokenise/1]).
-export([to_amqp_table/1, listener/1, web_context/1, properties/1, basic_properties/1]). -export([to_amqp_table/1, listener/1, web_context/1, properties/1, basic_properties/1]).
-export([record/2, to_basic_properties/1]). -export([record/2, to_basic_properties/1]).
@ -401,10 +401,19 @@ queue(Q, Ctx) when ?is_amqqueue(Q) ->
{exclusive, is_pid(ExclusiveOwner)}, {exclusive, is_pid(ExclusiveOwner)},
{owner_pid, ExclusiveOwner}, {owner_pid, ExclusiveOwner},
{arguments, amqp_table(Arguments)}, {arguments, amqp_table(Arguments)},
{pid, Pid} {pid, Pid},
{internal, amqqueue:is_internal(Q)},
{internal_owner, internal_owner(amqqueue:internal_owner(Q))}
%% type specific stuff like, state, type, members etc is returned here %% type specific stuff like, state, type, members etc is returned here
| rabbit_queue_type:format(Q, Ctx)]. | rabbit_queue_type:format(Q, Ctx)].
internal_owner(undefined) ->
false;
internal_owner(#resource{} = Owner) ->
[{name, Owner#resource.name},
{kind, Owner#resource.kind},
{vhost, Owner#resource.virtual_host}].
queue_info(List) -> queue_info(List) ->
format(List, {fun format_exchange_and_queue/1, false}). format(List, {fun format_exchange_and_queue/1, false}).