Browse Source

feat(chrome native): multiple graphs picker

Tienson Qin 4 years ago
parent
commit
3f6c09935c

+ 3 - 3
src/main/frontend/components/header.cljs

@@ -113,8 +113,8 @@
   (rum/with-context [[t] i18n/*tongue-context*]
     [:div.cp__header#head
      (left-menu-button {:on-click (fn []
-                               (open-fn)
-                               (state/set-left-sidebar-open! true))})
+                                    (open-fn)
+                                    (state/set-left-sidebar-open! true))})
 
      (logo {:white? white?})
 
@@ -127,7 +127,7 @@
      [:a.text-sm.font-medium.login.opacity-70.hover:opacity-100.mr-4
       {:on-click (fn []
                    (nfs/ls-dir-files))}
-      "Open a database"]
+      "Open a directory"]
 
      (when (and (not logged?)
                 (not config/publishing?))

+ 75 - 72
src/main/frontend/components/repo.cljs

@@ -13,6 +13,7 @@
             [reitit.frontend.easy :as rfe]
             [frontend.version :as version]
             [frontend.components.commit :as commit]
+            [frontend.components.svg :as svg]
             [frontend.context.i18n :as i18n]
             [clojure.string :as string]))
 
@@ -66,78 +67,80 @@
   []
   (let [repo (state/get-current-repo)]
     (when-not (= repo config/local-repo)
-      (let [changed-files (state/sub [:repo/changed-files repo])
-            should-push? (seq changed-files)
-            git-status (state/sub [:git/status repo])
-            pushing? (= :pushing git-status)
-            pulling? (= :pulling git-status)
-            push-failed? (= :push-failed git-status)
-            last-pulled-at (db/sub-key-value repo :git/last-pulled-at)
-            editing? (seq (state/sub :editor/editing?))]
-        [:div.flex-row.flex.items-center
-         (when pushing?
-           [:span.lds-dual-ring.mt-1])
-         (ui/dropdown
-          (fn [{:keys [toggle-fn]}]
-            [:div.cursor.w-2.h-2.sync-status.mr-2
-             {:class (cond
-                       push-failed?
-                       "bg-red-500"
-                       (or editing? should-push? pushing?)
-                       "bg-orange-400"
-                       :else
-                       "bg-green-600")
-              :style {:border-radius "50%"
-                      :margin-top 2}
-              :on-mouse-over
-              (fn [e]
-                (toggle-fn)
-                (js/setTimeout common-handler/check-changed-files-status 0))}])
-          (fn [{:keys [toggle-fn]}]
-            (rum/with-context [[t] i18n/*tongue-context*]
-              [:div.p-2.rounded-md.shadow-xs.bg-base-3.flex.flex-col.sync-content
-               {:on-mouse-leave toggle-fn}
-               [:div
-                [:div
-                 (cond
-                   push-failed?
-                   [:p (t :git/push-failed)]
-                   (and should-push? (seq changed-files))
-                   [:div.changes
-                    [:ul
-                     (for [file changed-files]
-                       [:li {:key (str "sync-" file)}
-                        [:div.flex.flex-row.justify-between.align-items
-                         [:a {:href (rfe/href :file {:path file})}
-                          file]
-                         [:a.ml-4.text-sm.mt-1
-                          {:on-click (fn [e]
-                                       (export-handler/download-file! file))}
-                          [:span (t :download)]]]])]]
-                   :else
-                   [:p (t :git/local-changes-synced)])]
-        ;; [:a.text-sm.font-bold {:href "/diff"} "Check diff"]
-                [:div.flex.flex-row.justify-between.align-items.mt-2
-                 (ui/button (t :git/push)
-                            :on-click (fn [] (state/set-modal! commit/add-commit-message)))
-                 (if pushing?
-                   [:span.lds-dual-ring.mt-1])]]
-               [:hr]
-               [:div
-                (when-not (string/blank? last-pulled-at)
-                  [:p {:style {:font-size 12}} (t :git/last-pull)
-                   (str ": " last-pulled-at)])
-                [:div.flex.flex-row.justify-between.align-items
-                 (ui/button (t :git/pull)
-                            :on-click (fn [] (repo-handler/pull-current-repo)))
-                 (if pulling?
-                   [:span.lds-dual-ring.mt-1])]
-                [:a.mt-5.text-sm.opacity-50.block
-                 {:on-click (fn []
-                              (export-handler/export-repo-as-zip! repo))}
-                 (t :repo/download-zip)]
-                [:p.pt-2.text-sm.opacity-50
-                 (t :git/version) (str " " version/version)]]])))]))))
+      (if (config/local-db? repo)
+        [:a.ml-2.mr-1.opacity-70.hover:opacity-100 svg/refresh]
+        (let [changed-files (state/sub [:repo/changed-files repo])
+              should-push? (seq changed-files)
+              git-status (state/sub [:git/status repo])
+              pushing? (= :pushing git-status)
+              pulling? (= :pulling git-status)
+              push-failed? (= :push-failed git-status)
+              last-pulled-at (db/sub-key-value repo :git/last-pulled-at)
+              editing? (seq (state/sub :editor/editing?))]
+          [:div.flex-row.flex.items-center
+           (when pushing?
+             [:span.lds-dual-ring.mt-1])
+           (ui/dropdown
+            (fn [{:keys [toggle-fn]}]
+              [:div.cursor.w-2.h-2.sync-status.mr-2
+               {:class (cond
+                         push-failed?
+                         "bg-red-500"
+                         (or editing? should-push? pushing?)
+                         "bg-orange-400"
+                         :else
+                         "bg-green-600")
+                :style {:border-radius "50%"
+                        :margin-top 2}
+                :on-mouse-over
+                (fn [e]
+                  (toggle-fn)
+                  (js/setTimeout common-handler/check-changed-files-status 0))}])
+            (fn [{:keys [toggle-fn]}]
+              (rum/with-context [[t] i18n/*tongue-context*]
+                [:div.p-2.rounded-md.shadow-xs.bg-base-3.flex.flex-col.sync-content
+                 {:on-mouse-leave toggle-fn}
+                 [:div
+                  [:div
+                   (cond
+                     push-failed?
+                     [:p (t :git/push-failed)]
+                     (and should-push? (seq changed-files))
+                     [:div.changes
+                      [:ul
+                       (for [file changed-files]
+                         [:li {:key (str "sync-" file)}
+                          [:div.flex.flex-row.justify-between.align-items
+                           [:a {:href (rfe/href :file {:path file})}
+                            file]
+                           [:a.ml-4.text-sm.mt-1
+                            {:on-click (fn [e]
+                                         (export-handler/download-file! file))}
+                            [:span (t :download)]]]])]]
+                     :else
+                     [:p (t :git/local-changes-synced)])]
+                 ;; [:a.text-sm.font-bold {:href "/diff"} "Check diff"]
+                  [:div.flex.flex-row.justify-between.align-items.mt-2
+                   (ui/button (t :git/push)
+                              :on-click (fn [] (state/set-modal! commit/add-commit-message)))
+                   (if pushing?
+                     [:span.lds-dual-ring.mt-1])]]
+                 [:hr]
+                 [:div
+                  (when-not (string/blank? last-pulled-at)
+                    [:p {:style {:font-size 12}} (t :git/last-pull)
+                     (str ": " last-pulled-at)])
+                  [:div.flex.flex-row.justify-between.align-items
+                   (ui/button (t :git/pull)
+                              :on-click (fn [] (repo-handler/pull-current-repo)))
+                   (if pulling?
+                     [:span.lds-dual-ring.mt-1])]
+                  [:a.mt-5.text-sm.opacity-50.block
+                   {:on-click (fn []
+                                (export-handler/export-repo-as-zip! repo))}
+                   (t :repo/download-zip)]
+                  [:p.pt-2.text-sm.opacity-50
+                   (t :git/version) (str " " version/version)]]])))])))))
 
 (rum/defc repos-dropdown < rum/reactive
   [head? on-click]

+ 4 - 0
src/main/frontend/components/svg.cljs

@@ -85,6 +85,10 @@
       :stroke "currentColor"
       :d d}]]))
 
+(def refresh
+  (hero-icon "M4 4V9H4.58152M19.9381 11C19.446 7.05369 16.0796 4 12 4C8.64262 4 5.76829 6.06817 4.58152 9M4.58152 9H9M20 20V15H19.4185M19.4185 15C18.2317 17.9318 15.3574 20 12 20C7.92038 20 4.55399 16.9463 4.06189 13M19.4185 15H15"
+             {:fill "none"}))
+
 (def user
   [:svg
    {:stroke-linejoin "round"