From 35f4f48f3778b7f358ac763fea1a8b7de4b354e4 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Fri, 7 Apr 2017 11:11:37 -0400 Subject: [PATCH] NIFI-3683: - Ensuring we use the appropriate action based on the previously displayed policy. Signed-off-by: Scott Aslan This closes #1657 --- .../js/nf/canvas/nf-policy-management.js | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js index 1fdf181a17..93cb9207a5 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js @@ -326,6 +326,26 @@ $('
  • ').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. */ @@ -397,7 +417,7 @@ $('#selected-policy-type').text(option.value); // 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 $('#controller-policy-target').combo('setSelectedOption', { 'value': 'read' @@ -406,7 +426,7 @@ $('#controller-policy-target').hide(); // record the action - if (option.value === 'proxy' || option.value === 'restricted-components') { + if (globalPolicySupportsWrite(option.value)) { $('#selected-policy-action').text('write'); } else { $('#selected-policy-action').text('read'); @@ -1458,9 +1478,9 @@ var policyType = $('#policy-type-list').combo('getSelectedOption').value; $('#selected-policy-type').text(policyType); - if (policyType === 'controller') { + if (globalPolicySupportsReadWrite(policyType)) { $('#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'); } else { $('#selected-policy-action').text('read');