NIFI-3683:

- Ensuring we use the appropriate action based on the previously displayed policy.

Signed-off-by: Scott Aslan <scottyaslan@gmail.com>

This closes #1657
This commit is contained in:
Matt Gilman 2017-04-07 11:11:37 -04:00 committed by Scott Aslan
parent e8771e59a7
commit 35f4f48f37
1 changed files with 24 additions and 4 deletions

View File

@ -326,6 +326,26 @@
$('<li></li>').data('tenant', allowedTenant).append(tenant).append(tenantAction).appendTo(allowedTenants); $('<li></li>').data('tenant', allowedTenant).append(tenant).append(tenantAction).appendTo(allowedTenants);
}; };
/**
* Determines whether the specified global policy type supports read/write options.
*
* @param policyType global policy type
* @returns {boolean} whether the policy supports read/write options
*/
var globalPolicySupportsReadWrite = function (policyType) {
return policyType === 'controller' || policyType === 'counters' || policyType === 'policies' || policyType === 'tenants';
};
/**
* Determines whether the specified global policy type only supports write.
*
* @param policyType global policy type
* @returns {boolean} whether the policy only supports write
*/
var globalPolicySupportsWrite = function (policyType) {
return policyType === 'proxy' || policyType === 'restricted-components';
};
/** /**
* Initializes the policy table. * Initializes the policy table.
*/ */
@ -397,7 +417,7 @@
$('#selected-policy-type').text(option.value); $('#selected-policy-type').text(option.value);
// if the option is for a specific component // if the option is for a specific component
if (option.value === 'controller' || option.value === 'counters' || option.value === 'policies' || option.value === 'tenants') { if (globalPolicySupportsReadWrite(option.value)) {
// update the policy target and let it relaod the policy // update the policy target and let it relaod the policy
$('#controller-policy-target').combo('setSelectedOption', { $('#controller-policy-target').combo('setSelectedOption', {
'value': 'read' 'value': 'read'
@ -406,7 +426,7 @@
$('#controller-policy-target').hide(); $('#controller-policy-target').hide();
// record the action // record the action
if (option.value === 'proxy' || option.value === 'restricted-components') { if (globalPolicySupportsWrite(option.value)) {
$('#selected-policy-action').text('write'); $('#selected-policy-action').text('write');
} else { } else {
$('#selected-policy-action').text('read'); $('#selected-policy-action').text('read');
@ -1458,9 +1478,9 @@
var policyType = $('#policy-type-list').combo('getSelectedOption').value; var policyType = $('#policy-type-list').combo('getSelectedOption').value;
$('#selected-policy-type').text(policyType); $('#selected-policy-type').text(policyType);
if (policyType === 'controller') { if (globalPolicySupportsReadWrite(policyType)) {
$('#selected-policy-action').text($('#controller-policy-target').combo('getSelectedOption').value); $('#selected-policy-action').text($('#controller-policy-target').combo('getSelectedOption').value);
} else if (policyType === 'proxy' || policyType === 'restricted-components') { } else if (globalPolicySupportsWrite(policyType)) {
$('#selected-policy-action').text('write'); $('#selected-policy-action').text('write');
} else { } else {
$('#selected-policy-action').text('read'); $('#selected-policy-action').text('read');