[ARVADOS] updated: 1.3.0-1088-ga981ba700

Git user git at public.curoverse.com
Tue Jun 18 14:32:01 UTC 2019


Summary of changes:
 .../app/assets/javascripts/components/edit_tags.js | 42 ++++++++++++++++++++--
 services/api/app/models/collection.rb              |  5 ++-
 2 files changed, 44 insertions(+), 3 deletions(-)

       via  a981ba7008866165a3941707ba2a98df34c424e0 (commit)
      from  282a705c0cc2841182f8b670f6696b681ab12779 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit a981ba7008866165a3941707ba2a98df34c424e0
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Tue Jun 18 11:29:10 2019 -0300

    14874: Adds protected properties error handling to wb's tag editor.
    
    The tag editor notifies the user which tags are protected and restores their
    state in the editor so they can be saved.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/javascripts/components/edit_tags.js b/apps/workbench/app/assets/javascripts/components/edit_tags.js
index b47f3abf7..5e02279ea 100644
--- a/apps/workbench/app/assets/javascripts/components/edit_tags.js
+++ b/apps/workbench/app/assets/javascripts/components/edit_tags.js
@@ -182,6 +182,24 @@ window.TagEditorApp = {
         tag.value.map(function() { vnode.state.dirty(true) })
         tag.name.map(m.redraw)
     },
+    fixTag: function(vnode, tagName) {
+        // Recover tag if deleted, recover its value if modified
+        savedTagValue = vnode.state.saved_tags[tagName]
+        if (savedTagValue === undefined) {
+            return
+        }
+        found = false
+        vnode.state.tags.forEach(function(tag) {
+            if (tag.name == tagName) {
+                tag.value = vnode.state.saved_tags[tagName]
+                found = true
+            }
+        })
+        if (!found) {
+            vnode.state.tags.pop() // Remove the last empty row
+            vnode.state.appendTag(vnode, tagName, savedTagValue)
+        }
+    },
     oninit: function(vnode) {
         vnode.state.sessionDB = new SessionDB()
         // Get vocabulary
@@ -190,6 +208,7 @@ window.TagEditorApp = {
         m.request('/vocabulary.json?v=' + vocabularyTimestamp).then(vnode.state.vocabulary)
         vnode.state.editMode = vnode.attrs.targetEditable
         vnode.state.tags = []
+        vnode.state.saved_tags = {}
         vnode.state.dirty = m.stream(false)
         vnode.state.dirty.map(m.redraw)
         vnode.state.error = m.stream('')
@@ -214,6 +233,7 @@ window.TagEditorApp = {
                     }
                     // Data synced with server, so dirty state should be false
                     vnode.state.dirty(false)
+                    vnode.state.saved_tags = o.properties
                     // Add new tag row when the last one is completed
                     vnode.state.dirty.map(function() {
                         if (!vnode.state.editMode) { return }
@@ -251,9 +271,27 @@ window.TagEditorApp = {
                         ).then(function(v) {
                             vnode.state.dirty(false)
                             vnode.state.error('')
+                            vnode.state.saved_tags = tags
                         }).catch(function(err) {
-                            errMsg = err["errors"].join(', ')
-                            vnode.state.error('Error: ' + errMsg)
+                            if (err.errors !== undefined) {
+                                var re = /protected\ property/i
+                                var protected_props = []
+                                err.errors.forEach(function(error) {
+                                    if (re.test(error)) {
+                                        prop = error.split(':')[1].trim()
+                                        vnode.state.fixTag(vnode, prop)
+                                        protected_props.push(prop)
+                                    }
+                                })
+                                if (protected_props.length > 0) {
+                                    errMsg = "Protected properties cannot be updated: " + protected_props.join(', ')
+                                } else {
+                                    errMsg = errors.join(', ')
+                                }
+                            } else {
+                                errMsg = err
+                            }
+                            vnode.state.error(errMsg)
                         })
                     }
                 }, vnode.state.dirty() ? ' Save changes ' : ' Saved '),
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 83bb604c4..c92b94516 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -697,7 +697,10 @@ class Collection < ArvadosModel
     # Pre-existent protected properties can't be updated
     invalid_updates = properties_was.keys.select{|p| properties_was[p] != properties[p]} & protected_props
     if !invalid_updates.empty?
-      raise PermissionDeniedError.new("protected properties cannot be updated: #{invalid_updates.join(', ')}")
+      invalid_updates.each do |p|
+        errors.add("protected property cannot be updated:", p)
+      end
+      raise PermissionDeniedError.new
     end
     true
   end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list