You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2022/05/18 08:47:12 UTC

[GitHub] [brooklyn-ui] grkvlt commented on a diff in pull request #325: Add `order` as module property and use it when is present before using name for ordering modules

grkvlt commented on code in PR #325:
URL: https://github.com/apache/brooklyn-ui/pull/325#discussion_r875633721


##########
ui-modules/utils/utils/general.js:
##########
@@ -54,10 +54,23 @@ export function isNonEmpty(object) {
     return true; 
 }
 
+export function uiModuleComparator(moduleA, moduleB) {
+    if(moduleA.order && moduleB.order){
+        if (moduleA.order > moduleB.order) {

Review Comment:
   another simplification maybe `if (moduleA.order != moduleB.order) return moduleA.order - moduleB.order`



##########
ui-modules/utils/utils/general.js:
##########
@@ -54,10 +54,23 @@ export function isNonEmpty(object) {
     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 no order implemented or is the same, order by name
+    return moduleA.name > moduleB.name ? 1: -1;

Review Comment:
   is something like `moduleA.name.localeCompare(moduleB.name)` better?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org