diff --git a/frontend/src/uxbox/main/ui.cljs b/frontend/src/uxbox/main/ui.cljs index a067bdf0b..3c852e214 100644 --- a/frontend/src/uxbox/main/ui.cljs +++ b/frontend/src/uxbox/main/ui.cljs @@ -83,19 +83,6 @@ ;; --- Main App (Component) -(defn- parse-dashboard-params - [route section] - (let [{:keys [id type]} (get-in route [:params :query]) - id (cond - (str/digits? id) (parse-int id) - (uuid-str? id) (uuid id) - :else nil) - type (when (str/alpha? type) (keyword type))] - #js {:section section - :id id - :type type})) - - (mf/def app :mixins [mx/reactive] @@ -121,17 +108,12 @@ :settings/notifications) (mf/elem settings/settings {:route route}) - ;; :settings/profile (mf/elem settings/settings {:section :profile}) - ;; :settings/password (mf/elem settings/settings {:section :password}) - ;; :settings/notifications (mf/elem settings/notifications-page) + (:dashboard/projects + :dashboard/icons + :dashboard/images + :dashboard/colors) + (mf/elem dashboard/dashboard {:route route}) - :dashboard/projects (mf/elem dashboard/dashboard {:section :projects}) - :dashboard/icons (->> (parse-dashboard-params route :icons) - (mf/element dashboard/dashboard)) - :dashboard/images (->> (parse-dashboard-params route :images) - (mf/element dashboard/dashboard)) - :dashboard/colors (->> (parse-dashboard-params route :colors) - (mf/element dashboard/dashboard)) :workspace/page (let [project (uuid (get-in route [:params :path :project])) page (uuid (get-in route [:params :path :page]))] diff --git a/frontend/src/uxbox/main/ui/dashboard.cljs b/frontend/src/uxbox/main/ui/dashboard.cljs index c6f1d3ac8..e2c73a418 100644 --- a/frontend/src/uxbox/main/ui/dashboard.cljs +++ b/frontend/src/uxbox/main/ui/dashboard.cljs @@ -1,6 +1,8 @@ (ns uxbox.main.ui.dashboard (:require + [cuerdas.core :as str] [rumext.alpha :as mf] + [uxbox.util.data :refer [parse-int uuid-str?]] [uxbox.main.ui.dashboard.header :refer [header]] [uxbox.main.ui.dashboard.projects :as projects] ;; [uxbox.main.ui.dashboard.elements :as elements] @@ -15,13 +17,27 @@ (def images-page images/images-page) (def colors-page colors/colors-page) +(defn- parse-route + [{:keys [params data] :as route}] + (let [{:keys [id type]} (:query params) + id (cond + (str/digits? id) (parse-int id) + (uuid-str? id) (uuid id) + :else nil) + type (when (str/alpha? type) (keyword type))] + {:section (:name data) + :type type + :id id})) + (mf/defc dashboard - [props] - [:main.dashboard-main - (messages-widget) - (header) - (case (:section props) - :icons (icons/icons-page props) - :images (images/images-page props) - :projects (projects/projects-page props) - :colors (colors/colors-page props))]) + {:wrap [mf/memo*]} + [{:keys [route] :as props}] + (let [{:keys [section] :as props} (parse-route route)] + [:main.dashboard-main + (messages-widget) + (header) ;; TODO: pass section to header + (case section + :dashboard/icons (icons/icons-page props) + :dashboard/images (images/images-page props) + :dashboard/projects (projects/projects-page props) + :dashboard/colors (colors/colors-page props))])) diff --git a/frontend/src/uxbox/view.cljs b/frontend/src/uxbox/view.cljs index bd86008b0..8935f8921 100644 --- a/frontend/src/uxbox/view.cljs +++ b/frontend/src/uxbox/view.cljs @@ -61,8 +61,8 @@ (let [match (rt/match router path)] (prn "on-navigate" path match) (cond - (and (= path "") (nil? match)) - (html-history/set-path! "/not-found") + ;; (and (= path "") (nil? match)) + ;; (html-history/set-path! "/not-found") (nil? match) (prn "TODO 404")