mirror of https://github.com/logseq/logseq
enhance: dev command to update db graph with its db.sqlite
parent
0fc1fd0f15
commit
f7e890b662
|
@ -383,7 +383,7 @@
|
|||
(let [command (some-> state state->highlighted-item :source-command)]
|
||||
(when-let [action (:action command)]
|
||||
(action)
|
||||
(when-not (contains? #{:graph/open :graph/remove :ui/toggle-settings :go/flashcards} (:id command))
|
||||
(when-not (contains? #{:graph/open :graph/remove :dev/replace-graph-with-db-file :ui/toggle-settings :go/flashcards} (:id command))
|
||||
(state/close-modal!)))))
|
||||
|
||||
(defmethod handle-action :create [_ state _event]
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
[rum.core :as rum]
|
||||
[frontend.config :as config]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.common.developer :as dev-common-handler]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
[clojure.string :as string]))
|
||||
|
||||
|
@ -203,7 +204,20 @@
|
|||
:id (config/get-repo-dir url)
|
||||
:graph url
|
||||
:original-graph original-graph}))))
|
||||
:on-chosen #(repo-handler/remove-repo! (:original-graph %))}})
|
||||
:on-chosen #(repo-handler/remove-repo! (:original-graph %))}
|
||||
:db-graph-replace
|
||||
{:items-fn (fn []
|
||||
(let [current-repo (state/get-current-repo)]
|
||||
(->> (state/get-repos)
|
||||
(remove (fn [{:keys [url]}]
|
||||
;; Can't replace current graph as ui wouldn't reload properly
|
||||
(or (= url current-repo) (not (config/db-based-graph? url)))))
|
||||
(map (fn [{:keys [url] :as original-graph}]
|
||||
{:value (text-util/get-graph-name-from-path url)
|
||||
:id (config/get-repo-dir url)
|
||||
:graph url
|
||||
:original-graph original-graph})))))
|
||||
:on-chosen #(dev-common-handler/import-chosen-graph (:graph %))}})
|
||||
|
||||
(rum/defc select-modal < rum/reactive
|
||||
[]
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
[frontend.util.page :as page-util]
|
||||
[frontend.handler.db-based.property.util :as db-pu]
|
||||
[frontend.format.mldoc :as mldoc]
|
||||
[frontend.config :as config]))
|
||||
[frontend.config :as config]
|
||||
[frontend.persist-db :as persist-db]
|
||||
[promesa.core :as p]))
|
||||
|
||||
;; Fns used between menus and commands
|
||||
(defn show-entity-data
|
||||
|
@ -69,3 +71,12 @@
|
|||
(if (get-in page-data [:block/file :file/content])
|
||||
(show-content-ast (get-in page-data [:block/file :file/content]) (:block/format page-data))
|
||||
(notification/show! "No page found" :warning)))))
|
||||
|
||||
(defn import-chosen-graph
|
||||
[repo]
|
||||
(p/let [_ (persist-db/<unsafe-delete repo)
|
||||
_ (persist-db/<fetch-init-data repo)]
|
||||
(notification/show! "Graph updated!" :success)))
|
||||
|
||||
(defn ^:export replace-graph-with-db-file []
|
||||
(state/set-state! :ui/open-select :db-graph-replace))
|
|
@ -551,6 +551,10 @@
|
|||
:file-graph? true
|
||||
:fn commit/show-commit-modal!}
|
||||
|
||||
:dev/replace-graph-with-db-file {:binding []
|
||||
:inactive (or (not (util/electron?)) (not (state/developer-mode?)))
|
||||
:fn :frontend.handler.common.developer/replace-graph-with-db-file}
|
||||
|
||||
:dev/show-block-data {:binding []
|
||||
:inactive (not (state/developer-mode?))
|
||||
:fn :frontend.handler.common.developer/show-block-data}
|
||||
|
@ -762,6 +766,7 @@
|
|||
:dev/show-block-ast
|
||||
:dev/show-page-data
|
||||
:dev/show-page-ast
|
||||
:dev/replace-graph-with-db-file
|
||||
:ui/cycle-color
|
||||
:ui/cycle-color-off])
|
||||
(with-meta {:before m/enable-when-not-editing-mode!}))
|
||||
|
@ -946,6 +951,7 @@
|
|||
:dev/show-block-ast
|
||||
:dev/show-page-data
|
||||
:dev/show-page-ast
|
||||
:dev/replace-graph-with-db-file
|
||||
:ui/clear-all-notifications]
|
||||
|
||||
:shortcut.category/plugins
|
||||
|
|
|
@ -824,4 +824,5 @@
|
|||
:dev/show-block-ast "(Dev) Show block AST"
|
||||
:dev/show-page-data "(Dev) Show page data"
|
||||
:dev/show-page-ast "(Dev) Show page AST"
|
||||
:dev/replace-graph-with-db-file "(Dev) Replace graph with its db.sqlite file"
|
||||
:window/close "Close window"}}
|
||||
|
|
Loading…
Reference in New Issue