[NIFI-3181] add operate palette actions to context menu. This closes #1516

This commit is contained in:
Scott Aslan 2017-02-17 12:02:56 -05:00 committed by Matt Gilman
parent 6a1854c975
commit 19302263c3
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
4 changed files with 90 additions and 26 deletions

View File

@ -98,7 +98,7 @@
<div class="button-spacer-small" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()">&nbsp;</div>
<div id="operate-policy" class="action-button" title="Access Policies" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()">
<button ng-click="appCtrl.nf.Actions['managePolicies'](appCtrl.nf.CanvasUtils.getSelection());"
ng-disabled="!(appCtrl.serviceProvider.graphControlsCtrl.canManagePolicies())">
ng-disabled="!(appCtrl.nf.CanvasUtils.canManagePolicies())">
<div class="graph-control-action-icon fa fa-key"></div></button>
</div>
<div class="button-spacer-large">&nbsp;</div>
@ -154,7 +154,7 @@
<div class="button-spacer-large">&nbsp;</div>
<div id="operate-group" class="action-button" title="Group">
<button ng-click="appCtrl.nf.Actions['group'](appCtrl.nf.CanvasUtils.getSelection());"
ng-disabled="!appCtrl.nf.Connection.isDisconnected(appCtrl.nf.CanvasUtils.getSelection()) || !appCtrl.nf.CanvasUtils.canModify(appCtrl.nf.CanvasUtils.getSelection());">
ng-disabled="!(appCtrl.nf.CanvasUtils.getComponentByType('Connection').isDisconnected(appCtrl.nf.CanvasUtils.getSelection()) && appCtrl.nf.CanvasUtils.canModify(appCtrl.nf.CanvasUtils.getSelection()));">
<div class="graph-control-action-icon icon icon-group"></div></button>
</div>
<div class="button-spacer-large">&nbsp;</div>

View File

@ -348,26 +348,6 @@
} else if (canvasUtils.hasDetails(selection)) {
actions.showDetails(selection);
}
},
/**
* Determines whether the user can configure or open the policy management page.
*/
canManagePolicies: function () {
var selection = canvasUtils.getSelection();
// ensure 0 or 1 components selected
if (selection.size() <= 1) {
// if something is selected, ensure it's not a connection
if (!selection.empty() && canvasUtils.isConnection(selection)) {
return false;
}
// ensure access to read tenants
return common.canAccessTenants();
}
return false;
}
}

View File

@ -748,7 +748,7 @@
*/
areRunnable: function (selection) {
if (selection.empty()) {
return false;
return true;
}
var runnable = true;
@ -798,7 +798,7 @@
*/
areStoppable: function (selection) {
if (selection.empty()) {
return false;
return true;
}
var stoppable = true;
@ -1035,7 +1035,11 @@
isConfigurable: function (selection) {
// ensure the correct number of components are selected
if (selection.size() !== 1) {
return false;
if (selection.empty()) {
return true;
} else {
return false;
}
}
if (nfCanvasUtils.isProcessGroup(selection)) {
@ -1076,6 +1080,26 @@
return false;
},
/**
* Determines whether the user can configure or open the policy management page.
*/
canManagePolicies: function () {
var selection = nfCanvasUtils.getSelection();
// ensure 0 or 1 components selected
if (selection.size() <= 1) {
// if something is selected, ensure it's not a connection
if (!selection.empty() && nfCanvasUtils.isConnection(selection)) {
return false;
}
// ensure access to read tenants
return common.canAccessTenants();
}
return false;
},
/**
* Determines whether the components in the specified selection are writable.
*

View File

@ -85,6 +85,60 @@
return canvasUtils.areDeletable(selection);
};
/**
* Determines whether user can create a template from the components in the specified selection.
*
* @param {selection} selection The selection of currently selected components
*/
var canCreateTemplate = function (selection) {
return canvasUtils.canWrite() && (selection.empty() && canvasUtils.canRead(selection));
};
/**
* Determines whether user can upload a template.
*
* @param {selection} selection The selection of currently selected components
*/
var canUploadTemplate = function (selection) {
return canvasUtils.canWrite() && selection.empty();
};
/**
* Determines whether components in the specified selection are group-able.
*
* @param {selection} selection The selection of currently selected components
*/
var canGroup = function (selection) {
return canvasUtils.getComponentByType('Connection').isDisconnected(selection) && canvasUtils.canModify(selection);
};
/**
* Determines whether components in the specified selection are enable-able.
*
* @param {selection} selection The selection of currently selected components
*/
var canEnable = function (selection) {
return canvasUtils.canEnable(selection);
};
/**
* Determines whether components in the specified selection are diable-able.
*
* @param {selection} selection The selection of currently selected components
*/
var canDisable = function (selection) {
return canvasUtils.canDisable(selection);
};
/**
* Determines whether user can manage policies of the components in the specified selection.
*
* @param {selection} selection The selection of currently selected components
*/
var canManagePolicies = function (selection) {
return canvasUtils.isConfigurableAuthorizer() && canvasUtils.canManagePolicies(selection);
};
/**
* Determines whether the components in the specified selection are runnable.
*
@ -453,6 +507,9 @@
{condition: isProcessGroup, menuItem: {clazz: 'fa fa-sign-in', text: 'Enter group', action: 'enterGroup'}},
{condition: isRunnable, menuItem: {clazz: 'fa fa-play', text: 'Start', action: 'start'}},
{condition: isStoppable, menuItem: {clazz: 'fa fa-stop', text: 'Stop', action: 'stop'}},
{condition: canEnable, menuItem: {clazz: 'fa fa-flash', text: 'Enable', action: 'enable'}},
{condition: canDisable, menuItem: {clazz: 'icon icon-enable-false', text: 'Disable', action: 'disable'}},
{condition: canGroup, menuItem: {clazz: 'icon icon-group', text: 'Group', action: 'group'}},
{condition: isRemoteProcessGroup, menuItem: {clazz: 'fa fa-cloud', text: 'Remote ports', action: 'remotePorts'}},
{condition: canStartTransmission, menuItem: {clazz: 'fa fa-bullseye', text: 'Enable transmission', action: 'enableTransmission'}},
{condition: canStopTransmission, menuItem: { clazz: 'icon icon-transmit-false', text: 'Disable transmission', action: 'disableTransmission'}},
@ -475,8 +532,11 @@
{condition: canListQueue, menuItem: {clazz: 'fa fa-list', text: 'List queue', action: 'listQueue'}},
{condition: canEmptyQueue, menuItem: {clazz: 'fa fa-minus-circle', text: 'Empty queue', action: 'emptyQueue'}},
{condition: isDeletable, menuItem: {clazz: 'fa fa-trash', text: 'Delete', action: 'delete'}},
{condition: canManagePolicies, menuItem: {clazz: 'fa fa-key', text: 'Access policies', action: 'managePolicies'}},
{condition: canAlign, menuItem: {clazz: 'fa fa-align-center', text: 'Align vertical', action: 'alignVertical'}},
{condition: canAlign, menuItem: { clazz: 'fa fa-align-center fa-rotate-90', text: 'Align horizontal', action: 'alignHorizontal'}}
{condition: canAlign, menuItem: { clazz: 'fa fa-align-center fa-rotate-90', text: 'Align horizontal', action: 'alignHorizontal'}},
{condition: canUploadTemplate, menuItem: {clazz: 'icon icon-template-import', text: 'Upload template', action: 'uploadTemplate'}},
{condition: canCreateTemplate, menuItem: {clazz: 'icon icon-template-save', text: 'Create template', action: 'template'}}
];
var nfContextMenu = {