You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sc...@apache.org on 2019/09/12 17:24:27 UTC

[nifi] branch master updated: NIFI-6630 - Add a goto action in the property table for properties that reference parameters.

This is an automated email from the ASF dual-hosted git repository.

scottyaslan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 75c4738  NIFI-6630 - Add a goto action in the property table for properties that reference parameters.
75c4738 is described below

commit 75c47388a611a2bb3ef398ad331cb0d05a88acd6
Author: Rob Fellows <ro...@gmail.com>
AuthorDate: Tue Sep 10 14:47:06 2019 -0400

    NIFI-6630 - Add a goto action in the property table for properties that reference parameters.
    
    NIFI-6630 - base convert and goto parameter logic on any reference to a parameter contained in the text of the property value.
    
    This closes #3718
    
    Signed-off-by: Scott Aslan <sc...@gmail.com>
---
 .../jquery/propertytable/jquery.propertytable.js   | 45 +++++++++++++++++-----
 .../webapp/js/nf/canvas/nf-controller-service.js   | 41 ++++++++++++--------
 .../webapp/js/nf/canvas/nf-parameter-contexts.js   |  9 +++--
 .../src/main/webapp/js/nf/nf-processor-details.js  | 21 ++++++----
 4 files changed, 79 insertions(+), 37 deletions(-)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
index b09bf57..0b34bd1 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
@@ -127,6 +127,11 @@
         return false;
     };
 
+    var containsParameterReference = function (value) {
+        var paramRefsRegex = /#{[a-zA-Z0-9-_. ]+}/;
+        return paramRefsRegex.test(value);
+    };
+
     var getSupportTip = function (isEl, isSupported) {
         var supportContainer = $('<div></div>');
 
@@ -1362,16 +1367,22 @@
                 });
             }
 
-            if (options.readOnly !== true) {
-                var canConvertPropertyToParam = false;
-                if (_.isFunction(options.getParameterContext)) {
-                    var paramContext = options.getParameterContext(groupId);
-                    var canWriteParamContext = _.get(paramContext, 'permissions.canWrite', false);
-                    var canReadParamContext = _.get(paramContext, 'permissions.canRead', false);
-                    canConvertPropertyToParam = canWriteParamContext && canReadParamContext;
-                }
-                var referencesParam = referencesParameter(dataContext.value);
+            var referencesParam = containsParameterReference(dataContext.value);
+            var canConvertPropertyToParam = false;
+            var canReadParamContext = false;
 
+            if (_.isFunction(options.getParameterContext)) {
+                var paramContext = options.getParameterContext(groupId);
+                var canWriteParamContext = _.get(paramContext, 'permissions.canWrite', false);
+                canReadParamContext = _.get(paramContext, 'permissions.canRead', false);
+                canConvertPropertyToParam = canWriteParamContext && canReadParamContext;
+            }
+
+            if (referencesParam && canReadParamContext) {
+                markup += '<div title="Go to parameter" class="goto-to-parameter pointer fa fa-long-arrow-right"></div>';
+            }
+
+            if (options.readOnly !== true) {
                 if (canConvertPropertyToParam && !referencesParam && !identifiesControllerService) {
                     markup += '<div title="Convert to parameter" class="convert-to-parameter pointer fa fa-level-up"></div>';
                 }
@@ -1596,6 +1607,22 @@
                                 propertyData.updateItem(property.id, updatedItem);
                             });
                     }
+                } else if (target.hasClass('goto-to-parameter')) {
+                    var parameterContext;
+                    if (_.isFunction(options.getParameterContext)) {
+                        parameterContext = options.getParameterContext(groupId);
+                        var canReadParamContext = _.get(parameterContext, 'permissions.canRead', false);
+
+                        if (canReadParamContext && !_.isNil(property.value)) {
+                            // get the reference parameter
+                            var paramRefsRegex = /#{([a-zA-Z0-9-_. ]+)}/;
+                            var result = property.value.match(paramRefsRegex);
+                            if (!_.isEmpty(result) && result.length === 2) {
+                                var parameterName = result[1];
+                                nfParameterContexts.showParameterContext(parameterContext.id, null, parameterName);
+                            }
+                        }
+                    }
                 }
             }
         });
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
index 14a9280..f88c660 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
@@ -1589,6 +1589,25 @@
         }).promise();
     };
 
