You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by grkvlt <gi...@git.apache.org> on 2018/11/09 10:25:28 UTC

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

GitHub user grkvlt opened a pull request:

    https://github.com/apache/brooklyn-ui/pull/106

    Update save to catalog action

    Sets some default values from the blueprint and moves some items to an advanced section

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/grkvlt/brooklyn-ui update/save-to-catalog-action

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-ui/pull/106.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #106
    
----
commit 474de9e24478a971d2d6a757dd4fd54e8e63eb74
Author: Andrew Donald Kennedy <an...@...>
Date:   2018-10-24T13:51:44Z

    Configure various catalog properties based on current blueprint
    
    Signed-off-by: Andrew Donald Kennedy <an...@cloudsoftcorp.com>

commit b66923215180412954333957ddd20eb87c427117
Author: Andrew Donald Kennedy <an...@...>
Date:   2018-11-07T13:27:53Z

    Adds optional advanced section to catalog save modal
    
    Signed-off-by: Andrew Donald Kennedy <an...@cloudsoftcorp.com>

----


---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/106#discussion_r232211854
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---
    @@ -64,8 +64,44 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
             $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
     
             $scope.activateModal = () => {
    -            // Override callback to update catalog configuration data in other applications
    -            $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
    +            function injectorGet(reference) { return $element.injector().get(reference); }
    +            let blueprintService = injectorGet('blueprintService');
    +
    +            let entity = blueprintService.get();
    +            let metadata = blueprintService.entityHasMetadata(entity) ? blueprintService.getEntityMetadata(entity) : { };
    --- End diff --
    
    `metadata` is a `Map`, not an object. So if there isn't any, it should return `new Map()`. It currently throws a JS exception 
    
    Also, why do you get the metadata? There is no need there as the getters for `version`, `icon` and `id` already return this info out of the box.


---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/106#discussion_r232208108
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---
    @@ -60,12 +60,47 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
             link: link
         };
     
    -    function link($scope, $element) {
    +    function link($scope, $element, $compile, controller) {
             $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
     
             $scope.activateModal = () => {
    -            // Override callback to update catalog configuration data in other applications
    -            $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
    +            function injectorGet(reference) { return $element.injector().get(reference); }
    +            function blueprintService() { return injectorGet('blueprintService'); }
    --- End diff --
    
    Instead of using the `$injector`, you can inject `blueprintService` directly in `saveToCatalogModalDirective`


---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/106#discussion_r232251461
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---
    @@ -64,8 +64,44 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
             $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
     
             $scope.activateModal = () => {
    -            // Override callback to update catalog configuration data in other applications
    -            $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
    +            function injectorGet(reference) { return $element.injector().get(reference); }
    +            let blueprintService = injectorGet('blueprintService');
    +
    +            let entity = blueprintService.get();
    +            let metadata = blueprintService.entityHasMetadata(entity) ? blueprintService.getEntityMetadata(entity) : { };
    --- End diff --
    
    Fair point, forgot about the metadata 👍 



---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/106#discussion_r232209479
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---
    @@ -64,8 +64,44 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
             $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
     
             $scope.activateModal = () => {
    -            // Override callback to update catalog configuration data in other applications
    -            $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
    +            function injectorGet(reference) { return $element.injector().get(reference); }
    +            let blueprintService = injectorGet('blueprintService');
    --- End diff --
    
    Instead of using the `$injector`, you can inject `blueprintService` directly in `saveToCatalogModalDirective`


---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-ui/pull/106


---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/106#discussion_r232236211
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---
    @@ -64,8 +64,44 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
             $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
     
             $scope.activateModal = () => {
    -            // Override callback to update catalog configuration data in other applications
    -            $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
    +            function injectorGet(reference) { return $element.injector().get(reference); }
    +            let blueprintService = injectorGet('blueprintService');
    +
    +            let entity = blueprintService.get();
    +            let metadata = blueprintService.entityHasMetadata(entity) ? blueprintService.getEntityMetadata(entity) : { };
    --- End diff --
    
    Sometimes `version` or `iconUrl` are only available in the metadata, depending on the source of the blueprint


---

[GitHub] brooklyn-ui pull request #106: Update save to catalog action

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/106#discussion_r232209888
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---
    @@ -64,8 +64,44 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
             $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
     
             $scope.activateModal = () => {
    -            // Override callback to update catalog configuration data in other applications
    -            $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element);
    +            function injectorGet(reference) { return $element.injector().get(reference); }
    +            let blueprintService = injectorGet('blueprintService');
    +
    +            let entity = blueprintService.get();
    +            let metadata = blueprintService.entityHasMetadata(entity) ? blueprintService.getEntityMetadata(entity) : { };
    +            let config = $scope.$parent.$parent.vm.saveToCatalogConfig;
    --- End diff --
    
    You should pass `saveToCatalogConfig` as a parameter for the directive instead of getting it from the parent. You create a link here which is brittle.


---