0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 14:39:45 -05:00

Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Alejandro Alonso 2024-07-03 08:46:26 +02:00
commit 9125b46ca5
7 changed files with 54 additions and 29 deletions

View file

@ -91,7 +91,8 @@
[params] [params]
(d/without-nils (d/without-nils
{:external-session-id (::rpc/external-session-id params) {:external-session-id (::rpc/external-session-id params)
:event-origin (::rpc/handler-name params)})) :event-origin (::rpc/external-event-origin params)
:triggered-by (::rpc/handler-name params)}))
;; --- SPECS ;; --- SPECS
@ -148,6 +149,7 @@
uuid/zero) uuid/zero)
session-id (get params ::rpc/external-session-id) session-id (get params ::rpc/external-session-id)
event-origin (get params ::rpc/external-event-origin)
props (-> (or (::replace-props resultm) props (-> (or (::replace-props resultm)
(-> params (-> params
(merge (::props resultm)) (merge (::props resultm))
@ -159,6 +161,7 @@
token-id (::actoken/id request) token-id (::actoken/id request)
context (-> (::context resultm) context (-> (::context resultm)
(assoc :external-session-id session-id) (assoc :external-session-id session-id)
(assoc :external-event-origin event-origin)
(assoc :access-token-id (some-> token-id str)) (assoc :access-token-id (some-> token-id str))
(d/without-nils))] (d/without-nils))]

View file

@ -80,11 +80,13 @@
(::actoken/profile-id request)) (::actoken/profile-id request))
session-id (rreq/get-header request "x-external-session-id") session-id (rreq/get-header request "x-external-session-id")
event-origin (rreq/get-header request "x-event-origin")
data (-> params data (-> params
(assoc ::handler-name handler-name) (assoc ::handler-name handler-name)
(assoc ::request-at (dt/now)) (assoc ::request-at (dt/now))
(assoc ::external-session-id session-id) (assoc ::external-session-id session-id)
(assoc ::external-event-origin event-origin)
(assoc ::session/id (::session/id request)) (assoc ::session/id (::session/id request))
(assoc ::cond/key etag) (assoc ::cond/key etag)
(cond-> (uuid? profile-id) (cond-> (uuid? profile-id)

View file

@ -357,10 +357,12 @@
::quotes/profile-id profile-id}) ::quotes/profile-id profile-id})
(let [features (-> (cfeat/get-enabled-features cf/flags) (let [features (-> (cfeat/get-enabled-features cf/flags)
(cfeat/check-client-features! (:features params)))] (cfeat/check-client-features! (:features params)))
(create-team cfg (assoc params team (create-team cfg (assoc params
:profile-id profile-id :profile-id profile-id
:features features)))))) :features features))]
(with-meta team
{::audit/props {:id (:id team)}})))))
(defn create-team (defn create-team
"This is a complete team creation process, it creates the team "This is a complete team creation process, it creates the team
@ -880,7 +882,7 @@
(sv/defmethod ::create-team-with-invitations (sv/defmethod ::create-team-with-invitations
{::doc/added "1.17" {::doc/added "1.17"
::sm/params schema:create-team-with-invitations} ::sm/params schema:create-team-with-invitations}
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id emails role] :as params}] [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id emails role name] :as params}]
(db/with-atomic [conn pool] (db/with-atomic [conn pool]
(let [features (-> (cfeat/get-enabled-features cf/flags) (let [features (-> (cfeat/get-enabled-features cf/flags)
@ -893,7 +895,8 @@
cfg (assoc cfg ::db/conn conn) cfg (assoc cfg ::db/conn conn)
team (create-team cfg params) team (create-team cfg params)
profile (db/get-by-id conn :profile profile-id) profile (db/get-by-id conn :profile profile-id)
emails (into #{} (map profile/clean-email) emails)] emails (into #{} (map profile/clean-email) emails)
context (audit/params->context params)]
;; Create invitations for all provided emails. ;; Create invitations for all provided emails.
(->> emails (->> emails
@ -917,6 +920,14 @@
::quotes/team-id (:id team) ::quotes/team-id (:id team)
::quotes/incr (count emails)})) ::quotes/incr (count emails)}))
(audit/submit! cfg
{::audit/type "action"
::audit/name "create-team"
::audit/profile-id profile-id
::audit/props {:name name
:features features}
::audit/context context})
(audit/submit! cfg (audit/submit! cfg
{::audit/type "command" {::audit/type "command"
::audit/name "create-team-invitations" ::audit/name "create-team-invitations"

View file

@ -405,12 +405,13 @@
(dm/assert! (string? name)) (dm/assert! (string? name))
(ptk/reify ::create-team (ptk/reify ::create-team
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [{:keys [on-success on-error] (let [{:keys [on-success on-error]
:or {on-success identity :or {on-success identity
on-error rx/throw}} (meta params) on-error rx/throw}} (meta params)
features (features/get-enabled-features state)] features (features/get-enabled-features state)
(->> (rp/cmd! :create-team {:name name :features features}) params {:name name :features features}]
(->> (rp/cmd! :create-team (with-meta params (meta it)))
(rx/tap on-success) (rx/tap on-success)
(rx/map team-created) (rx/map team-created)
(rx/catch on-error)))))) (rx/catch on-error))))))
@ -421,7 +422,7 @@
[{:keys [name emails role] :as params}] [{:keys [name emails role] :as params}]
(ptk/reify ::create-team-with-invitations (ptk/reify ::create-team-with-invitations
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [{:keys [on-success on-error] (let [{:keys [on-success on-error]
:or {on-success identity :or {on-success identity
on-error rx/throw}} (meta params) on-error rx/throw}} (meta params)
@ -430,7 +431,7 @@
:emails emails :emails emails
:role role :role role
:features features}] :features features}]
(->> (rp/cmd! :create-team-with-invitations params) (->> (rp/cmd! :create-team-with-invitations (with-meta params (meta it)))
(rx/tap on-success) (rx/tap on-success)
(rx/map team-created) (rx/map team-created)
(rx/catch on-error)))))) (rx/catch on-error))))))
@ -553,12 +554,12 @@
:resend resend?}) :resend resend?})
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [it _ _]
(let [{:keys [on-success on-error] (let [{:keys [on-success on-error]
:or {on-success identity :or {on-success identity
on-error rx/throw}} (meta params) on-error rx/throw}} (meta params)
params (dissoc params :resend?)] params (dissoc params :resend?)]
(->> (rp/cmd! :create-team-invitations params) (->> (rp/cmd! :create-team-invitations (with-meta params (meta it)))
(rx/tap on-success) (rx/tap on-success)
(rx/catch on-error)))))) (rx/catch on-error))))))

