Add proper on-accept callback on features related restriction error

Which redirects user to the dashboard if the team-id and project-id
is available in stante; if not just flushes hard refresh
This commit is contained in:
Andrey Antukh 2023-07-06 18:15:03 +02:00 committed by Alejandro Alonso
parent 09d28d8583
commit 7a837110f0
2 changed files with 22 additions and 15 deletions

View file

@ -165,12 +165,22 @@
[{:keys [code] :as error}]
(cond
(= :feature-mismatch code)
(let [message (tr "errors.feature-mismatch" (:feature error))]
(st/emit! (modal/show {:type :alert :message message})))
(let [message (tr "errors.feature-mismatch" (:feature error))
team-id (:current-team-id @st/state)
project-id (:current-project-id @st/state)
on-accept #(if (and project-id team-id)
(st/emit! (rt/nav :dashboard-files {:team-id team-id :project-id project-id}))
(set! (.-href glob/location) ""))]
(st/emit! (modal/show {:type :alert :message message :on-accept on-accept})))
(= :features-not-supported code)
(let [message (tr "errors.feature-not-supported" (:feature error))]
(st/emit! (modal/show {:type :alert :message message})))
(let [message (tr "errors.feature-not-supported" (:feature error))
team-id (:current-team-id @st/state)
project-id (:current-project-id @st/state)
on-accept #(if (and project-id team-id)
(st/emit! (rt/nav :dashboard-files {:team-id team-id :project-id project-id}))
(set! (.-href glob/location) ""))]
(st/emit! (modal/show {:type :alert :message message :on-accept on-accept})))
(= :max-quote-reached code)
(let [message (tr "errors.max-quote-reached" (:target error))]