From 31e3795ed07f3a8bc2817c0775237c1318999868 Mon Sep 17 00:00:00 2001 From: Thomas Schank Date: Fri, 14 Jul 2017 08:55:05 +0200 Subject: [PATCH] 0.6.0 Fix basic-auth sign in; improve UX of sign-in --- app/dev/releases.json | 2 +- app/prod/releases.json | 2 +- bin/draft-gh-release | 4 +- .../src/all/madek/app/front/connection.cljs | 69 ++++++++++++------- jvm_main/src/madek/app/server/connection.clj | 2 +- jvm_main/src/madek/app/server/utils.clj | 12 ++-- releases.yml | 23 ++++++- 7 files changed, 75 insertions(+), 39 deletions(-) diff --git a/app/dev/releases.json b/app/dev/releases.json index 9402ddc..2c2a6ab 100644 --- a/app/dev/releases.json +++ b/app/dev/releases.json @@ -1 +1 @@ -[{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}] \ No newline at end of file +[{"version_major":0,"version_minor":6,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Improve the UX of the sign-in page: swapping tags deletes existing sign in info.\n\nFixes\n=====\n\n* Fix sign in with login and password.\n"},{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}] \ No newline at end of file diff --git a/app/prod/releases.json b/app/prod/releases.json index 9402ddc..2c2a6ab 100644 --- a/app/prod/releases.json +++ b/app/prod/releases.json @@ -1 +1 @@ -[{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}] \ No newline at end of file +[{"version_major":0,"version_minor":6,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Improve the UX of the sign-in page: swapping tags deletes existing sign in info.\n\nFixes\n=====\n\n* Fix sign in with login and password.\n"},{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}] \ No newline at end of file diff --git a/bin/draft-gh-release b/bin/draft-gh-release index fc27f9f..cd4852d 100755 --- a/bin/draft-gh-release +++ b/bin/draft-gh-release @@ -33,8 +33,8 @@ def version end def commitish - JSON.parse(ENV['CIDER_CI_CURRENT_BRANCH_HEADS']).first.presence.try(:strip) \ - || `git log -n 1 --pretty='%H'`.strip + JSON.parse(ENV['CIDER_CI_CURRENT_BRANCH_HEADS'].presence || "[]").compact \ + .first.presence.try(:strip) || `git log -n 1 --pretty='%H'`.strip end def create_data diff --git a/electron_front/src/all/madek/app/front/connection.cljs b/electron_front/src/all/madek/app/front/connection.cljs index ce820ba..dcbf03c 100644 --- a/electron_front/src/all/madek/app/front/connection.cljs +++ b/electron_front/src/all/madek/app/front/connection.cljs @@ -35,30 +35,8 @@ (when-let [p (.getPort gurl)] (str ":" p))))))) -(defn compact-component [] - [:span - (when-let [ce @connected-entity*] - [:span ce]) - (when-let [ct @connected-target*] - [:span - " " ; utf-8 m-space! - [:span ct ]])]) -(defn connect [] - (let [req {:method :post - :json-params @form-data - :path "/connect"}] - (request/send-off - req {:title "Connect!"}))) - -(defn disconnect [] - (let [req {:method :delete - :path "/connect"}] - (request/send-off - req {:title "Disconnect!"} - :callback (fn [_] - (swap! state/client-db assoc-in [:connection :form :password] nil) - (accountant/navigate! "/connection"))))) +;;; data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn update-form-data [fun] (swap! state/client-db @@ -83,6 +61,42 @@ (reaction (or (:sign-in-method @form-data) :token))) + +;;; connect ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn compact-component [] + [:span + (when-let [ce @connected-entity*] + [:span ce]) + (when-let [ct @connected-target*] + [:span + " " ; utf-8 m-space! + [:span ct ]])]) + +(defn connect [] + (let [req {:method :post + :json-params @form-data + :path "/connect"}] + (request/send-off + req {:title "Connect!"}))) + + +;;; disconnect ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn clear-form-sign-in-data [] + (update-form-data-value :login nil) + (update-form-data-value :password nil)) + +(defn disconnect [] + (let [req {:method :delete + :path "/connect"}] + (request/send-off + req {:title "Disconnect!"} + :callback (fn [_] + (clear-form-sign-in-data) + (accountant/navigate! "/connection"))))) + + ;;; form ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn base-url-form-component [] @@ -125,17 +139,22 @@ :on-change #(update-form-data-value :password(-> % .-target .-value presence))}]]) + (defn connect-form [] [:div.form [base-url-form-component] [:ul.nav.nav-tabs {:style {:margin-bottom "1em"}} [:li {:class (when (= @sign-in-method* :token) "active")} [:a {:href "#" - :on-click #(update-form-data-value :sign-in-method :token)} + :on-click (fn [_] + (clear-form-sign-in-data) + (update-form-data-value :sign-in-method :token))} "Sign in with token"]] [:li {:class (when (= @sign-in-method* :login) "active")} [:a {:href "#" - :on-click #(update-form-data-value :sign-in-method :login)} + :on-click (fn [_] + (clear-form-sign-in-data) + (update-form-data-value :sign-in-method :login))} "Sign in with login and password"]]] [login-form-component] [token-form-component] diff --git a/jvm_main/src/madek/app/server/connection.clj b/jvm_main/src/madek/app/server/connection.clj index 619f750..657559e 100644 --- a/jvm_main/src/madek/app/server/connection.clj +++ b/jvm_main/src/madek/app/server/connection.clj @@ -65,4 +65,4 @@ ;(logging-config/set-logger! :level :debug) ;(logging-config/set-logger! :level :info) ;(debug/debug-ns 'ring.middleware.resource) -(debug/debug-ns *ns*) +;(debug/debug-ns *ns*) diff --git a/jvm_main/src/madek/app/server/utils.clj b/jvm_main/src/madek/app/server/utils.clj index 18bbfb7..5f24467 100644 --- a/jvm_main/src/madek/app/server/utils.clj +++ b/jvm_main/src/madek/app/server/utils.clj @@ -40,14 +40,10 @@ (defn options-to-http-options [options] (let [{login :login password :password session-token :session-token} options] - (cond-> {} - (and (presence login) - (presence password)) (assoc :basic-auth - [login password]) - (presence password) (assoc :basic-auth [password]) - session-token (assoc :cookies - {"madek-session" - {:value session-token}})))) + (if (and (presence login) + (presence password)) + {:basic-auth [login password]} + {:basic-auth [password]}))) (defn str "Like clojure.core/str but maps keywords to strings without preceding colon." diff --git a/releases.yml b/releases.yml index bc3299e..50e48f3 100644 --- a/releases.yml +++ b/releases.yml @@ -1,4 +1,25 @@ -### 5.0 ####################################################################### +#### 0.6.0 ####################################################################### + +- version_major: 0 + version_minor: 6 + version_patch: 0 + version_pre: NULL + version_build: NULL + name: NULL + + description: | + + Changes + ======= + + * Improve the UX of the sign-in page: swapping tags deletes existing sign in info. + + Fixes + ===== + + * Fix sign in with login and password. + +### 0.5.0 ####################################################################### - version_major: 0 version_minor: 5