)]}'
{"openstack_dashboard/static/app/core/images/actions/edit.action.service.js":[{"author":{"_account_id":12281,"name":"Itxaka","email":"igarcia@suse.com","username":"itxaka"},"change_message_id":"07cf53a98088fa713bd8a3019a8f1354236b8670","unresolved":false,"context_lines":[{"line_number":75,"context_line":""},{"line_number":76,"context_line":"    function initScope($scope) {"},{"line_number":77,"context_line":"      scope \u003d $scope;"},{"line_number":78,"context_line":"      $scope.$on(events.IMAGE_METADATA_CHANGED, onMetadataChange);"},{"line_number":79,"context_line":"      modifyImagePolicyCheck \u003d policy.ifAllowed({rules: [[\u0027image\u0027, \u0027modify_image\u0027]]});"},{"line_number":80,"context_line":"    }"},{"line_number":81,"context_line":""}],"source_content_type":"text/javascript","patch_set":2,"id":"3aaa91ec_2f3aaf98","line":78,"range":{"start_line":78,"start_character":24,"end_line":78,"end_character":46},"updated":"2016-06-29 09:32:42.000000000","message":"Not sure if this is what is failing, but where does this events.IMAGE_METADATA_CHANGED comes from?","commit_id":"b2655ffc7067179def699b162494c7350bd61166"},{"author":{"_account_id":7665,"name":"Travis Tripp","email":"os.travis.tripp@gmail.com","username":"travis.tripp"},"change_message_id":"8fff4aa039c7e9f122f7e35a5eb878a0d2ec2bbd","unresolved":false,"context_lines":[{"line_number":112,"context_line":"    }"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"    function submit() {"},{"line_number":115,"context_line":"      return clearMetadata().then(updateImage, updateImage);"},{"line_number":116,"context_line":"    }"},{"line_number":117,"context_line":""},{"line_number":118,"context_line":"    function updateImage() {"}],"source_content_type":"text/javascript","patch_set":3,"id":"1aa78d24_642330a8","line":115,"updated":"2016-07-05 23:47:41.000000000","message":"This is actually bad.  This removes metadata leaving the image missing information. If the next save step fails for some reason, the image will have not only NOT saved the desired metadata, but it will have lost all its existing metadata.  I think we need to follow the pattern established the metadata modal:\n\nhttps://github.com/openstack/horizon/blob/master/openstack_dashboard/static/app/core/metadata/modal/modal.controller.js#L52-L63\n\nI took the liberty of applying that pattern to the code and verifying that it will work here. Here\u0027s the code I used:\n\n    function updateMetadata() {\n\n      return metadataService\n        .getMetadata(\u0027image\u0027, model.image.id)\n        .then(onMetadataGet);\n\n      function onMetadataGet(response) {\n        var updated \u003d model.metadata;\n        var removed \u003d angular.copy(response.data);\n        angular.forEach(updated, function(value, key) {\n          delete removed[key];\n        });\n\n        return metadataService\n          .editMetadata(\u0027image\u0027, model.image.id, updated, Object.keys(removed));\n      }\n    }\n\n\nHere is the diff:\n\n diff --git a/openstack_dashboard/static/app/core/images/actions/edit.action.service.js b/openstack_dashboard/static/app/core/images/actions/edit.action.service.js\n index 4e87d94..3b8da0c 100644\n --- a/openstack_dashboard/static/app/core/images/actions/edit.action.service.js\n +++ b/openstack_dashboard/static/app/core/images/actions/edit.action.service.js\n @@ -112,7 +112,7 @@\n      }\n  \n      function submit() {\n -      return clearMetadata().then(updateImage, updateImage);\n +      return updateMetadata().then(updateImage, updateImage);\n      }\n \n      function updateImage() {\n @@ -133,16 +133,21 @@\n          .result;\n      }\n  \n -    function clearMetadata() {\n -      var imageId \u003d model.image.id;\n +    function updateMetadata() {\n \n -      return metadataService.getMetadata(\u0027image\u0027, imageId).then(onMetadataGet);\n +      return metadataService\n +        .getMetadata(\u0027image\u0027, model.image.id)\n +        .then(onMetadataGet);\n \n        function onMetadataGet(response) {\n -        var metadata \u003d angular.copy(response.data);\n -\n -        // clears all metadata\n -        return glance.editImageProps(imageId, {}, Object.keys(metadata));\n +        var updated \u003d model.metadata;\n +        var removed \u003d angular.copy(response.data);\n +        angular.forEach(updated, function(value, key) {\n +          delete removed[key];\n +        });\n +\n +        return metadataService\n +          .editMetadata(\u0027image\u0027, model.image.id, updated, Object.keys(removed));\n        }\n      }","commit_id":"ea4efd29303a1cfcdf6445f576df65a92e9f2050"},{"author":{"_account_id":6763,"name":"jingliuqing","email":"jing.liuqing@99cloud.net","username":"jing"},"change_message_id":"7f553a1b2e5cf7ad98a5e2f7d8db7c54b7e4919b","unresolved":false,"context_lines":[{"line_number":112,"context_line":"    }"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"    function submit() {"},{"line_number":115,"context_line":"      return updateMetadata().then(updateImage, updateImage);"},{"line_number":116,"context_line":"    }"},{"line_number":117,"context_line":""},{"line_number":118,"context_line":"    function updateImage() {"}],"source_content_type":"text/javascript","patch_set":4,"id":"1aa78d24_93578e01","line":115,"range":{"start_line":115,"start_character":35,"end_line":115,"end_character":59},"updated":"2016-07-11 14:43:27.000000000","message":"not very clear...","commit_id":"0e94d7c5c9e63e9a701f0d78a393dc9b73360ba2"},{"author":{"_account_id":7665,"name":"Travis Tripp","email":"os.travis.tripp@gmail.com","username":"travis.tripp"},"change_message_id":"ce43b2881d375e58849ac7a8ba583f8880380db9","unresolved":false,"context_lines":[{"line_number":112,"context_line":"    }"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"    function submit() {"},{"line_number":115,"context_line":"      return updateMetadata().then(updateImage, updateImage);"},{"line_number":116,"context_line":"    }"},{"line_number":117,"context_line":""},{"line_number":118,"context_line":"    function updateImage() {"}],"source_content_type":"text/javascript","patch_set":4,"id":"1aa78d24_d96f54fa","line":115,"range":{"start_line":115,"start_character":35,"end_line":115,"end_character":59},"in_reply_to":"1aa78d24_93578e01","updated":"2016-07-12 05:47:28.000000000","message":"Hmm... good catch. We should actually fail here, I think.","commit_id":"0e94d7c5c9e63e9a701f0d78a393dc9b73360ba2"},{"author":{"_account_id":14124,"name":"Matt Borland","email":"matt.borland@hpe.com","username":"mborland"},"change_message_id":"bda717ece7e7093677f1454dd11b858b168bf730","unresolved":false,"context_lines":[{"line_number":112,"context_line":"    }"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"    function submit() {"},{"line_number":115,"context_line":"      return updateMetadata().then(updateImage, updateImage);"},{"line_number":116,"context_line":"    }"},{"line_number":117,"context_line":""},{"line_number":118,"context_line":"    function updateImage() {"}],"source_content_type":"text/javascript","patch_set":4,"id":"1aa78d24_2f02e6b4","line":115,"range":{"start_line":115,"start_character":35,"end_line":115,"end_character":59},"in_reply_to":"1aa78d24_d96f54fa","updated":"2016-07-14 18:33:07.000000000","message":"Done","commit_id":"0e94d7c5c9e63e9a701f0d78a393dc9b73360ba2"},{"author":{"_account_id":6763,"name":"jingliuqing","email":"jing.liuqing@99cloud.net","username":"jing"},"change_message_id":"7f553a1b2e5cf7ad98a5e2f7d8db7c54b7e4919b","unresolved":false,"context_lines":[{"line_number":127,"context_line":"        .result;"},{"line_number":128,"context_line":"    }"},{"line_number":129,"context_line":""},{"line_number":130,"context_line":"    function onUpdateImageFail() {"},{"line_number":131,"context_line":"      return actionResultService.getActionResult()"},{"line_number":132,"context_line":"        .failed(imageResourceType, model.image.id)"},{"line_number":133,"context_line":"        .result;"}],"source_content_type":"text/javascript","patch_set":4,"id":"1aa78d24_2eec7128","line":130,"updated":"2016-07-11 14:43:27.000000000","message":"should we add error msg here ?","commit_id":"0e94d7c5c9e63e9a701f0d78a393dc9b73360ba2"},{"author":{"_account_id":14124,"name":"Matt Borland","email":"matt.borland@hpe.com","username":"mborland"},"change_message_id":"bda717ece7e7093677f1454dd11b858b168bf730","unresolved":false,"context_lines":[{"line_number":127,"context_line":"        .result;"},{"line_number":128,"context_line":"    }"},{"line_number":129,"context_line":""},{"line_number":130,"context_line":"    function onUpdateImageFail() {"},{"line_number":131,"context_line":"      return actionResultService.getActionResult()"},{"line_number":132,"context_line":"        .failed(imageResourceType, model.image.id)"},{"line_number":133,"context_line":"        .result;"}],"source_content_type":"text/javascript","patch_set":4,"id":"1aa78d24_cf908251","line":130,"in_reply_to":"1aa78d24_2eec7128","updated":"2016-07-14 18:33:07.000000000","message":"I believe we get the error toast from the api failure.","commit_id":"0e94d7c5c9e63e9a701f0d78a393dc9b73360ba2"},{"author":{"_account_id":12071,"name":"Richard Jones","email":"r1chardj0n3s@gmail.com","username":"richard"},"change_message_id":"124a3394c188632e9554dcaa887b91f2a41da1ce","unresolved":false,"context_lines":[{"line_number":77,"context_line":""},{"line_number":78,"context_line":"    function initScope($scope) {"},{"line_number":79,"context_line":"      scope \u003d $scope;"},{"line_number":80,"context_line":"      $scope.$on(events.IMAGE_METADATA_CHANGED, onMetadataChange);"},{"line_number":81,"context_line":"      modifyImagePolicyCheck \u003d policy.ifAllowed({rules: [[\u0027image\u0027, \u0027modify_image\u0027]]});"},{"line_number":82,"context_line":"    }"},{"line_number":83,"context_line":""}],"source_content_type":"text/javascript","patch_set":5,"id":"fad55976_5b0c7c42","line":80,"updated":"2016-07-15 19:20:21.000000000","message":"I feel like I should recommend this patch not use $scope - but I guess we don\u0027t really have a \"plan\" for moving away from scope in action services in general, right?","commit_id":"13339f218010766261955697f04b50cd3dc45346"},{"author":{"_account_id":14124,"name":"Matt Borland","email":"matt.borland@hpe.com","username":"mborland"},"change_message_id":"1fcc5f538c3cced681a897eef8d28bb5c620700b","unresolved":false,"context_lines":[{"line_number":77,"context_line":""},{"line_number":78,"context_line":"    function initScope($scope) {"},{"line_number":79,"context_line":"      scope \u003d $scope;"},{"line_number":80,"context_line":"      $scope.$on(events.IMAGE_METADATA_CHANGED, onMetadataChange);"},{"line_number":81,"context_line":"      modifyImagePolicyCheck \u003d policy.ifAllowed({rules: [[\u0027image\u0027, \u0027modify_image\u0027]]});"},{"line_number":82,"context_line":"    }"},{"line_number":83,"context_line":""}],"source_content_type":"text/javascript","patch_set":5,"id":"dada55a8_c59fd75d","line":80,"in_reply_to":"fad55976_5b0c7c42","updated":"2016-07-18 16:26:04.000000000","message":"Yeah, in general I\u0027d like to move away from it, but in this case frankly I\u0027m just bringing back functionality that was refactored out (inappropriately).  I think as we move to a form schema with shared models, we can better find substitutes for events.","commit_id":"13339f218010766261955697f04b50cd3dc45346"}]}
