mirror of
https://github.com/penpot/penpot.git
synced 2026-09-23 20:36:15 +00:00
✨ Error page for instances without admin-console configuration (#11649)
* ✨ Error page for instances without admin-console configuration * 📎 Code review
This commit is contained in:
parent
0caabfdd5b
commit
66876f16b2
@ -166,6 +166,13 @@
|
|||||||
{::yres/status 503
|
{::yres/status 503
|
||||||
::yres/body {:type :nitrate-unavailable}}))
|
::yres/body {:type :nitrate-unavailable}}))
|
||||||
|
|
||||||
|
(defmethod handle-error :nitrate-not-configured
|
||||||
|
[err request _]
|
||||||
|
(binding [l/*context* (request->context request)]
|
||||||
|
(l/warn :hint "nitrate is not configured; blocking request" :cause err)
|
||||||
|
{::yres/status 503
|
||||||
|
::yres/body {:type :nitrate-not-configured}}))
|
||||||
|
|
||||||
(defmethod handle-error :internal
|
(defmethod handle-error :internal
|
||||||
[error request parent-cause]
|
[error request parent-cause]
|
||||||
(binding [l/*context* (request->context request)]
|
(binding [l/*context* (request->context request)]
|
||||||
|
|||||||
@ -156,9 +156,13 @@
|
|||||||
(defn call
|
(defn call
|
||||||
[cfg method params]
|
[cfg method params]
|
||||||
(when (contains? cf/flags :admin-console)
|
(when (contains? cf/flags :admin-console)
|
||||||
(let [client (get cfg ::client)
|
(let [uri (cf/get :admin-console-uri)]
|
||||||
method (get client method)]
|
(if (nil? uri)
|
||||||
(method params))))
|
(ex/raise :type :nitrate-not-configured
|
||||||
|
:hint "admin console is not configured; refer to the documentation to complete the setup")
|
||||||
|
(let [client (get cfg ::client)
|
||||||
|
method (get client method)]
|
||||||
|
(method params))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
@ -499,6 +503,8 @@
|
|||||||
(defmethod ig/init-key ::client
|
(defmethod ig/init-key ::client
|
||||||
[_ cfg]
|
[_ cfg]
|
||||||
(when (contains? cf/flags :admin-console)
|
(when (contains? cf/flags :admin-console)
|
||||||
|
(when (nil? (cf/get :admin-console-uri))
|
||||||
|
(l/warn :hint "admin console is not configured; nitrate calls will fail until the setup is complete"))
|
||||||
{:get-team-organization (partial get-team-organization-api cfg)
|
{:get-team-organization (partial get-team-organization-api cfg)
|
||||||
:get-teams-organizations (partial get-teams-organizations-api cfg)
|
:get-teams-organizations (partial get-teams-organizations-api cfg)
|
||||||
:set-team-organization (partial set-team-organization-api cfg)
|
:set-team-organization (partial set-team-organization-api cfg)
|
||||||
@ -593,14 +599,14 @@
|
|||||||
"Enriches a profile map with subscription information from Nitrate.
|
"Enriches a profile map with subscription information from Nitrate.
|
||||||
Adds a :subscription field containing the user's license details.
|
Adds a :subscription field containing the user's license details.
|
||||||
Returns the original profile unchanged if the request fails for a reason
|
Returns the original profile unchanged if the request fails for a reason
|
||||||
other than Nitrate being unreachable. When Nitrate is unreachable the
|
other than Nitrate being unreachable or unconfigured. When Nitrate is
|
||||||
`:nitrate-unavailable` exception propagates so the request is rejected."
|
unreachable or unconfigured the exception propagates so the request is rejected."
|
||||||
[cfg profile]
|
[cfg profile]
|
||||||
(try
|
(try
|
||||||
(let [subscription (call cfg :get-subscription {:profile-id (:id profile)})]
|
(let [subscription (call cfg :get-subscription {:profile-id (:id profile)})]
|
||||||
(assoc profile :subscription subscription))
|
(assoc profile :subscription subscription))
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(if (= :nitrate-unavailable (-> cause ex-data :type))
|
(if (contains? #{:nitrate-unavailable :nitrate-not-configured} (-> cause ex-data :type))
|
||||||
(throw cause)
|
(throw cause)
|
||||||
(do
|
(do
|
||||||
(l/error :hint "failed to get nitrate licence"
|
(l/error :hint "failed to get nitrate licence"
|
||||||
|
|||||||
@ -139,7 +139,7 @@
|
|||||||
|
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(if (= :not-found (-> cause ex-data :type))
|
(if (= :not-found (-> cause ex-data :type))
|
||||||
{:id uuid/zero :fullname "Anonymous User"}
|
(with-nitrate-licence {:id uuid/zero :fullname "Anonymous User"} cfg)
|
||||||
(throw cause)))))
|
(throw cause)))))
|
||||||
|
|
||||||
(defn get-profile
|
(defn get-profile
|
||||||
|
|||||||
@ -450,6 +450,7 @@
|
|||||||
(defmethod ptk/handle-error :bad-gateway [error] (handle-exceptional-state error))
|
(defmethod ptk/handle-error :bad-gateway [error] (handle-exceptional-state error))
|
||||||
(defmethod ptk/handle-error :service-unavailable [error] (handle-exceptional-state error))
|
(defmethod ptk/handle-error :service-unavailable [error] (handle-exceptional-state error))
|
||||||
(defmethod ptk/handle-error :nitrate-unavailable [error] (handle-exceptional-state error))
|
(defmethod ptk/handle-error :nitrate-unavailable [error] (handle-exceptional-state error))
|
||||||
|
(defmethod ptk/handle-error :nitrate-not-configured [error] (handle-exceptional-state error))
|
||||||
|
|
||||||
(defn- redirect-to-dashboard
|
(defn- redirect-to-dashboard
|
||||||
[]
|
[]
|
||||||
|
|||||||
@ -90,6 +90,10 @@
|
|||||||
(= :nitrate-unavailable (:type body)))
|
(= :nitrate-unavailable (:type body)))
|
||||||
(rx/throw (ex-info "http error" {:type :nitrate-unavailable}))
|
(rx/throw (ex-info "http error" {:type :nitrate-unavailable}))
|
||||||
|
|
||||||
|
(and (= 503 status)
|
||||||
|
(= :nitrate-not-configured (:type body)))
|
||||||
|
(rx/throw (ex-info "http error" {:type :nitrate-not-configured}))
|
||||||
|
|
||||||
(= 503 status)
|
(= 503 status)
|
||||||
(rx/throw (ex-info "http error" {:type :service-unavailable}))
|
(rx/throw (ex-info "http error" {:type :service-unavailable}))
|
||||||
|
|
||||||
|
|||||||
@ -342,6 +342,27 @@
|
|||||||
[:p {:class (stl/css :nitrate-unavailable-footer)}
|
[:p {:class (stl/css :nitrate-unavailable-footer)}
|
||||||
(tr "labels.copyright-period")]])
|
(tr "labels.copyright-period")]])
|
||||||
|
|
||||||
|
(mf/defc nitrate-not-configured-page*
|
||||||
|
[]
|
||||||
|
[:section {:class (stl/css :nitrate-unavailable-layout)}
|
||||||
|
[:div {:class (stl/css :nitrate-unavailable-content)}
|
||||||
|
[:> raw-svg* {:id "logo-nitrate-unavailable" :class (stl/css :nitrate-unavailable-logo)}]
|
||||||
|
[:div {:class (stl/css :nitrate-unavailable-message)}
|
||||||
|
(tr "labels.nitrate-not-configured.main-message")]
|
||||||
|
[:div {:class (stl/css :nitrate-not-configured-message)}
|
||||||
|
(tr "labels.nitrate-not-configured.desc-message")]
|
||||||
|
[:div {:class (stl/css :nitrate-not-configured-message)}
|
||||||
|
[:span
|
||||||
|
(tr "labels.nitrate-not-configured.learn-more")
|
||||||
|
" "
|
||||||
|
[:a {:href "https://help.penpot.app/technical-guide/getting-started/"
|
||||||
|
:target "_blank"
|
||||||
|
:rel "noopener noreferrer"}
|
||||||
|
(tr "labels.nitrate-not-configured.technical-guide")]]]]
|
||||||
|
|
||||||
|
[:p {:class (stl/css :nitrate-unavailable-footer)}
|
||||||
|
(tr "labels.copyright-period")]])
|
||||||
|
|
||||||
(mf/defc webgl-context-lost*
|
(mf/defc webgl-context-lost*
|
||||||
[]
|
[]
|
||||||
(let [on-reload (mf/use-fn #(js/location.reload))]
|
(let [on-reload (mf/use-fn #(js/location.reload))]
|
||||||
@ -562,6 +583,9 @@
|
|||||||
:nitrate-unavailable
|
:nitrate-unavailable
|
||||||
[:> nitrate-unavailable*]
|
[:> nitrate-unavailable*]
|
||||||
|
|
||||||
|
:nitrate-not-configured
|
||||||
|
[:> nitrate-not-configured-page*]
|
||||||
|
|
||||||
:sso-error
|
:sso-error
|
||||||
[:> sso-error-section* {:organization-id (get data :organization-id)
|
[:> sso-error-section* {:organization-id (get data :organization-id)
|
||||||
:organization-name (get data :organization-name)
|
:organization-name (get data :organization-name)
|
||||||
|
|||||||
@ -51,6 +51,14 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nitrate-not-configured-message {
|
||||||
|
@include t.use-typography("title-medium");
|
||||||
|
|
||||||
|
color: var(--color-foreground-secondary);
|
||||||
|
max-width: 32rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.nitrate-unavailable-footer {
|
.nitrate-unavailable-footer {
|
||||||
@include t.use-typography("title-medium");
|
@include t.use-typography("title-medium");
|
||||||
|
|
||||||
|
|||||||
@ -3289,6 +3289,22 @@ msgstr ""
|
|||||||
"Penpot is temporarily unavailable due to a system issue. Please try again "
|
"Penpot is temporarily unavailable due to a system issue. Please try again "
|
||||||
"shortly."
|
"shortly."
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:344
|
||||||
|
msgid "labels.nitrate-not-configured.main-message"
|
||||||
|
msgstr "Penpot can't start yet."
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:345
|
||||||
|
msgid "labels.nitrate-not-configured.desc-message"
|
||||||
|
msgstr "This instance needs a setup step that comes with the latest version."
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:346
|
||||||
|
msgid "labels.nitrate-not-configured.learn-more"
|
||||||
|
msgstr "Check out our"
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:346
|
||||||
|
msgid "labels.nitrate-not-configured.technical-guide"
|
||||||
|
msgstr "technical guide"
|
||||||
|
|
||||||
#: src/app/main/ui/dashboard/comments.cljs:120, src/app/main/ui/workspace/comments.cljs:162
|
#: src/app/main/ui/dashboard/comments.cljs:120, src/app/main/ui/workspace/comments.cljs:162
|
||||||
msgid "labels.no-comments-available"
|
msgid "labels.no-comments-available"
|
||||||
msgstr "You're all caught up! New comment notifications will appear here."
|
msgstr "You're all caught up! New comment notifications will appear here."
|
||||||
|
|||||||
@ -3199,6 +3199,22 @@ msgstr ""
|
|||||||
"Penpot no está disponible temporalmente debido a un problema del sistema. "
|
"Penpot no está disponible temporalmente debido a un problema del sistema. "
|
||||||
"Por favor, inténtalo de nuevo en unos momentos."
|
"Por favor, inténtalo de nuevo en unos momentos."
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:344
|
||||||
|
msgid "labels.nitrate-not-configured.main-message"
|
||||||
|
msgstr "Penpot no puede iniciarse aún."
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:345
|
||||||
|
msgid "labels.nitrate-not-configured.desc-message"
|
||||||
|
msgstr "Esta instancia requiere un paso de configuración que se incluye en la versión más reciente."
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:346
|
||||||
|
msgid "labels.nitrate-not-configured.learn-more"
|
||||||
|
msgstr "Echa un vistazo a nuestra"
|
||||||
|
|
||||||
|
#: src/app/main/ui/static.cljs:346
|
||||||
|
msgid "labels.nitrate-not-configured.technical-guide"
|
||||||
|
msgstr "technical guide"
|
||||||
|
|
||||||
#: src/app/main/ui/dashboard/comments.cljs:120, src/app/main/ui/workspace/comments.cljs:162
|
#: src/app/main/ui/dashboard/comments.cljs:120, src/app/main/ui/workspace/comments.cljs:162
|
||||||
msgid "labels.no-comments-available"
|
msgid "labels.no-comments-available"
|
||||||
msgstr "¡Ya estás al día! Nuevas notificaciones de comentarios aparecerán aquí."
|
msgstr "¡Ya estás al día! Nuevas notificaciones de comentarios aparecerán aquí."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user