🐛 Fix nitrate advanced permissions error (#11255)

This commit is contained in:
María Valderrama 2026-08-18 11:20:02 +02:00 committed by GitHub
parent 9311737f66
commit c72bb331ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 39 deletions

View File

@ -609,50 +609,56 @@
(defn check-and-submit-invite-members (defn check-and-submit-invite-members
"Fetches fresh team data from the server to ensure up-to-date organization "Fetches fresh team data from the server to ensure up-to-date organization
permissions, then submits member invitations or shows a restriction modal." permissions, then submits member invitations or shows a permission error."
[{:keys [team-id] :as params} origin do-invite-members] [{:keys [team-id] :as params} origin do-invite-members]
(ptk/reify ::check-and-submit-invite-members (ptk/reify ::check-and-submit-invite-members
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ state _]
(if (contains? cf/flags :admin-console) (let [profile-id (dm/get-in state [:profile :id])]
(with-refreshed-team team-id (if (contains? cf/flags :admin-console)
(fn [team] (with-refreshed-team team-id
(if (not (cto/allowed? :add-anybody-to-team (fn [team]
{:organization-perms (:organization team)})) (if (not (cto/can-send-invitations?
(->> (rp/cmd! :check-organization-members {:organization-id (get-in team [:organization :id]) {:organization (:organization team)
:emails (vec (:emails params))}) :profile-id profile-id
(rx/mapcat :team-permissions (:permissions team)}))
(fn [result] (rx/of (modal/show :no-permission-modal {:type :invite-members}))
(let [blocked (into [] (comp (filter (fn [[_ v]] (not v))) (if (not (cto/allowed? :add-anybody-to-team
(map first)) {:organization-perms (:organization team)}))
result)] (->> (rp/cmd! :check-organization-members {:organization-id (get-in team [:organization :id])
(cond :emails (vec (:emails params))})
(empty? blocked) (rx/mapcat
(do (do-invite-members params origin) (rx/empty)) (fn [result]
(let [blocked (into [] (comp (filter (fn [[_ v]] (not v)))
(map first))
result)]
(cond
(empty? blocked)
(do (do-invite-members params origin) (rx/empty))
(= (count blocked) (count result)) (= (count blocked) (count result))
(rx/of (rx/of
(modal/show (modal/show
{:type :alert {:type :alert
:title (tr "modals.invite-restricted-members.all-blocked-title") :title (tr "modals.invite-restricted-members.all-blocked-title")
:message (tr "modals.invite-restricted-members.all-blocked") :message (tr "modals.invite-restricted-members.all-blocked")
:accept-label (tr "labels.accept") :accept-label (tr "labels.accept")
:accept-style :primary})) :accept-style :primary}))
:else :else
(rx/of (rx/of
(modal/show (modal/show
{:type :invite-restricted-members {:type :invite-restricted-members
:blocked-emails blocked :blocked-emails blocked
:on-accept (fn [] :on-accept (fn []
(let [valid-emails (into #{} (filter (fn [e] (get result e))) (let [valid-emails (into #{} (filter (fn [e] (get result e)))
(:emails params)) (:emails params))
params' (assoc params :emails valid-emails)] params' (assoc params :emails valid-emails)]
(do-invite-members params' origin)))}))))))) (do-invite-members params' origin)))})))))))
(do (do-invite-members params origin) (do (do-invite-members params origin)
(rx/empty))))) (rx/empty))))))
(do (do-invite-members params origin) (do (do-invite-members params origin)
(rx/empty)))))) (rx/empty)))))))
(defn copy-invitation-link (defn copy-invitation-link
[{:keys [email team-id] :as params}] [{:keys [email team-id] :as params}]

View File

@ -233,6 +233,9 @@
(= :email-domain-is-not-allowed code)) (= :email-domain-is-not-allowed code))
(st/emit! (ntf/error (tr "errors.email-domain-not-allowed")) (st/emit! (ntf/error (tr "errors.email-domain-not-allowed"))
(modal/hide)) (modal/hide))
(and (= :validation type)
(= :insufficient-permissions code))
(st/emit! (modal/show :no-permission-modal {:type :invite-members}))
:else :else
(st/emit! (ntf/error (tr "errors.generic")) (st/emit! (ntf/error (tr "errors.generic"))

View File

@ -152,6 +152,8 @@
(tr "dashboard.no-permission-create-team.message" organization-name)] (tr "dashboard.no-permission-create-team.message" organization-name)]
:delete-team [(tr "dashboard.delete-team") :delete-team [(tr "dashboard.delete-team")
(tr "dashboard.no-permission-delete-team.message" organization-name)] (tr "dashboard.no-permission-delete-team.message" organization-name)]
:invite-members [(tr "modals.invite-team-member.title")
(tr "dashboard.invitations.no-permission")]
:no-organizations-create [(tr "dashboard.select-organization-modal.title") :no-organizations-create [(tr "dashboard.select-organization-modal.title")
(tr "dashboard.no-organization-allows-create-team.message")] (tr "dashboard.no-organization-allows-create-team.message")]
:no-organizations-change [(tr "dashboard.change-organization-modal.title") :no-organizations-change [(tr "dashboard.change-organization-modal.title")