tbouron commented on a change in pull request #125: Fix errors around locations 
in composer
URL: https://github.com/apache/brooklyn-ui/pull/125#discussion_r260327518
 
 

 ##########
 File path: 
ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
 ##########
 @@ -603,16 +616,24 @@ function BlueprintService($log, $q, $sce, paletteApi, 
iconGenerator, dslService)
 
     function populateLocationFromApiSuccess(entity, data) {
         entity.clearIssues({group: 'location'});
-        entity.location = data.symbolicName;
-        entity.miscData.set('locationName', data.name);
-        entity.miscData.set('locationIcon', data.iconUrl || 
iconGenerator(data.symbolicName));
+        entity.location = data.yamlHere || data.symbolicName;
+        
+        let name = data.name || data.displayName;
+        if (!name && data.yamlHere) {
+            name = typeof data.yamlHere === 'object' ? 
Object.keys(data.yamlHere)[0] : data.yamlHere;
+        }
+        if (!name) name =  data.symbolicName;
+        entity.miscData.set('locationName', name);
+        
+        // use icon on item, but if none then generate using *yaml* to 
distinguish when someone has changed it
+        // (especially for things like jclouds:aws-ec2 -- the config is more 
interesting than the type name)
+        entity.miscData.set('locationIcon', data==null ? null : data.iconUrl 
|| iconGenerator(data.yamlHere ? JSON.stringify(data.yamlHere) : 
data.symbolicName));
         return entity;
     }
 
     function populateLocationFromApiError(entity) {
-        entity.clearIssues({group: 'location'});
+        populateLocationFromApiSuccess(entity, { yamlHere: entity.location });
 
 Review comment:
   That's wrong. If the location can be setup from the entity, then this code 
should be put into the caller function, not here. This function is to setup the 
state if there is an error when setting up the location.
   
   Also, you want to keep the `entity.clearIssues({group: 'location'});` 
because errors are recreated just below. Not doing so will result to the same 
error displayed twice

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to