You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by iu...@apache.org on 2021/08/31 08:20:09 UTC

[brooklyn-ui] branch master updated: Entity sorting correction

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

iuliana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new ac5f668  Entity sorting correction
     new bd70ea1  Merge pull request #273 from jathanasiou/fix/entity-sorting
ac5f668 is described below

commit ac5f6689cda68ce51940a667911595383939c113
Author: John Athanasiou <ja...@users.noreply.github.com>
AuthorDate: Mon Aug 30 16:18:30 2021 +0100

    Entity sorting correction
    
    Added a default displayName=symbolicName to prevent unwanted clustering
    
    Avoids fallback to 'lastUsed' attribute with which elements are moved around as they are used
---
 .../catalog-selector/catalog-selector.directive.js  | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js b/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
index 799c71b..0571260 100644
--- a/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
+++ b/ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
@@ -31,9 +31,9 @@ const MIN_ROWS_PER_PAGE = 4;
 const PALETTE_VIEW_ORDERS = {
         relevance: { id: "relevance", label: "Relevance", field: "relevance" },
         name: { id: "name", label: "Name", field: "displayName" },
-        lastUsed: { id: "lastUsed", label: "Recent", field: "-lastUsed" }, 
+        lastUsed: { id: "lastUsed", label: "Recent", field: "-lastUsed" },
         bundle: { id: "bundle", label: "Bundle", field: "containingBundle" }, 
-        id: { id: "id", label: "ID", field: "symbolicName" }, 
+        id: { id: "id", label: "ID", field: "symbolicName" },
     };
 
 const PALETTE_VIEW_MODES = {
@@ -66,7 +66,7 @@ export function catalogSelectorDirective() {
             family: '<',
             onSelect: '&', // action to do when item is selected
             onSelectText: "&?", // function returning text to show in the "on select" button for an item
-            iconSelects: '<?',  // boolean whether clicking the icon triggers selection directly or shows popup (false, default) 
+            iconSelects: '<?',  // boolean whether clicking the icon triggers selection directly or shows popup (false, default)
             rowsPerPage: '<?',  // optionally show fixed number of rows; unset (default and normal) computes based on available height
             reservedKeys: '<?',
             state: '<?', // for shared state usage
@@ -268,24 +268,25 @@ export function catalogSelectorDirective() {
         // Init
         $scope.items = [];
         function getDisplayTags(tags) {
-            if (!tags || !tags.length || !tags.reduce) return tags;
-            return tags.reduce((result, tag) => {
-                if (!(/[=:\[\]()]/.exec(tag))) {
-                    result.push(tag);
-                }
-                return result;
-            }, []);
+            if (!Array.isArray(tags) || !tags.length) return tags;
+            return tags.filter(tag => !(/[=:\[\]()]/.exec(tag)));
         }
+
         $scope.getItems().then((items)=> {
             // add displayTags, as any tag that doesn't contain = : or ( ) [ ]
             // any tag that is an object will be eliminated as it is toStringed to make [ object object ]
+            // add display name=symbolicName for those that don't have one, to avoid issues with the 'Name' property sorting
             items.forEach(item => {
                 if (item.tags) {
                     item.displayTags = getDisplayTags(item.tags);
                 }
+                if(!item.displayName) {
+                    item.displayName = item.symbolicName;
+                }
             });
             $scope.items = items;
         });
+
         $scope.lastUsedText = (item) => {
             if (item==null) return "";
             let l = (Number)(item.lastUsed);