From 768e89b57938c41e64a275dc92053c88e7a421e2 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Tue, 14 Mar 2017 11:08:24 -0400 Subject: [PATCH] NIFI-3246: - Preventing the editing of controller services that are defined in an ancestor process group. - Adding a go to link for users to easily navigate to where services are actually defined. This closes #1594 Signed-off-by: Scott Aslan --- .../canvas/process-group-configuration.jsp | 1 + .../js/nf/canvas/nf-controller-services.js | 59 +++++++++++++++---- .../canvas/nf-process-group-configuration.js | 34 ++++++----- 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/process-group-configuration.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/process-group-configuration.jsp index 6be880394c..6fd904d386 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/process-group-configuration.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/process-group-configuration.jsp @@ -28,6 +28,7 @@
Process group name
+
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js index 5274f79caf..9f1a26d74b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js @@ -753,23 +753,38 @@ var markup = ''; if (dataContext.permissions.canRead && dataContext.permissions.canWrite) { - if (dataContext.component.state === 'ENABLED' || dataContext.component.state === 'ENABLING') { - markup += '
'; - } else if (dataContext.component.state === 'DISABLED') { - markup += '
'; - - // if there are no validation errors allow enabling - if (nfCommon.isEmpty(dataContext.component.validationErrors)) { - markup += '
'; + var definedByCurrentGroup = false; + if (nfCommon.isDefinedAndNotNull(dataContext.component.parentGroupId)) { + // when opened in the process group context, the current group is store in #process-group-id + if (dataContext.component.parentGroupId === $('#process-group-id').text()) { + definedByCurrentGroup = true; } + } else { + // when there is no parent group, the service is defined at the controller level and should be editable + definedByCurrentGroup = true; } - if (dataContext.component.persistsState === true) { - markup += '
'; - } + if (definedByCurrentGroup === true) { + if (dataContext.component.state === 'ENABLED' || dataContext.component.state === 'ENABLING') { + markup += '
'; + } else if (dataContext.component.state === 'DISABLED') { + markup += '
'; - if (canWriteControllerServiceParent(dataContext)) { - markup += '
'; + // if there are no validation errors allow enabling + if (nfCommon.isEmpty(dataContext.component.validationErrors)) { + markup += '
'; + } + } + + if (dataContext.component.persistsState === true) { + markup += '
'; + } + + if (canWriteControllerServiceParent(dataContext)) { + markup += '
'; + } + } else { + markup += '
'; } } @@ -875,6 +890,24 @@ // close the settings dialog $('#shell-close-button').click(); + } else if (target.hasClass('go-to-controller-service')) { + // load the parent group of the selected service + nfProcessGroup.enterGroup(controllerServiceEntity.component.parentGroupId); + + // open/select the specific service + $.Deferred(function (deferred) { + if ($('#process-group-configuration').is(':visible')) { + nfProcessGroupConfiguration.loadConfiguration(controllerServiceEntity.component.parentGroupId).done(function () { + deferred.resolve(); + }); + } else { + nfProcessGroupConfiguration.showConfiguration(controllerServiceEntity.component.parentGroupId).done(function () { + deferred.resolve(); + }); + } + }).done(function () { + nfProcessGroupConfiguration.selectControllerService(controllerServiceEntity.id); + }); } } else if (controllerServicesGrid.getColumns()[args.cell].id === 'moreDetails') { if (target.hasClass('view-controller-service')) { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js index 2ca92260fc..00810c7fc0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js @@ -151,6 +151,23 @@ } }; + // record the group id + $('#process-group-id').text(groupId); + + // update the click listener + $('#process-group-configuration-refresh-button').off('click').on('click', function () { + loadConfiguration(groupId); + }); + + // update the new controller service click listener + $('#add-process-group-configuration-controller-service').off('click').on('click', function () { + var selectedTab = $('#process-group-configuration-tabs li.selected-tab').text(); + if (selectedTab === 'Controller Services') { + var controllerServicesUri = config.urls.api + '/process-groups/' + encodeURIComponent(groupId) + '/controller-services'; + nfControllerServices.promptNewControllerService(controllerServicesUri, getControllerServicesTable()); + } + }); + var processGroup = $.Deferred(function (deferred) { $.ajax({ type: 'GET', @@ -164,7 +181,6 @@ var processGroup = response.component; // populate the process group settings - $('#process-group-id').text(processGroup.id); $('#process-group-name').removeClass('unset').val(processGroup.name); $('#process-group-comments').removeClass('unset').val(processGroup.comments); @@ -253,6 +269,7 @@ $('#process-group-configuration-save').mouseout(); // reset the fields + $('#process-group-id').text(''); $('#process-group-name').val(''); $('#process-group-comments').val(''); @@ -330,21 +347,6 @@ * Shows the settings dialog. */ showConfiguration: function (groupId) { - // update the click listener - $('#process-group-configuration-refresh-button').off('click').on('click', function () { - loadConfiguration(groupId); - }); - - // update the new controller service click listener - $('#add-process-group-configuration-controller-service').off('click').on('click', function () { - var selectedTab = $('#process-group-configuration-tabs li.selected-tab').text(); - if (selectedTab === 'Controller Services') { - var controllerServicesUri = config.urls.api + '/process-groups/' + encodeURIComponent(groupId) + '/controller-services'; - nfControllerServices.promptNewControllerService(controllerServicesUri, getControllerServicesTable()); - } - }); - - // load the configuration return loadConfiguration(groupId).done(showConfiguration); },