enhance: add sync from local files (the old refresh way)

pull/2777/head
Tienson Qin 2021-09-06 17:57:33 +08:00
parent a16e5c98ba
commit 571c81af30
2 changed files with 91 additions and 93 deletions

View File

@ -90,18 +90,8 @@
(js/setTimeout common-handler/check-changed-files-status 1000) (js/setTimeout common-handler/check-changed-files-status 1000)
state)} state)}
[repo] [repo]
(when repo (when (and repo
(when-not (or (util/electron?) (string/starts-with? repo "https://"))
(= repo config/local-repo))
(let [nfs-repo? (config/local-db? 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]) (let [changed-files (state/sub [:repo/changed-files repo])
should-push? (seq changed-files) should-push? (seq changed-files)
git-status (state/sub [:git/status repo]) git-status (state/sub [:git/status repo])
@ -181,7 +171,7 @@
(export-handler/export-repo-as-zip! repo))} (export-handler/export-repo-as-zip! repo))}
(t :repo/download-zip)] (t :repo/download-zip)]
[:p.pt-2.text-sm.opacity-50 [:p.pt-2.text-sm.opacity-50
(t :git/version) (str " " version/version)]]])))])))))) (t :git/version) (str " " version/version)]]])))])))
(rum/defc repos-dropdown < rum/reactive (rum/defc repos-dropdown < rum/reactive
[on-click] [on-click]
@ -235,6 +225,13 @@
[:a {:class "block px-4 py-2 text-sm transition ease-in-out duration-150 cursor menu-link" [:a {:class "block px-4 py-2 text-sm transition ease-in-out duration-150 cursor menu-link"
:href (rfe/href :repos)} :href (rfe/href :repos)}
(t :all-graphs)] (t :all-graphs)]
(let [nfs-repo? (config/local-db? current-repo)]
(when (and nfs-repo?
(not= current-repo config/local-repo)
(nfs-handler/supported?))
[:a {:class "block px-4 py-2 text-sm transition ease-in-out duration-150 cursor menu-link"
:on-click #(nfs-handler/refresh! (state/get-current-repo) refresh-cb)}
(t :sync-from-local-files)]))
[:a {:class "block px-4 py-2 text-sm transition ease-in-out duration-150 cursor menu-link" [:a {:class "block px-4 py-2 text-sm transition ease-in-out duration-150 cursor menu-link"
:on-click (fn [] :on-click (fn []
(repo-handler/re-index! (repo-handler/re-index!

View File

@ -250,7 +250,8 @@
:cancel "Cancel" :cancel "Cancel"
:close "Close" :close "Close"
:delete "Delete" :delete "Delete"
:re-index "Re-index" :re-index "Re-index (rebuild the graph)"
:sync-from-local-files "Sync from local files"
:unlink "unlink" :unlink "unlink"
:search (if config/publishing? :search (if config/publishing?
"Search" "Search"