Преглед изворни кода

fix: multiple onboarding issues

Konstantinos Kaloutas пре 3 година
родитељ
комит
2756f4a8ae

+ 14 - 10
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
   []

+ 20 - 23
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)))))]])

+ 1 - 1
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
 ;; ===============