Repository: nifi Updated Branches: refs/heads/master 6a1854c97 -> 19302263c
[NIFI-3181] add operate palette actions to context menu. This closes #1516 Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/19302263 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/19302263 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/19302263 Branch: refs/heads/master Commit: 19302263c35c8f648feb378a0eaab4af43aa1366 Parents: 6a1854c Author: Scott Aslan <[email protected]> Authored: Fri Feb 17 12:02:56 2017 -0500 Committer: Matt Gilman <[email protected]> Committed: Fri Feb 17 15:40:23 2017 -0500 ---------------------------------------------------------------------- .../WEB-INF/partials/canvas/navigation.jsp | 4 +- .../nf-ng-canvas-graph-controls-controller.js | 20 ------- .../main/webapp/js/nf/canvas/nf-canvas-utils.js | 30 +++++++++- .../main/webapp/js/nf/canvas/nf-context-menu.js | 62 +++++++++++++++++++- 4 files changed, 90 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/19302263/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp index 1670dcf..6d97b0e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp @@ -98,7 +98,7 @@ <div class="button-spacer-small" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()"> </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"> </div> @@ -154,7 +154,7 @@ <div class="button-spacer-large"> </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"> </div> http://git-wip-us.apache.org/repos/asf/nifi/blob/19302263/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-graph-controls-controller.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-graph-controls-controller.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-graph-controls-controller.js index e7dedea..3274a48 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-graph-controls-controller.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-graph-controls-controller.js @@ -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; } } http://git-wip-us.apache.org/repos/asf/nifi/blob/19302263/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js index 4be7299..3e09a0e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js @@ -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)) { @@ -1077,6 +1081,26 @@ }, /** + * 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. * * @argument {selection} selection The selection http://git-wip-us.apache.org/repos/asf/nifi/blob/19302263/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js index ba0acb0..092297f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js @@ -86,6 +86,60 @@ }; /** + * 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. * * @param {selection} selection The selection of currently selected components @@ -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 = {
