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 <scottyaslan@gmail.com>
This commit is contained in:
Matt Gilman 2017-03-14 11:08:24 -04:00 committed by Scott Aslan
parent 78382c66bc
commit 768e89b579
3 changed files with 65 additions and 29 deletions

View File

@ -28,6 +28,7 @@
<div id="general-process-group-configuration">
<div class="setting">
<div class="setting-name">Process group name</div>
<span id="process-group-id" class="hidden"></span>
<div class="editable setting-field">
<input type="text" id="process-group-name" class="setting-input"/>
</div>

View File

@ -753,6 +753,18 @@
var markup = '';
if (dataContext.permissions.canRead && dataContext.permissions.canWrite) {
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 (definedByCurrentGroup === true) {
if (dataContext.component.state === 'ENABLED' || dataContext.component.state === 'ENABLING') {
markup += '<div class="pointer disable-controller-service icon icon-enable-false" title="Disable" style="margin-top: 2px; margin-right: 3px;" ></div>';
} else if (dataContext.component.state === 'DISABLED') {
@ -771,6 +783,9 @@
if (canWriteControllerServiceParent(dataContext)) {
markup += '<div class="pointer delete-controller-service fa fa-trash" title="Remove" style="margin-top: 2px; margin-right: 3px;" ></div>';
}
} else {
markup += '<div class="pointer go-to-controller-service fa fa-long-arrow-right" title="Go To" style="margin-top: 2px; margin-right: 3px;" ></div>';
}
}
// allow policy configuration conditionally
@ -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')) {

View File

@ -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);
},