mirror of
https://github.com/penpot/penpot.git
synced 2025-04-15 16:31:25 -05:00
✨ Improve 404 and add broken link static page on viewer.
This commit is contained in:
parent
15991d0226
commit
85a1c61880
7 changed files with 89 additions and 73 deletions
|
@ -42,10 +42,13 @@
|
|||
(if-let [conform (get-in match [:data :conform])]
|
||||
(let [spath (get conform :path-params ::any)
|
||||
squery (get conform :query-params ::any)]
|
||||
(-> (dissoc match :params)
|
||||
(assoc :path-params (us/conform spath (get match :path-params))
|
||||
:query-params (us/conform squery (get match :query-params)))))
|
||||
match)))
|
||||
(try
|
||||
(-> (dissoc match :params)
|
||||
(assoc :path-params (us/conform spath (get match :path-params))
|
||||
:query-params (us/conform squery (get match :query-params))))
|
||||
(catch :default _
|
||||
nil)))
|
||||
match)))
|
||||
|
||||
(defn on-navigate
|
||||
[router path]
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
;; --- COMMON SPECS
|
||||
|
||||
(defn is-authenticated?
|
||||
[{:keys [id]}]
|
||||
(and (uuid? id) (not= id uuid/zero)))
|
||||
|
||||
(s/def ::id ::us/uuid)
|
||||
(s/def ::fullname ::us/string)
|
||||
(s/def ::email ::us/email)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
[app.main.ui.render :as render]
|
||||
[app.main.ui.settings :as settings]
|
||||
[app.main.ui.static :as static]
|
||||
[app.main.ui.viewer :refer [viewer-page]]
|
||||
[app.main.ui.viewer :as viewer]
|
||||
[app.main.ui.workspace :as workspace]
|
||||
[app.util.timers :as ts]
|
||||
[cljs.pprint :refer [pprint]]
|
||||
|
@ -151,11 +151,13 @@
|
|||
{:keys [index share-id section page-id] :or {section :interactions}} query-params
|
||||
{:keys [file-id]} path-params]
|
||||
[:& fs/fullscreen-wrapper {}
|
||||
[:& viewer-page {:page-id page-id
|
||||
:file-id file-id
|
||||
:section section
|
||||
:index index
|
||||
:share-id share-id}]])
|
||||
(if (:token query-params)
|
||||
[:& viewer/breaking-change-notice]
|
||||
[:& viewer/viewer-page {:page-id page-id
|
||||
:file-id file-id
|
||||
:section section
|
||||
:index index
|
||||
:share-id share-id}])])
|
||||
|
||||
:render-object
|
||||
(do
|
||||
|
|
|
@ -12,82 +12,68 @@
|
|||
[app.main.store :as st]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.object :as obj]
|
||||
[app.util.router :as rt]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(defn- go-to-dashboard
|
||||
[profile]
|
||||
(let [team-id (du/get-current-team-id profile)]
|
||||
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))
|
||||
(mf/defc static-header
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [children (obj/get props "children")
|
||||
on-click (mf/use-callback
|
||||
(fn []
|
||||
(let [profile (deref refs/profile)]
|
||||
(if (du/is-authenticated? profile)
|
||||
(let [team-id (du/get-current-team-id profile)]
|
||||
(st/emit! (rt/nav :dashboard-projects {:team-id team-id})))
|
||||
(st/emit! (rt/nav :auth-login {}))))))]
|
||||
|
||||
[:section.exception-layout
|
||||
[:div.exception-header
|
||||
{:on-click on-click}
|
||||
i/logo]
|
||||
[:div.exception-content
|
||||
[:div.container children]]]))
|
||||
|
||||
(mf/defc not-found
|
||||
[]
|
||||
(let [profile (mf/deref refs/profile)]
|
||||
[:section.exception-layout
|
||||
[:div.exception-header
|
||||
{:on-click (partial go-to-dashboard profile)}
|
||||
i/logo]
|
||||
[:div.exception-content
|
||||
[:div.container
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.not-found.main-message")]
|
||||
[:div.desc-message (tr "labels.not-found.desc-message")]
|
||||
[:div.sign-info
|
||||
[:span (tr "labels.not-found.auth-info") " " [:b (:email profile)]]
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf (du/logout))}
|
||||
(tr "labels.sign-out")]]]]]))
|
||||
[:> static-header {}
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.not-found.main-message")]
|
||||
[:div.desc-message (tr "labels.not-found.desc-message")]])
|
||||
|
||||
(mf/defc bad-gateway
|
||||
[]
|
||||
(let [profile (mf/deref refs/profile)]
|
||||
[:section.exception-layout
|
||||
[:div.exception-header
|
||||
{:on-click (partial go-to-dashboard profile)}
|
||||
i/logo]
|
||||
[:div.exception-content
|
||||
[:div.container
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.bad-gateway.main-message")]
|
||||
[:div.desc-message (tr "labels.bad-gateway.desc-message")]
|
||||
[:div.sign-info
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf #(dissoc % :exception))}
|
||||
(tr "labels.retry")]]]]]))
|
||||
[:> static-header {}
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.bad-gateway.main-message")]
|
||||
[:div.desc-message (tr "labels.bad-gateway.desc-message")]
|
||||
[:div.sign-info
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf #(dissoc % :exception))}
|
||||
(tr "labels.retry")]]])
|
||||
|
||||
(mf/defc service-unavailable
|
||||
[]
|
||||
(let [profile (mf/deref refs/profile)]
|
||||
[:section.exception-layout
|
||||
[:div.exception-header
|
||||
{:on-click (partial go-to-dashboard profile)}
|
||||
i/logo]
|
||||
[:div.exception-content
|
||||
[:div.container
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.service-unavailable.main-message")]
|
||||
[:div.desc-message (tr "labels.service-unavailable.desc-message")]
|
||||
[:div.sign-info
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf #(dissoc % :exception))}
|
||||
(tr "labels.retry")]]]]]))
|
||||
[:> static-header {}
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.service-unavailable.main-message")]
|
||||
[:div.desc-message (tr "labels.service-unavailable.desc-message")]
|
||||
[:div.sign-info
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf #(dissoc % :exception))}
|
||||
(tr "labels.retry")]]])
|
||||
|
||||
(mf/defc internal-error
|
||||
[]
|
||||
(let [profile (mf/deref refs/profile)]
|
||||
[:section.exception-layout
|
||||
[:div.exception-header
|
||||
{:on-click (partial go-to-dashboard profile)}
|
||||
i/logo]
|
||||
[:div.exception-content
|
||||
[:div.container
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.internal-error.main-message")]
|
||||
[:div.desc-message (tr "labels.internal-error.desc-message")]
|
||||
[:div.sign-info
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf (dm/assign-exception nil))}
|
||||
(tr "labels.retry")]]]]]))
|
||||
[:> static-header {}
|
||||
[:div.image i/icon-empty]
|
||||
[:div.main-message (tr "labels.internal-error.main-message")]
|
||||
[:div.desc-message (tr "labels.internal-error.desc-message")]
|
||||
[:div.sign-info
|
||||
[:a.btn-primary.btn-small
|
||||
{:on-click (st/emitf (dm/assign-exception nil))}
|
||||
(tr "labels.retry")]]])
|
||||
|
||||
(mf/defc exception-page
|
||||
[{:keys [data] :as props}]
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.main.ui.share-link]
|
||||
[app.main.ui.static :as static]
|
||||
[app.main.ui.viewer.comments :refer [comments-layer]]
|
||||
[app.main.ui.viewer.handoff :as handoff]
|
||||
[app.main.ui.viewer.header :refer [header]]
|
||||
|
@ -150,3 +152,10 @@
|
|||
(when-let [data (mf/deref refs/viewer-data)]
|
||||
(let [key (str (get-in data [:file :id]))]
|
||||
[:& viewer {:params props :data data :key key}])))
|
||||
|
||||
(mf/defc breaking-change-notice
|
||||
[]
|
||||
[:> static/static-header {}
|
||||
[:div.image i/unchain]
|
||||
[:div.main-message (tr "viewer.breaking-change.message")]
|
||||
[:div.desc-message (tr "viewer.breaking-change.description")]])
|
||||
|
|
|
@ -2968,4 +2968,10 @@ msgid "workspace.updates.update"
|
|||
msgstr "Update"
|
||||
|
||||
msgid "workspace.viewport.click-to-close-path"
|
||||
msgstr "Click to close the path"
|
||||
msgstr "Click to close the path"
|
||||
|
||||
msgid "viewer.breaking-change.message"
|
||||
msgstr "Sorry!"
|
||||
|
||||
msgid "viewer.breaking-change.description"
|
||||
msgstr "This shareable link is no longer valid. Create a new one or ask the owner for a new one.
|
||||
|
|
|
@ -2853,4 +2853,10 @@ msgid "workspace.updates.update"
|
|||
msgstr "Actualizar"
|
||||
|
||||
msgid "workspace.viewport.click-to-close-path"
|
||||
msgstr "Pulsar para cerrar la ruta"
|
||||
msgstr "Pulsar para cerrar la ruta"
|
||||
|
||||
msgid "viewer.breaking-change.message"
|
||||
msgstr "¡Lo sentimos!"
|
||||
|
||||
msgid "viewer.breaking-change.description"
|
||||
msgstr "Este link compartido ya no funciona. Crea uno nuevo o pídelo a la persona que lo creó."
|
||||
|
|
Loading…
Add table
Reference in a new issue