From 9a313752c57d8689d77f734ea896e82e70416102 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 3 Jul 2019 17:57:29 +0200 Subject: [PATCH] misc(frontend): minor code reorganization --- frontend/src/uxbox/main.cljs | 24 +++--------------------- frontend/src/uxbox/main/ui.cljs | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/frontend/src/uxbox/main.cljs b/frontend/src/uxbox/main.cljs index 5f7cb90e2..860e0387f 100644 --- a/frontend/src/uxbox/main.cljs +++ b/frontend/src/uxbox/main.cljs @@ -12,7 +12,7 @@ [uxbox.main.locales.en :as en] [uxbox.main.locales.fr :as fr] [uxbox.main.store :as st] - [uxbox.main.ui :refer [app]] + [uxbox.main.ui :as ui] [uxbox.main.ui.lightbox :refer [lightbox]] [uxbox.main.ui.loader :refer [loader]] [uxbox.util.dom :as dom] @@ -65,24 +65,6 @@ (set! st/*on-error* on-error) -(def routes - [["/auth" - ["/login" :auth/login] - ["/register" :auth/register] - ["/recovery/request" :auth/recovery-request] - ["/recovery/token/:token" :auth/recovery]] - ["/settings" - ["/profile" :settings/profile] - ["/password" :settings/password] - ["/notifications" :settings/notifications]] - ["/dashboard" - ["/projects" :dashboard/projects] - ["/elements" :dashboard/elements] - ["/icons" :dashboard/icons] - ["/images" :dashboard/images] - ["/colors" :dashboard/colors]] - ["/workspace/:project/:page" :workspace/page]]) - (defn- on-navigate [router path] (let [match (rt/match router path)] @@ -99,7 +81,7 @@ (defn init-ui [] - (let [router (rt/init routes) + (let [router (rt/init ui/routes) cpath (deref html-history/path)] (st/emit! #(assoc % :router router)) @@ -107,7 +89,7 @@ (st/emit! (udu/fetch-profile)) - (mx/mount (app) (dom/get-element "app")) + (mx/mount (ui/app) (dom/get-element "app")) (mx/mount (lightbox) (dom/get-element "lightbox")) (mx/mount (loader) (dom/get-element "loader")) diff --git a/frontend/src/uxbox/main/ui.cljs b/frontend/src/uxbox/main/ui.cljs index e6f8f9973..2dc81e07a 100644 --- a/frontend/src/uxbox/main/ui.cljs +++ b/frontend/src/uxbox/main/ui.cljs @@ -30,20 +30,38 @@ [uxbox.util.dom :as dom] [rumext.core :as mx :include-macros true])) -;; --- Constants +;; --- Refs (def route-ref (-> (l/key :route) (l/derive st/state))) +;; --- Routes + +(def routes + [["/auth" + ["/login" :auth/login] + ["/register" :auth/register] + ["/recovery/request" :auth/recovery-request] + ["/recovery/token/:token" :auth/recovery]] + ["/settings" + ["/profile" :settings/profile] + ["/password" :settings/password] + ["/notifications" :settings/notifications]] + ["/dashboard" + ["/projects" :dashboard/projects] + ["/elements" :dashboard/elements] + ["/icons" :dashboard/icons] + ["/images" :dashboard/images] + ["/colors" :dashboard/colors]] + ["/workspace/:project/:page" :workspace/page]]) + ;; --- Main App (Component) (mx/defc app {:mixins [mx/reactive]} [] - (let [route (mx/react route-ref) - auth (mx/react st/auth-ref)] - (prn "main$app" route) + (let [route (mx/react route-ref)] (case (get-in route [:data :name]) :auth/login (auth/login-page) :auth/register (auth/register-page)