From 2756f4a8ae51b086fb7b685b18e1ce8e61b3dd53 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Mon, 28 Nov 2022 15:09:25 +0200 Subject: [PATCH] fix: multiple onboarding issues --- .../components/onboarding/quick_tour.cljs | 24 ++++++----- src/main/frontend/components/whiteboard.cljs | 43 +++++++++---------- src/main/frontend/state.cljs | 2 +- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/main/frontend/components/onboarding/quick_tour.cljs b/src/main/frontend/components/onboarding/quick_tour.cljs index 2bf292a83..031bf2db6 100644 --- a/src/main/frontend/components/onboarding/quick_tour.cljs +++ b/src/main/frontend/components/onboarding/quick_tour.cljs @@ -157,12 +157,12 @@ :text (h/render-html [:section [:h2 "🖼 Home for your whiteboards"] [:p "Whiteboards have their own section in the app where you can see them at a glance, create new ones or delete them easily."]]) :attachTo {:element ".nav-header .whiteboard" :on "right"} - :beforeShowPromise #(if (state/sub :ui/sidebar-open?) - (wait-target state/hide-right-sidebar! 700) - (p/resolved true)) + :beforeShowPromise (fn [] + (when-not (state/sub :ui/left-sidebar-open?) + (state/toggle-left-sidebar!)) + (wait-target ".nav-header .whiteboard" 500)) :canClickTarget true - :buttons [{:text "Next" :action (do (router-handler/redirect-to-whiteboard-dashboard!) - (.-next jsTour))}] + :buttons [{:text "Next" :action (.-next jsTour)}] :popperOptions {:modifiers [{:name "preventOverflow" :options {:padding 20}} {:name "offset" @@ -172,12 +172,16 @@ {:id "whiteboard-new" :text (h/render-html [:section [:h2 "🆕️ Create new whiteboard"] [:p "There is multiple ways of creating a new whiteboard. One of them is always right here in the dashboard."]]) - :beforeShowPromise #((if-not (state/sub :ui/left-sidebar-open?) - (wait-target state/toggle-left-sidebar! 500) - (p/resolved true))) - :attachTo {:element "#tl-create-whiteboard" :on "bottom"} + :beforeShowPromise (fn [] + (router-handler/redirect-to-whiteboard-dashboard!) + (wait-target ".dashboard-create-card" 500)) + :attachTo {:element ".dashboard-create-card" :on "bottom"} :buttons [{:text "Back" :classes "back" :action (.-back jsTour)} - {:text "Finish" :action (.-complete jsTour)}]}]) + {:text "Finish" :action (.-complete jsTour)}] + :popperOptions {:modifiers [{:name "preventOverflow" + :options {:padding 20}} + {:name "offset" + :options {:offset [0, 10]}}]}}]) (defn start [] diff --git a/src/main/frontend/components/whiteboard.cljs b/src/main/frontend/components/whiteboard.cljs index ef2d1c8a3..dfc94f659 100644 --- a/src/main/frontend/components/whiteboard.cljs +++ b/src/main/frontend/components/whiteboard.cljs @@ -16,6 +16,7 @@ [frontend.rum :refer [use-bounding-client-rect use-breakpoint use-click-outside]] [frontend.state :as state] + [frontend.storage :as storage] [frontend.ui :as ui] [frontend.util :as util] [promesa.core :as p] @@ -298,34 +299,30 @@ (defn onboarding-show [] (when (and (user-handler/feature-available? :whiteboard) - (not (or (state/enable-whiteboards?) - (state/sub :whiteboard/onboarding?)))) + (not (or (state/sub :whiteboard/onboarding?) + (state/enable-whiteboards?)))) (state/pub-event! [:whiteboard/onboarding]) - (state/set-state! [:whiteboard/onboarding?] true))) + (state/set-state! [:whiteboard/onboarding?] true) + (storage/set :whiteboard-onboarding? true))) (rum/defc onboarding-welcome [close-fn] - (try - [:div.cp__whiteboard-welcome - [:span.head-bg + [:div.cp__whiteboard-welcome + [:span.head-bg - [:strong (t :on-boarding/closed-feature (name (:whiteboard user-handler/feature-matrix)))]] + [:strong (t :on-boarding/closed-feature (name (:whiteboard user-handler/feature-matrix)))]] - [:h1.text-2xl.font-bold.flex-col.sm:flex-row - (t :on-boarding/welcome-whiteboard-modal-title)] + [:h1.text-2xl.font-bold.flex-col.sm:flex-row + (t :on-boarding/welcome-whiteboard-modal-title)] - [:p (t :on-boarding/welcome-whiteboard-modal-description)] + [:p (t :on-boarding/welcome-whiteboard-modal-description)] - [:div.pt-6.flex.justify-center.space-x-2.sm:justify-end - (ui/button (t :on-boarding/welcome-whiteboard-modal-later) :on-click close-fn :background "gray" :class "opacity-60") - (ui/button (t :on-boarding/welcome-whiteboard-modal-start) - :on-click (fn [] - (config-handler/set-config! :feature/enable-whiteboards? true) - (do (quick-tour/ready - (fn [] - (quick-tour/start-whiteboard) - (state/set-state! :whiteboard/onboarding? true) - (close-fn))) - (throw (js/Error. nil)))))]] - (catch :default e - (js/console.warn "[Whiteboard onboarding SKIP] " (name type) e)))) + [:div.pt-6.flex.justify-center.space-x-2.sm:justify-end + (ui/button (t :on-boarding/welcome-whiteboard-modal-later) :on-click close-fn :background "gray" :class "opacity-60") + (ui/button (t :on-boarding/welcome-whiteboard-modal-start) + :on-click (fn [] + (config-handler/set-config! :feature/enable-whiteboards? true) + (quick-tour/ready + (fn [] + (quick-tour/start-whiteboard) + (close-fn)))))]]) diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 7e1d37c64..a2eee0984 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -275,7 +275,7 @@ :graph/importing-state {} :whiteboard/onboarding-whiteboard? (or (storage/get :ls-onboarding-whiteboard?) false) - :whiteboard/onboarding? (or (storage/get :whiteboard/onboarding?) false)}))) + :whiteboard/onboarding? (or (storage/get :whiteboard-onboarding?) false)}))) ;; Block ast state ;; ===============