+    var getParameterContext = function (groupId, controllerServiceEntity) {
+        if (_.isNil(controllerServiceEntity.parentGroupId)) {
+            return null;
+        }
+
+        var parameterContext;
+
+        // attempt to identify the parameter context, conditional based on whether
+        // the user is configuring the current process group
+        if (_.isNil(groupId) || groupId === nfCanvasUtils.getGroupId()) {
+            parameterContext = nfCanvasUtils.getParameterContext();
+        } else {
+            var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId);
+            parameterContext = parentProcessGroup.parameterContext;
+        }
+
+        return parameterContext;
+    };
+
     var saveControllerService = function (serviceTable, controllerServiceEntity) {
         // marshal the settings and properties and update the controller service
         var updatedControllerService = marshalDetails();
@@ -1877,22 +1896,7 @@
                         return goToServiceFromProperty(serviceTable);
                     },
                     getParameterContext: function (groupId) {
-                        if (_.isNil(controllerServiceEntity.parentGroupId)) {
-                            return null;
-                        }
-
-                        var parameterContext;
-
-                        // attempt to identify the parameter context, conditional based on whether
-                        // the user is configuring the current process group
-                        if (_.isNil(groupId) || groupId === nfCanvasUtils.getGroupId()) {
-                            parameterContext = nfCanvasUtils.getParameterContext();
-                        } else {
-                            var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId);
-                            parameterContext = parentProcessGroup.parameterContext;
-                        }
-
-                        return parameterContext;
+                        return getParameterContext(groupId, controllerServiceEntity);
                     }
                 });
 
@@ -2077,7 +2081,10 @@
                 // initialize the property table
                 $('#controller-service-properties').propertytable('destroy').propertytable({
                     supportsGoTo: true,
-                    readOnly: true
+                    readOnly: true,
+                    getParameterContext: function (groupId) {
+                        return getParameterContext(groupId, controllerServiceEntity);
+                    }
                 });
 
                 // update the mode
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
index 46c94df..f6724fd 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
@@ -2372,10 +2372,11 @@
         /**
          * Shows the dialog for the specified parameter context.
          *
-         * @param id         The parameter context id
-         * @param readOnly   Optional, boolean to open in read only mode even if the user has permission to write.
+         * @param id                  The parameter context id
+         * @param readOnly            Optional, boolean to open in read only mode even if the user has permission to write.
+         * @param parameterToSelect   Optional, name of the parameter to select in the table.
          */
-        showParameterContext: function (id, readOnly) {
+        showParameterContext: function (id, readOnly, parameterToSelect) {
             parameterCount = 0;
 
             // reload the parameter context in case the parameters have changed
@@ -2417,7 +2418,7 @@
                     .prop('title', parameterContextEntity.id)
                     .text(parameterContextEntity.id);
 
-                loadParameters(parameterContextEntity, null, readOnly);
+                loadParameters(parameterContextEntity, parameterToSelect, readOnly || !canWrite);
 
                 var editModeButtonModel = [{
                     buttonText: 'Apply',
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js
index f38561b..946e676 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js
@@ -25,9 +25,10 @@
                 'nf.Dialog',
                 'nf.ErrorHandler',
                 'nf.CustomUi',
-                'nf.ClusterSummary'],
-            function ($, nfCommon, nfUniversalCapture, nfDialog, nfErrorHandler, nfCustomUi, nfClusterSummary) {
-                return (nf.ProcessorDetails = factory($, nfCommon, nfUniversalCapture, nfDialog, nfErrorHandler, nfCustomUi, nfClusterSummary));
+                'nf.ClusterSummary',
+                'nf.CanvasUtils'],
+            function ($, nfCommon, nfUniversalCapture, nfDialog, nfErrorHandler, nfCustomUi, nfClusterSummary, nfCanvasUtils) {
+                return (nf.ProcessorDetails = factory($, nfCommon, nfUniversalCapture, nfDialog, nfErrorHandler, nfCustomUi, nfClusterSummary, nfCanvasUtils));
             });
     } else if (typeof exports === 'object' && typeof module === 'object') {
         module.exports = (nf.ProcessorDetails =
@@ -37,7 +38,8 @@
                 require('nf.Dialog'),
                 require('nf.ErrorHandler'),
                 require('nf.CustomUi'),
-                require('nf.ClusterSummary')));
+                require('nf.ClusterSummary'),
+                require('nf.CanvasUtils')));
     } else {
         nf.ProcessorDetails = factory(root.$,
             root.nf.Common,
@@ -45,9 +47,10 @@
             root.nf.Dialog,
             root.nf.ErrorHandler,
             root.nf.CustomUi,
-            root.nf.ClusterSummary);
+            root.nf.ClusterSummary,
+            root.nf.CanvasUtils);
     }
-}(this, function ($, nfCommon, nfUniversalCapture, nfDialog, nfErrorHandler, nfCustomUi, nfClusterSummary) {
+}(this, function ($, nfCommon, nfUniversalCapture, nfDialog, nfErrorHandler, nfCustomUi, nfClusterSummary, nfCanvasUtils) {
     'use strict';
 
     /**
@@ -173,7 +176,11 @@
             // initialize the properties
             $('#read-only-processor-properties').propertytable({
                 supportsGoTo: config.supportsGoTo,
-                readOnly: true
+                readOnly: true,
+                getParameterContext: function (groupId) {
+                    // processors being configured must be in the current group
+                    return nfCanvasUtils.getParameterContext();
+                }
             });
         },