fix: remove import/export options for db graphs

pull/11433/head
Tienson Qin 2024-07-25 15:50:12 +08:00
parent bcecedb909
commit 66fcaf0c1f
2 changed files with 100 additions and 91 deletions

View File

@ -18,44 +18,48 @@
(rum/defc export (rum/defc export
[] []
(when-let [current-repo (state/get-current-repo)] (when-let [current-repo (state/get-current-repo)]
[:div.export (let [db-based? (config/db-based-graph? current-repo)]
[:h1.title (t :export)] [:div.export
[:ul.mr-1 [:h1.title (t :export)]
[:li.mb-4 [:ul.mr-1
[:a.font-medium {:on-click #(export/export-repo-as-edn! current-repo)} (when-not db-based?
(t :export-edn)]] [:li.mb-4
[:li.mb-4 [:a.font-medium {:on-click #(export/export-repo-as-edn! current-repo)}
[:a.font-medium {:on-click #(export/export-repo-as-json! current-repo)} (t :export-edn)]])
(t :export-json)]] (when-not db-based?
(when (config/db-based-graph? current-repo) [:li.mb-4
[:li.mb-4 [:a.font-medium {:on-click #(export/export-repo-as-json! current-repo)}
[:a.font-medium {:on-click #(export/export-repo-as-sqlite-db! current-repo)} (t :export-json)]])
(t :export-sqlite-db)]]) (when (config/db-based-graph? current-repo)
(when (util/electron?) [:li.mb-4
[:li.mb-4 [:a.font-medium {:on-click #(export/export-repo-as-sqlite-db! current-repo)}
[:a.font-medium {:on-click #(export/download-repo-as-html! current-repo)} (t :export-sqlite-db)]])
(t :export-public-pages)]]) (when-not db-based?
(when-not (mobile-util/native-platform?) (when (util/electron?)
[:li.mb-4 [:li.mb-4
[:a.font-medium {:on-click #(export-text/export-repo-as-markdown! current-repo)} [:a.font-medium {:on-click #(export/download-repo-as-html! current-repo)}
(t :export-markdown)]]) (t :export-public-pages)]]))
(when-not (mobile-util/native-platform?) (when-not (or (mobile-util/native-platform?) db-based?)
[:li.mb-4 [:li.mb-4
[:a.font-medium {:on-click #(export-opml/export-repo-as-opml! current-repo)} [:a.font-medium {:on-click #(export-text/export-repo-as-markdown! current-repo)}
(t :export-opml)]]) (t :export-markdown)]])
(when-not (mobile-util/native-platform?) (when-not (or (mobile-util/native-platform?) db-based?)
[:li.mb-4 [:li.mb-4
[:a.font-medium {:on-click #(export/export-repo-as-roam-json! current-repo)} [:a.font-medium {:on-click #(export-opml/export-repo-as-opml! current-repo)}
(t :export-roam-json)]])] (t :export-opml)]])
[:a#download-as-edn-v2.hidden] (when-not (or (mobile-util/native-platform?) db-based?)
[:a#download-as-json-v2.hidden] [:li.mb-4
[:a#download-as-sqlite-db.hidden] [:a.font-medium {:on-click #(export/export-repo-as-roam-json! current-repo)}
[:a#download-as-roam-json.hidden] (t :export-roam-json)]])]
[:a#download-as-html.hidden] [:a#download-as-edn-v2.hidden]
[:a#download-as-zip.hidden] [:a#download-as-json-v2.hidden]
[:a#export-as-markdown.hidden] [:a#download-as-sqlite-db.hidden]
[:a#export-as-opml.hidden] [:a#download-as-roam-json.hidden]
[:a#convert-markdown-to-unordered-list-or-heading.hidden]])) [:a#download-as-html.hidden]
[:a#download-as-zip.hidden]
[:a#export-as-markdown.hidden]
[:a#export-as-opml.hidden]
[:a#convert-markdown-to-unordered-list-or-heading.hidden]])))
(def *export-block-type (atom :text)) (def *export-block-type (atom :text))

View File

@ -374,7 +374,8 @@
(rum/defc importer < rum/reactive (rum/defc importer < rum/reactive
[{:keys [query-params]}] [{:keys [query-params]}]
(let [db-based? (config/db-based-graph? (state/get-current-repo))]
(if (state/sub :graph/importing) (if (state/sub :graph/importing)
(let [{:keys [total current-idx current-page]} (state/sub :graph/importing-state) (let [{:keys [total current-idx current-page]} (state/sub :graph/importing-state)
left-label (if (and current-idx total (= current-idx total)) left-label (if (and current-idx total (= current-idx total))
@ -396,63 +397,67 @@
[:h1 (t :on-boarding/importing-title)] [:h1 (t :on-boarding/importing-title)]
[:h2 (t :on-boarding/importing-desc)]] [:h2 (t :on-boarding/importing-desc)]]
[:section.d.md:flex.flex-col [:section.d.md:flex.flex-col
[:label.action-input.flex.items-center.mx-2.my-2 (when db-based?
[:span.as-flex-center [:i (svg/logo 28)]] [:label.action-input.flex.items-center.mx-2.my-2
[:span.flex.flex-col [:span.as-flex-center [:i (svg/logo 28)]]
[[:strong "SQLite"] [:span.flex.flex-col
[:small (t :on-boarding/importing-sqlite-desc)]]] [[:strong "SQLite"]
[:input.absolute.hidden [:small (t :on-boarding/importing-sqlite-desc)]]]
{:id "import-sqlite-db" [:input.absolute.hidden
:type "file" {:id "import-sqlite-db"
:on-change (fn [e] :type "file"
(shui/dialog-open! :on-change (fn [e]
#(set-graph-name-dialog e {:sqlite? true})))}]] (shui/dialog-open!
#(set-graph-name-dialog e {:sqlite? true})))}]])
(when (or util/electron? util/web-platform?) (when (and db-based? (or util/electron? util/web-platform?))
[:label.action-input.flex.items-center.mx-2.my-2 [:label.action-input.flex.items-center.mx-2.my-2
[:span.as-flex-center [:i (svg/logo 28)]] [:span.as-flex-center [:i (svg/logo 28)]]
[:span.flex.flex-col [:span.flex.flex-col
[[:strong "File to DB graph"] [[:strong "File to DB graph"]
[:small "Import a file-based Logseq graph folder into a new DB graph"]]] [:small "Import a file-based Logseq graph folder into a new DB graph"]]]
[:input.absolute.hidden [:input.absolute.hidden
{:id "import-file-graph" {:id "import-file-graph"
:type "file" :type "file"
:webkitdirectory "true" :webkitdirectory "true"
:on-change (debounce (fn [e] :on-change (debounce (fn [e]
(import-file-to-db-handler e {})) (import-file-to-db-handler e {}))
1000)}]]) 1000)}]])
[:label.action-input.flex.items-center.mx-2.my-2 (when-not db-based?
[:span.as-flex-center [:i (svg/logo 28)]] [:label.action-input.flex.items-center.mx-2.my-2
[:span.flex.flex-col [:span.as-flex-center [:i (svg/logo 28)]]
[[:strong "EDN / JSON"] [:span.flex.flex-col
[:small (t :on-boarding/importing-lsq-desc)]]] [[:strong "EDN / JSON"]
[:input.absolute.hidden [:small (t :on-boarding/importing-lsq-desc)]]]
{:id "import-lsq" [:input.absolute.hidden
:type "file" {:id "import-lsq"
:on-change lsq-import-handler}]] :type "file"
:on-change lsq-import-handler}]])
[:label.action-input.flex.items-center.mx-2.my-2 (when-not db-based?
[:span.as-flex-center [:i (svg/roam-research 28)]] [:label.action-input.flex.items-center.mx-2.my-2
[:div.flex.flex-col [:span.as-flex-center [:i (svg/roam-research 28)]]
[[:strong "RoamResearch"] [:div.flex.flex-col
[:small (t :on-boarding/importing-roam-desc)]]] [[:strong "RoamResearch"]
[:input.absolute.hidden [:small (t :on-boarding/importing-roam-desc)]]]
{:id "import-roam" [:input.absolute.hidden
:type "file" {:id "import-roam"
:on-change roam-import-handler}]] :type "file"
:on-change roam-import-handler}]])
[:label.action-input.flex.items-center.mx-2.my-2 (when-not db-based?
[:span.as-flex-center.ml-1 (ui/icon "sitemap" {:size 26})] [:label.action-input.flex.items-center.mx-2.my-2
[:span.flex.flex-col [:span.as-flex-center.ml-1 (ui/icon "sitemap" {:size 26})]
[[:strong "OPML"] [:span.flex.flex-col
[:small (t :on-boarding/importing-opml-desc)]]] [[:strong "OPML"]
[:small (t :on-boarding/importing-opml-desc)]]]
[:input.absolute.hidden [:input.absolute.hidden
{:id "import-opml" {:id "import-opml"
:type "file" :type "file"
:on-change opml-import-handler}]]] :on-change opml-import-handler}]])]
(when (= "picker" (:from query-params)) (when (= "picker" (:from query-params))
[:section.e [:section.e
[:a.button {:on-click #(route-handler/redirect-to-home!)} "Skip"]])]))) [:a.button {:on-click #(route-handler/redirect-to-home!)} "Skip"]])]))))