       (cond
         (= code-format "blockly")
         (do
-          (swap! app-state assoc-in [:ui :ui :editor :mode] "blockly")
+          (swap! app-state assoc-in [:ui :editor :mode] "blockly")
           ;(js/alert  (str (:blockly app-code-resp)))
           (js/setBlocklyXml (str (:blockly app-code-resp)))
           (js/populateEditor app-code-value)



                      (if (get @can-use-interfaces "edit.my.database")
                        (span {:onClick #(go  (let [old-app-id   (read-ui app [:app-id])]
                                                (write-ui app [:mode] "view")
                                                (write-ui app [:app-id] (get @can-use-interfaces "edit.my.database"))
                                                (evalapp (get @can-use-interfaces "edit.my.database")   old-app-id nil))
                                              )} "Data | "))


     ;(js/alert (str "(get @app-state :ui :editor :mode):" (get @app-state :ui :editor :mode)))
    (let [
           code             (cond
                              (= (get-in @app-state [:ui :editor :mode])  "text")
                                     (js/getCodeMirrorValue)

                              (= (get-in @app-state [:ui :editor :mode])  "blockly")
                                     (js/getBlocklyValue))

           blockly-xml      (if (= (get-in @app-state [:ui :editor :mode])  "blockly")
                              (js/getBlocklyXml))

           app-session-id   (str (js/getappsessionid) )
           ]

      (if
        (= (get-in @app-state [:ui :editor :mode])  "text")
        (do
          (remote !savecode {:id                 app-id
                             :code               (subs code 0 2000)
