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

jcabrerizo pushed a commit to branch feature/remove-appX-naming-from-home
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git

commit fec765b5ff469022a79b29d228d56e8c2f2fe9b4
Author: Juan Cabrerizo <[email protected]>
AuthorDate: Wed May 18 10:54:49 2022 +0100

    Addresing PR comments
---
 ui-modules/utils/utils/general.js | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/ui-modules/utils/utils/general.js 
b/ui-modules/utils/utils/general.js
index 23b3d2b7..ff84eb6b 100644
--- a/ui-modules/utils/utils/general.js
+++ b/ui-modules/utils/utils/general.js
@@ -36,39 +36,36 @@ export function capitalize(input) {
  * and anything with a length (string). also understands null and undefined.
  * 
  * useful instead of the refrain of (x!==null && x.length>0), or a bit worse 
for Object.
- */ 
+ */
 export function isNonEmpty(object) {
     if (typeof object === "undefined" || object == null) return false;
-    
+
     // treat arrays specially although I think the two methods below will 
always work for them
     if (Array.isArray(object)) return object.length > 0;
-    
+
     if (angular.isObject(object)) return Object.keys(object).length > 0;
 
     // other common falsey types            
     if (object == 0 || object == false) return false;
     // strings, maybe other things
     if (object.hasOwnProperty("length")) return object.length > 0;
-    
+
     // other objects will be complex or default to true
-    return true; 
+    return true;
 }
 
 export function uiModuleComparator(moduleA, moduleB) {
     if(moduleA.order && moduleB.order){
-        if (moduleA.order > moduleB.order) {
-            return 1;
-        }
-        if(moduleA.order < moduleB.order) {
-            return -1;
+        if (moduleA.order != moduleB.order){
+            return moduleA.order - moduleB.order;
         }
     }
     // If no order implemented or is the same, order by name
-    return moduleA.name > moduleB.name ? 1: -1;
+    return moduleA.name.localeCompare(moduleB.name);
 }
 export function brUtilsGeneralProvider() {
-    return { 
-        isNonEmpty, 
+    return {
+        isNonEmpty,
         capitalize,
         uiModuleComparator
     };

Reply via email to