enhance: page history support reverting back

pull/2777/head
Tienson Qin 2021-09-06 11:49:58 +08:00
parent 7273112a00
commit eec677873b
3 changed files with 20 additions and 5 deletions

View File

@ -3,7 +3,9 @@
[frontend.ui :as ui]
[frontend.util :as util]
[clojure.string :as string]
[frontend.handler.shell :as shell]))
[frontend.handler.shell :as shell]
[frontend.handler.file :as file]
[frontend.state :as state]))
(rum/defcs set-git-username-and-email <
(rum/local "" ::username)
@ -43,3 +45,16 @@
(not (string/blank? email)))
(shell/set-git-username-and-email username email))))}
"Submit"]]]]))
(rum/defc file-specific-version
[path hash content]
[:div.w-full.sm:max-w-lg {:style {:width 700}}
[:div.font-bold.mb-4 (str path (util/format " (%s)" hash)) ]
[:pre content]
(ui/button "Revert"
:on-click (fn []
(file/alter-file (state/get-current-repo)
path
content
{:re-render-root? true
:skip-compare? true})))])

View File

@ -158,6 +158,9 @@
(when-let [repo (state/get-current-repo)]
(state/set-modal! #(diff/local-file repo path disk-content db-content))))
(defmethod handle :modal/display-file-version [[_ path content hash]]
(state/set-modal! #(git-component/file-specific-version path hash content)))
(defmethod handle :after-db-restore [[_ repos]]
(mapv (fn [{url :url} repo]
;; compare :ast/version

View File

@ -53,10 +53,7 @@
local-dir (config/get-local-dir repo)
path (string/replace path (str local-dir "/") "")]
(p/let [content (run-git-command! ["show" (str hash ":" path)])]
(state/pub-event! [:modal/show
[:div.w-full.sm:max-w-lg {:style {:width 700}}
[:div.font-bold.mb-4 (str path (util/format " (%s)" hash)) ]
[:pre content]]])))))
(state/pub-event! [:modal/display-file-version path content hash])))))
(defn get-file-latest-git-log
[page n]