From 19302263c35c8f648feb378a0eaab4af43aa1366 Mon Sep 17 00:00:00 2001 From: Scott Aslan Date: Fri, 17 Feb 2017 12:02:56 -0500 Subject: [PATCH] [NIFI-3181] add operate palette actions to context menu. This closes #1516 --- .../WEB-INF/partials/canvas/navigation.jsp | 4 +- .../nf-ng-canvas-graph-controls-controller.js | 20 ------ .../webapp/js/nf/canvas/nf-canvas-utils.js | 30 ++++++++- .../webapp/js/nf/canvas/nf-context-menu.js | 62 ++++++++++++++++++- 4 files changed, 90 insertions(+), 26 deletions(-) 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 1670dcf9fb..6d97b0e7f1 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 @@
 
 
@@ -154,7 +154,7 @@
 
 
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 e7dedeab77..3274a48562 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; } } 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 4be72993a9..3e09a0e115 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)) { @@ -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. * 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 ba0acb06fb..092297f4ee 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 @@ -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 = {