mirror of
https://github.com/penpot/penpot.git
synced 2025-07-07 22:57:16 +02:00
New header for dashboard projects and draft
This commit is contained in:
parent
6838b9e769
commit
8b0eab5e90
3 changed files with 217 additions and 154 deletions
|
@ -39,7 +39,6 @@
|
|||
(s/keys ::req-un [::id
|
||||
::name
|
||||
::team-id
|
||||
::version
|
||||
::profile-id
|
||||
::created-at
|
||||
::modified-at]))
|
||||
|
@ -89,7 +88,7 @@
|
|||
(watch [_ state stream]
|
||||
(let [local (:dashboard-local state)]
|
||||
(rx/of (fetch-files (:project-id local))
|
||||
(fetch-projects (:team-id local)))))))
|
||||
(fetch-projects (:team-id local) (:project-id local)))))))
|
||||
|
||||
|
||||
(defn initialize-recent
|
||||
|
@ -105,7 +104,7 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [local (:dashboard-local state)]
|
||||
(rx/of (fetch-projects (:team-id local))
|
||||
(rx/of (fetch-projects (:team-id local) (:project-id nil))
|
||||
(fetch-recent-files (:team-id local)))))))
|
||||
|
||||
|
||||
|
@ -123,8 +122,8 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [local (:dashboard-local state)]
|
||||
(rx/of (fetch-files (:project-id local))
|
||||
(fetch-projects (:team-id local)))))))
|
||||
(rx/of (fetch-projects (:team-id local) (:project-id local))
|
||||
(fetch-files (:project-id local)))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Data Fetching
|
||||
|
@ -135,22 +134,28 @@
|
|||
(declare projects-fetched)
|
||||
|
||||
(defn fetch-projects
|
||||
[team-id]
|
||||
[team-id project-id]
|
||||
(us/assert ::us/uuid team-id)
|
||||
(us/assert (s/nilable ::us/uuid) project-id)
|
||||
(ptk/reify ::fetch-projects
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(->> (rp/query :projects-by-team {:team-id team-id})
|
||||
(rx/map projects-fetched)))))
|
||||
(rx/map (projects-fetched project-id))))))
|
||||
|
||||
(defn projects-fetched
|
||||
[projects]
|
||||
(us/verify (s/every ::project) projects)
|
||||
(ptk/reify ::projects-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [assoc-project #(assoc-in %1 [:projects (:id %2)] %2)]
|
||||
(reduce assoc-project state projects)))))
|
||||
[project-id]
|
||||
(us/assert (s/nilable ::us/uuid) project-id)
|
||||
(fn [projects]
|
||||
(us/verify (s/every ::project) projects)
|
||||
(ptk/reify ::projects-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [find-project #(first (filter (fn [p] (= (:id p) %1)) projects))
|
||||
set-project #(assoc %1 :project (find-project project-id))
|
||||
assoc-project #(assoc-in %1 [:projects (:id %2)] %2)
|
||||
reduce-projects #(reduce assoc-project %1 projects)]
|
||||
(-> state set-project reduce-projects))))))
|
||||
|
||||
;; --- Search Files
|
||||
|
||||
|
|
|
@ -12,15 +12,34 @@
|
|||
(:require
|
||||
[lentes.core :as l]
|
||||
[rumext.alpha :as mf]
|
||||
[uxbox.util.i18n :as i18n :refer [t]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.main.data.dashboard :as dsh]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.main.ui.dashboard.grid :refer [grid]]))
|
||||
|
||||
(def project-ref
|
||||
(-> (l/key :project)
|
||||
(l/derive st/state)))
|
||||
|
||||
(def files-ref
|
||||
(-> (comp (l/key :files)
|
||||
(l/lens vals))
|
||||
(l/derive st/state)))
|
||||
|
||||
(mf/defc project-header
|
||||
[{:keys [profile] :as props}]
|
||||
(let [project (mf/deref project-ref)
|
||||
locale (i18n/use-locale)]
|
||||
[:header#main-bar.main-bar
|
||||
(if (:is-default project)
|
||||
[:h1.dashboard-title (t locale "dashboard.header.draft")]
|
||||
[:h1.dashboard-title (t locale "dashboard.header.project" (:name project))])
|
||||
[:a.btn-dashboard {:on-click #(do
|
||||
(dom/prevent-default %)
|
||||
(st/emit! (dsh/create-file (:id project))))}
|
||||
(t locale "dashboard.header.new-file")]]))
|
||||
|
||||
(mf/defc project-page
|
||||
[{:keys [section team-id project-id] :as props}]
|
||||
(let [files (->> (mf/deref files-ref)
|
||||
|
@ -30,6 +49,8 @@
|
|||
{:fn #(st/emit! (dsh/initialize-project team-id project-id))
|
||||
:deps (mf/deps team-id project-id)})
|
||||
|
||||
[:section.projects-page
|
||||
[:& grid { :id project-id :files files }]]))
|
||||
[:*
|
||||
[:& project-header]
|
||||
[:section.projects-page
|
||||
[:& grid { :id project-id :files files :hide-new? true}]]]))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue