From eb2ebefc4682d3f95ba5c9cbb8f604f5331ec79e Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Mon, 8 Jun 2020 17:05:24 -0400 Subject: [PATCH] NIFI-7514: - Ensuring the group id is always set in the properties table when loading properties. - Using a common approach to getting parameters in nfControllerService. - Code clean up. - Addressing review feedback. - Ensuring the service dialog is closed when navigating to the parameter context dialog. This closes #4322 --- .../propertytable/jquery.propertytable.js | 28 +++++++++++++------ .../js/nf/canvas/nf-controller-service.js | 14 ++++++---- .../webapp/js/nf/canvas/nf-reporting-task.js | 6 ++-- .../main/webapp/js/nf/nf-processor-details.js | 10 ++++--- 4 files changed, 37 insertions(+), 21 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 4acaf947e9..4b08a3129f 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 @@ -1246,6 +1246,17 @@ }; var initPropertiesTable = function (table, options) { + // function for closing the dialog + var closeDialog = function () { + // close the dialog + var dialog = table.closest('.dialog'); + if (dialog.hasClass('modal')) { + dialog.modal('hide'); + } else { + dialog.hide(); + } + } + // function for formatting the property name var nameFormatter = function (row, cell, value, columnDef, dataContext) { var nameWidthOffset = 30; @@ -1386,7 +1397,7 @@ } if (referencesParam && canReadParamContext) { - markup += '
'; + markup += '
'; } if (options.readOnly !== true) { @@ -1510,12 +1521,7 @@ dataType: 'json' }).done(function (controllerServiceEntity) { // close the dialog - var dialog = table.closest('.dialog'); - if (dialog.hasClass('modal')) { - dialog.modal('hide'); - } else { - dialog.hide(); - } + closeDialog(); var controllerService = controllerServiceEntity.component; $.Deferred(function (deferred) { @@ -1616,7 +1622,7 @@ propertyData.updateItem(property.id, updatedItem); }); } - } else if (target.hasClass('goto-to-parameter')) { + } else if (target.hasClass('go-to-parameter')) { var parameterContext; if (_.isFunction(options.getParameterContext)) { parameterContext = options.getParameterContext(groupId); @@ -1627,6 +1633,9 @@ var paramRefsRegex = /#{([a-zA-Z0-9-_. ]+)}/; var result = property.value.match(paramRefsRegex); if (!_.isEmpty(result) && result.length === 2) { + // close the dialog since we are sending the user to the parameter context + closeDialog(); + var parameterName = result[1]; nfParameterContexts.showParameterContext(parameterContext.id, null, parameterName); } @@ -2157,7 +2166,8 @@ }, /** - * Sets the current group id. + * Sets the current group id. This is used to indicate where inline Controller Services are created + * and to obtain the parameter context. */ setGroupId: function (currentGroupId) { return this.each(function () { 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 f88c660937..4fb41d73b2 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,8 +1589,8 @@ }).promise(); }; - var getParameterContext = function (groupId, controllerServiceEntity) { - if (_.isNil(controllerServiceEntity.parentGroupId)) { + var getParameterContext = function (groupId) { + if (_.isNil(groupId)) { return null; } @@ -1598,7 +1598,7 @@ // attempt to identify the parameter context, conditional based on whether // the user is configuring the current process group - if (_.isNil(groupId) || groupId === nfCanvasUtils.getGroupId()) { + if (groupId === nfCanvasUtils.getGroupId()) { parameterContext = nfCanvasUtils.getParameterContext(); } else { var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId); @@ -1896,7 +1896,7 @@ return goToServiceFromProperty(serviceTable); }, getParameterContext: function (groupId) { - return getParameterContext(groupId, controllerServiceEntity); + return getParameterContext(groupId); } }); @@ -2083,7 +2083,7 @@ supportsGoTo: true, readOnly: true, getParameterContext: function (groupId) { - return getParameterContext(groupId, controllerServiceEntity); + return getParameterContext(groupId); } }); @@ -2185,7 +2185,9 @@ controllerServiceDialog.modal('setButtonModel', buttons); // load the property table - $('#controller-service-properties').propertytable('loadProperties', controllerService.properties, controllerService.descriptors, controllerServiceHistory.propertyHistory); + $('#controller-service-properties') + .propertytable('setGroupId', controllerService.parentGroupId) + .propertytable('loadProperties', controllerService.properties, controllerService.descriptors, controllerServiceHistory.propertyHistory); // show the details controllerServiceDialog.modal('show'); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js index 07e59f5afa..f8b0b1ac59 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js @@ -601,7 +601,7 @@ // load the property table $('#reporting-task-properties') - .propertytable('setGroupId', reportingTask.parentGroupId) + .propertytable('setGroupId', null) .propertytable('loadProperties', reportingTask.properties, reportingTask.descriptors, reportingTaskHistory.propertyHistory); // show the details @@ -721,7 +721,9 @@ reportingTaskDialog.modal('setButtonModel', buttons).modal('show'); // load the property table - $('#reporting-task-properties').propertytable('loadProperties', reportingTask.properties, reportingTask.descriptors, reportingTaskHistory.propertyHistory); + $('#reporting-task-properties') + .propertytable('setGroupId', null) + .propertytable('loadProperties', reportingTask.properties, reportingTask.descriptors, reportingTaskHistory.propertyHistory); // show the details reportingTaskDialog.modal('show'); 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 ec1daf3389..93bd0809fb 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 @@ -174,13 +174,13 @@ } // initialize the properties - + $('#read-only-processor-properties').propertytable(Object.assign({ supportsGoTo: config.supportsGoTo, readOnly: true - }, + }, //incase of summary window, nfCanvasUtils module wont be loaded - nfCanvasUtils && { + nfCanvasUtils && { getParameterContext: function (groupId) { // processors being configured must be in the current group return nfCanvasUtils.getParameterContext(); @@ -289,7 +289,9 @@ var selection; // load the properties - $('#read-only-processor-properties').propertytable('loadProperties', processor.config.properties, processor.config.descriptors, history.propertyHistory); + $('#read-only-processor-properties') + .propertytable('setGroupId', processor.parentGroupId) + .propertytable('loadProperties', processor.config.properties, processor.config.descriptors, history.propertyHistory); var buttons = [{ buttonText: 'Ok',