View file

@ -10,6 +10,7 @@
[app.common.transit :as t] [app.common.transit :as t]
[app.common.uri :as u] [app.common.uri :as u]
[app.config :as cf] [app.config :as cf]
[app.main.data.events :as-alias ev]
[app.util.http :as http] [app.util.http :as http]
[app.util.sse :as sse] [app.util.sse :as sse]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
@ -93,12 +94,12 @@
(= query-params :all) :get (= query-params :all) :get
(str/starts-with? nid "get-") :get (str/starts-with? nid "get-") :get
:else :post) :else :post)
request {:method method request {:method method
:uri (u/join cf/public-uri "api/rpc/command/" nid) :uri (u/join cf/public-uri "api/rpc/command/" nid)
:credentials "include" :credentials "include"
:headers {"accept" "application/transit+json,text/event-stream,*/*" :headers {"accept" "application/transit+json,text/event-stream,*/*"
"x-external-session-id" (cf/external-session-id)} "x-external-session-id" (cf/external-session-id)
"x-event-origin" (::ev/origin (meta params))}
:body (when (= method :post) :body (when (= method :post)
(if form-data? (if form-data?
(http/form-data params) (http/form-data params)
@ -137,7 +138,8 @@
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri uri :uri uri
:credentials "include" :credentials "include"
:headers {"x-external-session-id" (cf/external-session-id)} :headers {"x-external-session-id" (cf/external-session-id)
"x-event-origin" (::ev/origin (meta params))}
:query params}) :query params})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))
@ -147,7 +149,8 @@
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join cf/public-uri "api/export") :uri (u/join cf/public-uri "api/export")
:body (http/transit-data (dissoc params :blob?)) :body (http/transit-data (dissoc params :blob?))
:headers {"x-external-session-id" (cf/external-session-id)} :headers {"x-external-session-id" (cf/external-session-id)
"x-event-origin" (::ev/origin (meta params))}
:credentials "include" :credentials "include"
:response-type (if blob? :blob :text)}) :response-type (if blob? :blob :text)})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
@ -167,7 +170,8 @@
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join cf/public-uri "api/rpc/command/" (name id)) :uri (u/join cf/public-uri "api/rpc/command/" (name id))
:credentials "include" :credentials "include"
:headers {"x-external-session-id" (cf/external-session-id)} :headers {"x-external-session-id" (cf/external-session-id)
"x-event-origin" (::ev/origin (meta params))}
:body (http/form-data params)}) :body (http/form-data params)})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response))) (rx/mapcat handle-response)))

View file

@ -9,6 +9,7 @@
(:require (:require
[app.common.schema :as sm] [app.common.schema :as sm]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.events :as ev]
[app.main.data.messages :as msg] [app.main.data.messages :as msg]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.store :as st] [app.main.store :as st]
@ -50,7 +51,8 @@
(let [mdata {:on-success (partial on-create-success form) (let [mdata {:on-success (partial on-create-success form)
:on-error (partial on-error form)} :on-error (partial on-error form)}
params {:name (get-in @form [:clean-data :name])}] params {:name (get-in @form [:clean-data :name])}]
(st/emit! (dd/create-team (with-meta params mdata))))) (st/emit! (-> (dd/create-team (with-meta params mdata))
(with-meta {::ev/origin :dashboard})))))
(defn- on-update-submit (defn- on-update-submit
[form] [form]

View file

@ -98,7 +98,8 @@
(let [mdata {:on-success on-success (let [mdata {:on-success on-success
:on-error on-error} :on-error on-error}
params {:name name}] params {:name name}]
(st/emit! (dd/create-team (with-meta params mdata)) (st/emit! (-> (dd/create-team (with-meta params mdata))
(with-meta {::ev/origin :onboarding-without-invitations}))
(ptk/data-event ::ev/event (ptk/data-event ::ev/event
{::ev/name "onboarding-step" {::ev/name "onboarding-step"
:label "team:create-team-and-invite-later" :label "team:create-team-and-invite-later"
@ -113,7 +114,8 @@
(let [mdata {:on-success on-success (let [mdata {:on-success on-success
:on-error on-error}] :on-error on-error}]
(st/emit! (dd/create-team-with-invitations (with-meta params mdata)) (st/emit! (-> (dd/create-team-with-invitations (with-meta params mdata))
(with-meta {::ev/origin :onboarding-with-invitations}))
(ptk/data-event ::ev/event (ptk/data-event ::ev/event
{::ev/name "onboarding-step" {::ev/name "onboarding-step"
:label "team:create-team-and-invite" :label "team:create-team-and-invite"