This is an automated email from the ASF dual-hosted git repository.

rfellows pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new ed1e843  NIFI-6769: - Ensuring the users policy listing can handle 
when the specified policy is unknown.
ed1e843 is described below

commit ed1e843609af32711daac88bd423428b86a58a7c
Author: Matt Gilman <[email protected]>
AuthorDate: Thu Oct 10 11:06:10 2019 -0400

    NIFI-6769:
    - Ensuring the users policy listing can handle when the specified policy is 
unknown.
    
    This closes #3807.
---
 .../nifi-web-ui/src/main/webapp/js/nf/nf-common.js | 24 ++++++++++++-----
 .../src/main/webapp/js/nf/users/nf-users-table.js  | 30 +++++++++++++++++-----
 2 files changed, 41 insertions(+), 13 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
index c7ca1ea..77d5847 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
@@ -1709,13 +1709,25 @@
             return formattedGarbageCollections;
         },
 
+        /**
+         * Returns whether the specified resource is for a global policy.
+         *
+         * @param resource
+         */
+        isGlobalPolicy: function (value) {
+            return nfCommon.getPolicyTypeListing(value) !== null;
+        },
+
+        /**
+         * Gets the policy type for the specified resource.
+         *
+         * @param value
+         * @returns {*}
+         */
         getPolicyTypeListing: function (value) {
-            var nest = d3.nest()
-                .key(function (d) {
-                    return d.value;
-                })
-                .map(policyTypeListing, d3.map);
-            return nest.get(value)[0];
+            return policyTypeListing.find(function (policy) {
+                return value === policy.value;
+            });
         },
 
         /**
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
index 93a8edd..b10385b 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
@@ -534,12 +534,21 @@
     /**
      * Generates a human readable global policy string.
      *
+     * @param policy
+     * @returns {string}
+     */
+    var globalResourceParser = function (policy) {
+        return 'Global policy to ' + policy.text;
+    };
+
+    /**
+     * Generates a human readable policy string for an unknown resource.
+     *
      * @param dataContext
      * @returns {string}
      */
-    var globalResourceParser = function (dataContext) {
-        return 'Global policy to ' +
-            
nfCommon.getPolicyTypeListing(nfCommon.substringAfterFirst(dataContext.component.resource,
 '/')).text;
+    var unknownResourceParser = function (dataContext) {
+        return '<span class="unset">Unknown resource ' + 
nfCommon.escapeHtml(dataContext.component.resource) + '</span>';
     };
 
     /**
@@ -991,12 +1000,19 @@
         if 
(dataContext.component.resource.startsWith('/restricted-components')) {
             // restricted components policy
             return restrictedComponentResourceParser(dataContext);
-        } else if 
(nfCommon.isUndefinedOrNull(dataContext.component.componentReference)) {
-            // global policy
-            return globalResourceParser(dataContext);
-        } else {
+        } else if 
(nfCommon.isDefinedAndNotNull(dataContext.component.componentReference)) {
             // not restricted/global policy... check if user has access to the 
component reference
             return componentResourceParser(dataContext);
+        } else {
+            // may be a global policy
+            var policy = 
nfCommon.getPolicyTypeListing(nfCommon.substringAfterFirst(dataContext.component.resource,
 '/'));
+
+            // if known global policy, format it otherwise format as unknown
+            if (nfCommon.isDefinedAndNotNull(policy)) {
+                return globalResourceParser(policy);
+            } else {
+                return unknownResourceParser(dataContext);
+            }
         }
     };
 

Reply via email to