diff --git a/src/main/frontend/components/home.cljs b/src/main/frontend/components/home.cljs index 6e44dc8aae..ff3e60313f 100644 --- a/src/main/frontend/components/home.cljs +++ b/src/main/frontend/components/home.cljs @@ -3,5 +3,5 @@ [frontend.components.sidebar :as sidebar])) (rum/defc home - [args] - (sidebar/main-content args)) + [] + (sidebar/main-content)) diff --git a/src/main/frontend/components/repo.cljs b/src/main/frontend/components/repo.cljs index 0fa8c07b03..4a2bdc5d74 100644 --- a/src/main/frontend/components/repo.cljs +++ b/src/main/frontend/components/repo.cljs @@ -20,7 +20,7 @@ (rum/defc add-repo [] - (widgets/add-repo)) + (widgets/add-graph)) (rum/defc repos < rum/reactive [] @@ -79,7 +79,7 @@ "Unlink"]]]))] [:a#download-as-json.hidden]] - (widgets/add-repo))))) + (widgets/add-graph))))) (rum/defc sync-status < rum/reactive {:did-mount (fn [state] diff --git a/src/main/frontend/components/sidebar.cljs b/src/main/frontend/components/sidebar.cljs index ee6a403b80..4cf109e692 100644 --- a/src/main/frontend/components/sidebar.cljs +++ b/src/main/frontend/components/sidebar.cljs @@ -163,10 +163,8 @@ (state/sidebar-add-block! current-repo db-id block-type nil)))) (reset! sidebar-inited? true)))) state)} - [args] - (let [query (get-in args [:parameters :query]) - login-source (:login_source query) - today (state/sub :today) + [] + (let [today (state/sub :today) cloning? (state/sub :repo/cloning?) default-home (get-default-home-if-valid) importing-to-db? (state/sub :repo/importing-to-db?) @@ -209,16 +207,7 @@ (journal/journals latest-journals) (and logged? (empty? (:repos me))) - (case login-source - "google" - (if-not (nfs-handler/supported?) - [:div (t :help/select-nfs-browser)] - [:div (t :help/open-top-right-open-button)]) - - "github" - (widgets/add-repo) - - (widgets/add-repo)) + (widgets/add-graph) ;; FIXME: why will this happen? :else diff --git a/src/main/frontend/components/svg.cljs b/src/main/frontend/components/svg.cljs index 526576ed24..26d5f4d73a 100644 --- a/src/main/frontend/components/svg.cljs +++ b/src/main/frontend/components/svg.cljs @@ -148,6 +148,16 @@ :stroke-linejoin "round" :stroke-linecap "round"}]]) +(def folder-add-large + [:svg + {:stroke "currentColor", :view-box "0 0 24 24", :fill "none" :width 64 :height 64 :display "inline-block"} + [:path + {:d + "M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" + :stroke-width "2" + :stroke-linejoin "round" + :stroke-linecap "round"}]]) + (def folder (hero-icon "M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z")) (def folder-sm (hero-icon "M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" {:height "16" :width "16"})) (def pages-sm [:svg {:viewBox "0 0 20 20", :fill "currentColor", :height "16", :width "16"} diff --git a/src/main/frontend/components/widgets.cljs b/src/main/frontend/components/widgets.cljs index a736ba29ad..af306008ca 100644 --- a/src/main/frontend/components/widgets.cljs +++ b/src/main/frontend/components/widgets.cljs @@ -14,7 +14,9 @@ [frontend.version :as version] [frontend.components.commit :as commit] [frontend.context.i18n :as i18n] - [reitit.frontend.easy :as rfe])) + [reitit.frontend.easy :as rfe] + [frontend.components.svg :as svg] + [frontend.handler.web.nfs :as nfs])) (rum/defcs choose-preferred-format [] @@ -36,52 +38,68 @@ :on-click #(user-handler/set-preferred-format! :org))]])) -(rum/defcs add-repo < +(rum/defcs add-graph < (rum/local "" ::repo) (rum/local "master" ::branch) [state] (let [repo (get state ::repo) - branch (get state ::branch)] + branch (get state ::branch) + login-source (state/get-login-source)] (rum/with-context [[t] i18n/*tongue-context*] - [:div.p-8.flex.items-center.justify-center - [:div.w-full.mx-auto - [:div + (if (= "github" login-source) + [:div.p-8.flex.items-center.justify-center + [:div.w-full.mx-auto [:div - [:h1.title.mb-1 - (t :git/add-repo-prompt)] - (ui/admonition :warning - [:p "Make sure that you've created this repo on GitHub."]) - [:div.mt-4.mb-4.relative.rounded-md.shadow-sm.max-w-xs - [:input#repo.form-input.block.w-full.sm:text-sm.sm:leading-5 - {:autoFocus true - :placeholder "https://github.com/username/repo" - :on-change (fn [e] - (reset! repo (util/evalue e)))}]] + [:div + [:h1.title.mb-1 + (t :git/add-repo-prompt)] + (ui/admonition :warning + [:p "Make sure that you've created this repo on GitHub."]) + [:div.mt-4.mb-4.relative.rounded-md.shadow-sm.max-w-xs + [:input#repo.form-input.block.w-full.sm:text-sm.sm:leading-5 + {:autoFocus true + :placeholder "https://github.com/username/repo" + :on-change (fn [e] + (reset! repo (util/evalue e)))}]] - [:label.font-medium "Default Branch (make sure it's matched with your setting on Github): "] - [:div.mt-2.mb-4.relative.rounded-md.shadow-sm.max-w-xs - [:input#branch.form-input.block.w-full.sm:text-sm.sm:leading-5 - {:value @branch - :placeholder "master" - :on-change (fn [e] - (reset! branch (util/evalue e)))}]]]] + [:label.font-medium "Default Branch (make sure it's matched with your setting on Github): "] + [:div.mt-2.mb-4.relative.rounded-md.shadow-sm.max-w-xs + [:input#branch.form-input.block.w-full.sm:text-sm.sm:leading-5 + {:value @branch + :placeholder "master" + :on-change (fn [e] + (reset! branch (util/evalue e)))}]]]] - (ui/button - (t :git/add-repo-prompt-confirm) - :on-click - (fn [] - (let [branch (string/trim @branch)] - (if (string/blank? branch) - (notification/show! - [:p "Please input a branch, make sure it's matched with your setting on Github."] - :error - false) - (let [repo (util/lowercase-first @repo)] - (if (util/starts-with? repo "https://github.com/") - (let [repo (string/replace repo ".git" "")] - (repo-handler/create-repo! repo branch)) + (ui/button + (t :git/add-repo-prompt-confirm) + :on-click + (fn [] + (let [branch (string/trim @branch)] + (if (string/blank? branch) + (notification/show! + [:p "Please input a branch, make sure it's matched with your setting on Github."] + :error + false) + (let [repo (util/lowercase-first @repo)] + (if (util/starts-with? repo "https://github.com/") + (let [repo (string/replace repo ".git" "")] + (repo-handler/create-repo! repo branch)) - (notification/show! - [:p "Please input a valid repo url, e.g. https://github.com/username/repo"] - :error - false)))))))]]))) + (notification/show! + [:p "Please input a valid repo url, e.g. https://github.com/username/repo"] + :error + false)))))))]] + + [:div.p-8.flex.items-center.justify-center + [:div.w-full.mx-auto + [:div + [:div + [:h1.title.mb-1 + "Please open a local directory : "]] + [:a.text-lg.font-medium.opacity-70.hover:opacity-100.ml-3.block + {:on-click (fn [] (nfs/ls-dir-files))} + [:div.flex.flex-row + [:span.inline-block svg/folder-add-large] + (when-not config/mobile? + [:span.ml-1.inline-block {:style {:margin-top "20px"}} + (t :open)])]]]]])))) diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index e9cfcb7ce1..1525670b71 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -249,6 +249,10 @@ [] (get-in @state [:me :repos])) +(defn get-login-source + [] + (get-in @state [:me :login_source])) + (defn set-repos! [repos] (set-state! [:me :repos] repos))