mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Fix nitrate invitations org ux review
This commit is contained in:
parent
81061013b1
commit
ac472c615a
1
.gitignore
vendored
1
.gitignore
vendored
@ -82,3 +82,4 @@
|
||||
/**/node_modules
|
||||
/**/.yarn/*
|
||||
/.pnpm-store
|
||||
/.vscode
|
||||
|
||||
@ -179,7 +179,7 @@
|
||||
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
||||
<div
|
||||
style="font-family:Source Sans Pro, sans-serif;font-size:16px;line-height:150%;text-align:left;color:#000000;">
|
||||
Hi{{ user-name|abbreviate:25 }},
|
||||
Hi{% if user-name %} {{ user-name|abbreviate:25 }}{% endif %},
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -187,7 +187,7 @@
|
||||
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
||||
<div
|
||||
style="font-family:Source Sans Pro, sans-serif;font-size:16px;line-height:150%;text-align:left;color:#000000;">
|
||||
<b>{{invited-by|abbreviate:25}}</b> sent you an invitation to join the organization {{ org-name|abbreviate:25 }}:
|
||||
<b>{{invited-by|abbreviate:25}}</b> sent you an invitation to join the organization:
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -195,10 +195,15 @@
|
||||
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
||||
<div
|
||||
style="font-family:Source Sans Pro, sans-serif;font-size:16px;line-height:150%;text-align:left;color:#000000;">
|
||||
<span style="display:inline-block;vertical-align:middle;width:20px;height:20px;border-radius: 50%;background-image:url('{{org-logo}}');overflow:hidden;text-align:center;font-weight: bold;font-size: 9px;line-height: 20px;">
|
||||
{{ org-initials }}
|
||||
</span>
|
||||
|
||||
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="20" height="20" style="display:inline-block;vertical-align:middle;">
|
||||
<tr>
|
||||
<td width="20" height="20" align="center" valign="middle"
|
||||
background="{{org-logo}}"
|
||||
style="width:20px;height:20px;text-align:center;font-weight:bold;font-size:9px;line-height:20px;color:#ffffff;background-size:cover;background-position:center;background-repeat:no-repeat;border-radius: 50%;color:black">
|
||||
{{org-initials}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<span style="display:inline-block; vertical-align: middle;padding-left:5px;height:20px;line-height: 20px;">
|
||||
“{{ org-name|abbreviate:25 }}”
|
||||
</span>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
(ns app.nitrate
|
||||
"Module that make calls to the external nitrate aplication"
|
||||
(:require
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.json :as json]
|
||||
[app.common.logging :as l]
|
||||
[app.common.schema :as sm]
|
||||
@ -130,7 +131,8 @@
|
||||
(def ^:private schema:profile-org
|
||||
[:map
|
||||
[:is-member :boolean]
|
||||
[:organization-id ::sm/uuid]])
|
||||
[:organization-id ::sm/uuid]
|
||||
[:default-team-id [:maybe ::sm/uuid]]])
|
||||
|
||||
|
||||
;; TODO Unify with schemas on backend/src/app/http/management.clj
|
||||
@ -214,6 +216,17 @@
|
||||
team-id)
|
||||
schema:organization params)))
|
||||
|
||||
(defn- get-org-membership-api
|
||||
[cfg {:keys [profile-id org-id] :as params}]
|
||||
(let [baseuri (cf/get :nitrate-backend-uri)]
|
||||
(request-to-nitrate cfg :get
|
||||
(str baseuri
|
||||
"/api/organizations/"
|
||||
org-id
|
||||
"/members/"
|
||||
profile-id)
|
||||
schema:profile-org params)))
|
||||
|
||||
(defn- get-org-membership-by-team-api
|
||||
[cfg {:keys [profile-id team-id] :as params}]
|
||||
(let [baseuri (cf/get :nitrate-backend-uri)]
|
||||
@ -308,6 +321,7 @@
|
||||
(when (contains? cf/flags :nitrate)
|
||||
{:get-team-org (partial get-team-org-api cfg)
|
||||
:set-team-org (partial set-team-org-api cfg)
|
||||
:get-org-membership (partial get-org-membership-api cfg)
|
||||
:get-org-membership-by-team (partial get-org-membership-by-team-api cfg)
|
||||
:get-org-summary (partial get-org-summary-api cfg)
|
||||
:add-profile-to-org (partial add-profile-to-org-api cfg)
|
||||
@ -369,9 +383,10 @@
|
||||
:is-default (:is-default params))
|
||||
result (call cfg :set-team-org params)]
|
||||
(when (nil? result)
|
||||
(throw (ex-info "Failed to set team organization"
|
||||
{:team-id (:id team)
|
||||
:organization-id (:organization-id params)})))
|
||||
(ex/raise :type :internal
|
||||
:code :failed-to-set-team-org
|
||||
:context {:team-id (:id team)
|
||||
:organization-id (:organization-id params)}))
|
||||
team))
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
[app.http.session :as session]
|
||||
[app.loggers.audit :as audit]
|
||||
[app.main :as-alias main]
|
||||
[app.nitrate :as nitrate]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.commands.profile :as profile]
|
||||
[app.rpc.commands.teams :as teams]
|
||||
@ -175,13 +176,13 @@
|
||||
org-id (assoc :org-id org-id)))
|
||||
profile (db/get* conn :profile
|
||||
{:id profile-id}
|
||||
{:columns [:id :email]})
|
||||
registration-disabled? (not (contains? cf/flags :registration))]
|
||||
{:columns [:id :email :default-team-id]})
|
||||
registration-disabled? (not (contains? cf/flags :registration))
|
||||
|
||||
(when (nil? invitation)
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-token
|
||||
:hint "no invitation associated with the token"))
|
||||
org-invitation? (and (contains? cf/flags :nitrate) org-id)
|
||||
membership (when org-invitation?
|
||||
(nitrate/call cfg :get-org-membership {:profile-id profile-id
|
||||
:org-id org-id}))]
|
||||
|
||||
(if profile
|
||||
(do
|
||||
@ -191,6 +192,23 @@
|
||||
:code :invalid-token
|
||||
:hint "logged-in user does not matches the invitation"))
|
||||
|
||||
(when (:is-member membership)
|
||||
(ex/raise :type :validation
|
||||
:code :already-an-org-member
|
||||
:team-id (:default-team-id membership)
|
||||
:hint "the user is already a member of the organization"))
|
||||
|
||||
(when (and org-invitation? (not (:organization-id membership)))
|
||||
(ex/raise :type :validation
|
||||
:code :org-not-found
|
||||
:team-id (:default-team-id profile)
|
||||
:hint "the organization doesn't exist"))
|
||||
|
||||
(when (nil? invitation)
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-token
|
||||
:hint "no invitation associated with the token"))
|
||||
|
||||
|
||||
;; if we have logged-in user and it matches the invitation we proceed
|
||||
;; with accepting the invitation and joining the current profile to the
|
||||
|
||||
@ -76,8 +76,17 @@
|
||||
(fn [tdata]
|
||||
(handle-token tdata))
|
||||
(fn [cause]
|
||||
(let [{:keys [type code] :as error} (ex-data cause)]
|
||||
(let [{:keys [type code team-id] :as error} (ex-data cause)]
|
||||
(cond
|
||||
(= :invalid-token-already-member code)
|
||||
(st/emit!
|
||||
(rt/nav :dashboard-recent {:team-id team-id}))
|
||||
|
||||
(= :org-not-found code)
|
||||
(st/emit!
|
||||
(rt/nav :dashboard-recent {:team-id team-id})
|
||||
(ntf/error (tr "errors.org-not-found")))
|
||||
|
||||
(or (= :validation type)
|
||||
(= :invalid-token code)
|
||||
(= :token-expired (:reason error)))
|
||||
|
||||
@ -1667,6 +1667,9 @@ msgstr "Email or password is incorrect."
|
||||
msgid "errors.wrong-old-password"
|
||||
msgstr "Old password is incorrect"
|
||||
|
||||
msgid "errors.org-not-found"
|
||||
msgstr "That organization doesn't exists"
|
||||
|
||||
#: src/app/main/ui/settings/feedback.cljs:120
|
||||
msgid "feedback.description"
|
||||
msgstr "Description"
|
||||
|
||||
@ -1636,6 +1636,9 @@ msgstr "El email o la contraseña son incorrectos."
|
||||
msgid "errors.wrong-old-password"
|
||||
msgstr "La contraseña anterior no es correcta"
|
||||
|
||||
msgid "errors.org-not-found"
|
||||
msgstr "Esa organización no existe"
|
||||
|
||||
#: src/app/main/ui/settings/feedback.cljs:120
|
||||
msgid "feedback.description"
|
||||
msgstr "Descripción"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user