|
|
@@ -99,96 +99,87 @@
|
|
|
state)}
|
|
|
[repo]
|
|
|
(when repo
|
|
|
- (let [nfs-repo? (config/local-db? repo)]
|
|
|
- (when-not (= repo config/local-repo)
|
|
|
- (if (and nfs-repo? (nfs-handler/supported?))
|
|
|
- (let [syncing? (state/sub :graph/syncing?)]
|
|
|
- [:div.opacity-60.refresh.hover:opacity-100
|
|
|
- [:a.button
|
|
|
- {:on-click #(nfs-handler/refresh! repo refresh-cb)
|
|
|
- :title (str "Import files from the local directory: " (config/get-local-dir repo) ".\nVersion: "
|
|
|
- version/version)}
|
|
|
- [:div {:class (if syncing? "animate-spin-reverse" "initial")} 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)
|
|
|
- git-failed? (contains?
|
|
|
- #{:push-failed
|
|
|
- :clone-failed
|
|
|
- :checkout-failed
|
|
|
- :fetch-failed
|
|
|
- :merge-failed}
|
|
|
- git-status)
|
|
|
- push-failed? (= :push-failed git-status)
|
|
|
- last-pulled-at (db/sub-key-value repo :git/last-pulled-at)
|
|
|
- ;; db-persisted? (state/sub [:db/persisted? repo])
|
|
|
- editing? (seq (state/sub :editor/editing?))]
|
|
|
- [:div.flex-row.flex.items-center.cp__repo-indicator
|
|
|
- (when pushing? svg/loading)
|
|
|
- (ui/dropdown
|
|
|
- (fn [{:keys [toggle-fn]}]
|
|
|
- [:div.cursor.w-2.h-2.sync-status.mr-2
|
|
|
- {:class (cond
|
|
|
- git-failed?
|
|
|
- "bg-red-500"
|
|
|
- (or
|
|
|
- ;; (not db-persisted?)
|
|
|
- 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.overflow-y-auto {:style {:max-height 250}}
|
|
|
- (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)]]]])]]
|
|
|
+ (when (string/starts-with? repo "https://")
|
|
|
+ (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)
|
|
|
+ git-failed? (contains?
|
|
|
+ #{:push-failed
|
|
|
+ :clone-failed
|
|
|
+ :checkout-failed
|
|
|
+ :fetch-failed
|
|
|
+ :merge-failed}
|
|
|
+ git-status)
|
|
|
+ push-failed? (= :push-failed git-status)
|
|
|
+ last-pulled-at (db/sub-key-value repo :git/last-pulled-at)
|
|
|
+ ;; db-persisted? (state/sub [:db/persisted? repo])
|
|
|
+ editing? (seq (state/sub :editor/editing?))]
|
|
|
+ [:div.flex-row.flex.items-center.cp__repo-indicator
|
|
|
+ (when pushing? svg/loading)
|
|
|
+ (ui/dropdown
|
|
|
+ (fn [{:keys [toggle-fn]}]
|
|
|
+ [:div.cursor.w-2.h-2.sync-status.mr-2
|
|
|
+ {:class (cond
|
|
|
+ git-failed?
|
|
|
+ "bg-red-500"
|
|
|
+ (or
|
|
|
+ ;; (not db-persisted?)
|
|
|
+ editing?
|
|
|
+ should-push? pushing?)
|
|
|
+ "bg-orange-400"
|
|
|
: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? svg/loading)]]
|
|
|
- [: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? svg/loading)]
|
|
|
- [: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)]]])))]))))))
|
|
|
+ "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.overflow-y-auto {:style {:max-height 250}}
|
|
|
+ (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? svg/loading)]]
|
|
|
+ [: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? svg/loading)]
|
|
|
+ [: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
|
|
|
[on-click]
|