ARTEMIS-3186 enable create-queue more often

* provide proper default when creating queues on anycast/multicast level
* allow queue creation on 3 levels (not 1)
* reformatted the shouldShow functions for readability
* force conscious decision on the routing type when creating address or queue
* do not need workspace as a parameter (4 out of 7 functions were already like that)
This commit is contained in:
Erwin Dondorp 2021-11-11 00:09:11 +01:00 committed by Justin Bertram
parent 27f09810b8
commit 754c569d08
No known key found for this signature in database
GPG Key ID: F41830B875BB8633
3 changed files with 47 additions and 19 deletions

View File

@ -57,7 +57,7 @@ var Artemis;
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary"
ng-click="$ctrl.createAddress($ctrl.addressName, $ctrl.routingType)"
ng-disabled="!$ctrl.addressName">Create Address
ng-disabled="!$ctrl.addressName || !$ctrl.routingType">Create Address
</button>
</div>
</div>
@ -92,7 +92,7 @@ var Artemis;
Artemis.log.debug("loaded address controller");
var ctrl = this;
ctrl.addressName = "";
ctrl.routingType = "Anycast";
ctrl.routingType = null;
ctrl.workspace = workspace;
ctrl.message = "";

View File

@ -91,7 +91,7 @@ var Artemis;
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary"
ng-click="$ctrl.createQueue($ctrl.queueName, $ctrl.routingType, $ctrl.durable, $ctrl.filter, $ctrl.maxConsumers, $ctrl.purgeWhenNoConsumers)"
ng-disabled="!$ctrl.queueName">Create Queue
ng-disabled="!$ctrl.queueName || !$ctrl.routingType">Create Queue
</button>
</div>
</div>
@ -160,7 +160,13 @@ var Artemis;
var artemisJmxDomain = localStorage['artemisJmxDomain'] || "org.apache.activemq.artemis";
ctrl.workspace = workspace;
ctrl.maxConsumers = -1;
ctrl.routingType = "Anycast";
if (workspace.selection.folderNames.length >= 6 && workspace.selection.folderNames[5] === "anycast") {
ctrl.routingType = "Anycast";
} else if (workspace.selection.folderNames.length >= 6 && workspace.selection.folderNames[5] === "multicast") {
ctrl.routingType = "Multicast";
} else {
ctrl.routingType = null;
}
ctrl.filter = "";
ctrl.purgeWhenNoConsumers = false;
ctrl.durable = true;
@ -184,8 +190,8 @@ var Artemis;
var mbean = Artemis.getBrokerMBean(workspace, jolokia);
if (mbean) {
var selection = workspace.selection;
var entries = selection.entries;
var address = entries["address"];
var folderNames = selection.folderNames;
var address = folderNames[3];
if (address.charAt(0) === '"' && address.charAt(address.length -1) === '"')
{
address = address.substr(1,address.length -2);

View File

@ -158,13 +158,13 @@ var Artemis;
if (shouldShowDeleteQueueTab()) {
tabs.push(new Nav.HawtioTab(TAB_CONFIG.deleteQueue.title, TAB_CONFIG.deleteQueue.route));
}
if (shouldShowSendMessageTab(workspace)) {
if (shouldShowSendMessageTab()) {
tabs.push(new Nav.HawtioTab(TAB_CONFIG.sendMessage.title, TAB_CONFIG.sendMessage.route));
}
if (shouldShowAddressSendMessageTab(workspace)) {
if (shouldShowAddressSendMessageTab()) {
tabs.push(new Nav.HawtioTab(TAB_CONFIG.addressSendMessage.title, TAB_CONFIG.addressSendMessage.route));
}
if (shouldShowBrowseMessageTab(workspace)) {
if (shouldShowBrowseMessageTab()) {
tabs.push(new Nav.HawtioTab(TAB_CONFIG.browseQueue.title, TAB_CONFIG.browseQueue.route));
}
tabs.push(new Nav.HawtioTab(TAB_CONFIG.brokerDiagram.title, TAB_CONFIG.brokerDiagram.route));
@ -173,31 +173,53 @@ var Artemis;
}
function shouldShowCreateAddressTab() {
return workspace.selectionHasDomainAndLastFolderName(artemisJmxDomain, 'addresses') && ctrl.showCreateAddress;
if (!workspace.selectionHasDomainAndLastFolderName(artemisJmxDomain, 'addresses')) return false;
if (!ctrl.showCreateAddress) return false;
return true;
}
function shouldShowDeleteAddressTab() {
return workspace.hasDomainAndProperties(artemisJmxDomain, {'component': 'addresses'}) && !workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && !workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'diverts'}) && ctrl.showDeleteAddress;
if (!workspace.hasDomainAndProperties(artemisJmxDomain, {'component': 'addresses'})) return false;
if (workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'})) return false;
if (workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'diverts'})) return false;
if (!ctrl.showDeleteAddress) return false;
return true;
}
function shouldShowCreateQueueTab() {
return workspace.hasDomainAndProperties(artemisJmxDomain, {'component': 'addresses'}) && !workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && !workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'diverts'}) && ctrl.showCreateQueue;
if (!workspace.selection) return false;
if (!workspace.selection.folderNames) return false;
if (workspace.selection.folderNames.length < 4 || workspace.selection.folderNames.length > 6) return false;
if (workspace.selection.folderNames[2] !== "addresses") return false;
if (workspace.selection.folderNames.length >= 5 && workspace.selection.folderNames[4] !== "queues") return false;
if (!ctrl.showCreateQueue) return false;
return true;
}
function shouldShowDeleteQueueTab() {
return workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && ctrl.showDeleteQueue;
if (!workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'})) return false;
if (!ctrl.showDeleteQueue) return false;
return true;
}
function shouldShowSendMessageTab(workspace) {
return workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && hasQueueinvokeRights(workspace, "sendMessage");
function shouldShowSendMessageTab() {
if (!workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'})) return false;
if (!hasQueueinvokeRights(workspace, "sendMessage")) return false;
return true;
}
function shouldShowAddressSendMessageTab(workspace) {
return workspace.hasDomainAndProperties(artemisJmxDomain, {'component': 'addresses'}) && !workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && hasQueueinvokeRights(workspace, "sendMessage");
function shouldShowAddressSendMessageTab() {
if (!workspace.hasDomainAndProperties(artemisJmxDomain, {'component': 'addresses'})) return false;
if (workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'})) return false;
if (!hasQueueinvokeRights(workspace, "sendMessage")) return false;
return true;
}
function shouldShowBrowseMessageTab(workspace) {
return workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && hasQueueinvokeRights(workspace, "browse") && hasQueueinvokeRights(workspace, "countMessages");
function shouldShowBrowseMessageTab() {
if (!workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'})) return false;
if (!hasQueueinvokeRights(workspace, "browse")) return false;
if (!hasQueueinvokeRights(workspace, "countMessages")) return false;
return true;
}
function hasInvokeRights(jolokia, mbean, operation) {