mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 03:51:38 +02:00
🎉 Add malli based validation and coersion subsystem
This commit is contained in:
parent
dbc08ba80f
commit
5ca3d01ea1
125 changed files with 4984 additions and 2762 deletions
|
@ -6,9 +6,10 @@
|
|||
|
||||
(ns app.main.ui.dashboard.project-menu
|
||||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.schema :as sm]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.messages :as msg]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
|
@ -18,24 +19,21 @@
|
|||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[cljs.spec.alpha :as s]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(s/def ::project some?)
|
||||
(s/def ::show? boolean?)
|
||||
(s/def ::on-edit fn?)
|
||||
(s/def ::on-menu-close fn?)
|
||||
(s/def ::top (s/nilable ::us/number))
|
||||
(s/def ::left (s/nilable ::us/number))
|
||||
(s/def ::on-import fn?)
|
||||
|
||||
(s/def ::project-menu
|
||||
(s/keys :req-un [::project ::show? ::on-edit ::on-menu-close]
|
||||
:opt-un [::top ::left ::on-import]))
|
||||
(def schema:project-menu
|
||||
[:map {:title "UIProjectMenu"}
|
||||
[:project some?]
|
||||
[:show? :boolean]
|
||||
[:on-menu-close {:optional true} ::sm/fn]
|
||||
[:on-error {:optional true} ::sm/fn]
|
||||
[:top {:optional true} [:maybe :double]]
|
||||
[:left {:optional true} [:maybe :double]]
|
||||
[:on-import {:optional true} ::sm/fn]])
|
||||
|
||||
(mf/defc project-menu
|
||||
[{:keys [project show? on-edit on-menu-close top left on-import] :as props}]
|
||||
(us/verify ::project-menu props)
|
||||
(dm/assert! (sm/valid? schema:project-menu props))
|
||||
(let [top (or top 0)
|
||||
left (or left 0)
|
||||
|
||||
|
@ -45,7 +43,7 @@
|
|||
|
||||
on-duplicate-success
|
||||
(fn [new-project]
|
||||
(st/emit! (dm/success (tr "dashboard.success-duplicate-project"))
|
||||
(st/emit! (msg/success (tr "dashboard.success-duplicate-project"))
|
||||
(rt/nav :dashboard-files
|
||||
{:team-id (:team-id new-project)
|
||||
:project-id (:id new-project)})))
|
||||
|
@ -66,12 +64,12 @@
|
|||
(fn [team-id]
|
||||
(let [data {:id (:id project) :team-id team-id}
|
||||
mdata {:on-success #(on-move-success team-id)}]
|
||||
#(st/emit! (dm/success (tr "dashboard.success-move-project"))
|
||||
#(st/emit! (msg/success (tr "dashboard.success-move-project"))
|
||||
(dd/move-project (with-meta data mdata)))))
|
||||
|
||||
delete-fn
|
||||
(fn [_]
|
||||
(st/emit! (dm/success (tr "dashboard.success-delete-project"))
|
||||
(st/emit! (msg/success (tr "dashboard.success-delete-project"))
|
||||
(dd/delete-project project)
|
||||
(dd/go-to-projects (:team-id project))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue