Browse Source

enhance: put all export options together

Tienson Qin 4 years ago
parent
commit
86758c8007

+ 30 - 0
src/main/frontend/components/export.cljs

@@ -0,0 +1,30 @@
+(ns frontend.components.export
+  (:require [rum.core :as rum]
+            [frontend.ui :as ui]
+            [frontend.util :as util]
+            [frontend.handler.export :as export]
+            [frontend.state :as state]
+            [frontend.context.i18n :as i18n]))
+
+(rum/defc export
+  []
+  (when-let [current-repo (state/get-current-repo)]
+    (rum/with-context [[t] i18n/*tongue-context*]
+      [:div.export.w-96
+       [:h1.title "Export"]
+
+       [:ul.mr-1
+        (when (util/electron?)
+          [:li.mb-4
+           [:a.font-medium {:on-click #(export/export-repo-as-html! current-repo)}
+            (t :export-public-pages)]])
+        [:li.mb-4
+         [:a.font-medium {:on-click #(export/export-repo-as-markdown! current-repo)}
+          (t :export-markdown)]]
+        [:li.mb-4
+         [:a.font-medium {:on-click #(export/export-repo-as-edn! current-repo)}
+          (t :export-edn)]]]
+       [:a#download-as-edn.hidden]
+       [:a#download-as-html.hidden]
+       [:a#download-as-zip.hidden]
+       [:a#export-as-markdown.hidden]])))

+ 4 - 14
src/main/frontend/components/header.cljs

@@ -11,10 +11,10 @@
             [frontend.context.i18n :as i18n]
             [frontend.handler.ui :as ui-handler]
             [frontend.handler.user :as user-handler]
-            [frontend.handler.export :as export]
             [frontend.components.svg :as svg]
             [frontend.components.repo :as repo]
             [frontend.components.search :as search]
+            [frontend.components.export :as export]
             [frontend.handler.project :as project-handler]
             [frontend.handler.page :as page-handler]
             [frontend.handler.web.nfs :as nfs]
@@ -126,17 +126,11 @@
           :options {:on-click #(ui-handler/toggle-settings-modal!)}
           :icon svg/settings-sm})
 
-       (when (and (util/electron?) current-repo)
+       (when current-repo
          {:title (t :export)
-          :options {:on-click (fn []
-                                (export/export-repo-as-html! current-repo))}
+          :options {:on-click #(state/set-modal! export/export)}
           :icon nil})
 
-       (when current-repo
-         {:title (t :export-markdown)
-          :options {:on-click (fn []
-                                (export/export-repo-as-markdown! current-repo))}})
-
        (when current-repo
          {:title (t :import)
           :options {:href (rfe/href :import)}
@@ -218,8 +212,4 @@
        (dropdown-menu {:me me
                        :t t
                        :current-repo current-repo
-                       :default-home default-home})
-
-       [:a#download-as-html.hidden]
-       [:a#download-as-zip.hidden]
-       [:a#export-as-markdown.hidden]])))
+                       :default-home default-home})])))

+ 1 - 8
src/main/frontend/components/repo.cljs

@@ -78,17 +78,10 @@
                                   :on-click (fn []
                                               (repo-handler/re-index! nfs-handler/rebuild-index!))}
                  "Re-index"]
-                [:a.control.ml-4 {:title "Export as EDN"
-                                  :on-click (fn []
-                                              (export-handler/export-repo-as-edn! (:url repo)))}
-                 "Export as EDN"]
                 [:a.text-gray-400.ml-4 {:title "No worries, unlink this graph will clear its cache only, it does not remove your files on the disk."
                                         :on-click (fn []
                                                     (repo-handler/remove-repo! repo))}
-                 "Unlink"]]]))]
-
-         [:a#download-as-json.hidden]
-         [:a#download-as-edn.hidden]]
+                 "Unlink"]]]))]]
         (widgets/add-graph)))))
 
 (rum/defc sync-status < rum/reactive

+ 5 - 3
src/main/frontend/dicts.cljs

@@ -310,8 +310,6 @@ title: How to take dummy notes?
         :cancel "Cancel"
         :close "Close"
         :re-index "Re-index"
-        :export-json "Export as JSON"
-        :export-markdown "Export as Markdown"
         :unlink "unlink"
         :search (if config/publishing?
                   "Search"
@@ -321,7 +319,11 @@ title: How to take dummy notes?
         :graph "Graph"
         :graph-view "View Graph"
         :publishing "Publishing"
-        :export "Export public pages"
+        :export "Export"
+        :export-json "Export as JSON"
+        :export-markdown "Export as Markdown"
+        :export-public-pages "Export public pages"
+        :export-edn "Export as EDN"
         :all-graphs "All graphs"
         :all-pages "All pages"
         :all-files "All files"