From 36dde7b53d0e2712cf623689813acc2953ce447f Mon Sep 17 00:00:00 2001 From: Junyi Du Date: Tue, 31 Jan 2023 14:21:22 +0800 Subject: [PATCH] enhancement: minor enhancement to the no native FS API display --- .../frontend/components/onboarding/setups.cljs | 7 ++----- src/main/frontend/components/repo.cljs | 4 +++- src/main/frontend/components/widgets.cljs | 16 ++++++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/frontend/components/onboarding/setups.cljs b/src/main/frontend/components/onboarding/setups.cljs index aad88cdb1b..e32e08b014 100644 --- a/src/main/frontend/components/onboarding/setups.cljs +++ b/src/main/frontend/components/onboarding/setups.cljs @@ -4,6 +4,7 @@ [frontend.ui :as ui] [frontend.context.i18n :refer [t]] [frontend.components.svg :as svg] + [frontend.components.widgets :as widgets] [frontend.handler.page :as page-handler] [frontend.handler.route :as route-handler] [frontend.handler.ui :as ui-handler] @@ -96,11 +97,7 @@ [:small "Open existing directory or Create a new one"]])]]] [:div.px-5 (ui/admonition :warning - [:p "It seems that your browser doesn't support the " - [:a {:href "https://web.dev/file-system-access/" - :target "_blank"} - "new native filesystem API"] - [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]])]))] + (widgets/native-fs-api-alert))]))] [:section.b.flex.items-center.flex-col [:p.flex [:i.as-flex-center (ui/icon "zoom-question" {:style {:fontSize "22px"}})] diff --git a/src/main/frontend/components/repo.cljs b/src/main/frontend/components/repo.cljs index 6975e9d3dd..dc8abe0752 100644 --- a/src/main/frontend/components/repo.cljs +++ b/src/main/frontend/components/repo.cljs @@ -184,7 +184,9 @@ (->> (concat repo-links [(when (seq repo-links) {:hr true}) - {:title (t :new-graph) :options {:on-click #(state/pub-event! [:graph/setup-a-repo])}} + (if (or (nfs-handler/supported?) (mobile-util/native-platform?)) + {:title (t :new-graph) :options {:on-click #(state/pub-event! [:graph/setup-a-repo])}} + {:title (t :new-graph) :options {:href (rfe/href :repos)}}) ;; Brings to the repos page for showing fallback message {:title (t :all-graphs) :options {:href (rfe/href :repos)}} refresh-link reindex-link diff --git a/src/main/frontend/components/widgets.cljs b/src/main/frontend/components/widgets.cljs index c2cac3641f..119c959af5 100644 --- a/src/main/frontend/components/widgets.cljs +++ b/src/main/frontend/components/widgets.cljs @@ -9,6 +9,15 @@ [frontend.mobile.util :as mobile-util] [frontend.state :as state])) + +(rum/defc native-fs-api-alert + [] + [:p "It seems that your browser doesn't support the " + [:a {:href "https://web.dev/file-system-access/" + :target "_blank"} + "new native filesystem API"] + [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]) + (rum/defc add-local-directory [] [:div.flex.flex-col @@ -38,12 +47,7 @@ [:li (t :on-boarding/new-graph-desc-4)] [:li (t :on-boarding/new-graph-desc-5)]] (when-not nfs-supported? - (ui/admonition :warning - [:p "It seems that your browser doesn't support the " - [:a {:href "https://web.dev/file-system-access/" - :target "_blank"} - "new native filesystem API"] - [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]))]]]))]) + (ui/admonition :warning (native-fs-api-alert)))]]]))]) (rum/defc android-permission-alert []