mirror of
https://github.com/penpot/penpot.git
synced 2025-05-25 15:16:10 +02: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,9 +42,12 @@
|
||||||
(if-let [conform (get-in match [:data :conform])]
|
(if-let [conform (get-in match [:data :conform])]
|
||||||
(let [spath (get conform :path-params ::any)
|
(let [spath (get conform :path-params ::any)
|
||||||
squery (get conform :query-params ::any)]
|
squery (get conform :query-params ::any)]
|
||||||
|
(try
|
||||||
(-> (dissoc match :params)
|
(-> (dissoc match :params)
|
||||||
(assoc :path-params (us/conform spath (get match :path-params))
|
(assoc :path-params (us/conform spath (get match :path-params))
|
||||||
:query-params (us/conform squery (get match :query-params)))))
|
:query-params (us/conform squery (get match :query-params))))
|
||||||
|
(catch :default _
|
||||||
|
nil)))
|
||||||
match)))
|
match)))
|
||||||
|
|
||||||
(defn on-navigate
|
(defn on-navigate
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
|
|
||||||
;; --- COMMON SPECS
|
;; --- COMMON SPECS
|
||||||
|
|
||||||
|
(defn is-authenticated?
|
||||||
|
[{:keys [id]}]
|
||||||
|
(and (uuid? id) (not= id uuid/zero)))
|
||||||
|
|
||||||
(s/def ::id ::us/uuid)
|
(s/def ::id ::us/uuid)
|
||||||
(s/def ::fullname ::us/string)
|
(s/def ::fullname ::us/string)
|
||||||
(s/def ::email ::us/email)
|
(s/def ::email ::us/email)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
[app.main.ui.render :as render]
|
[app.main.ui.render :as render]
|
||||||
[app.main.ui.settings :as settings]
|
[app.main.ui.settings :as settings]
|
||||||
[app.main.ui.static :as static]
|
[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.main.ui.workspace :as workspace]
|
||||||
[app.util.timers :as ts]
|
[app.util.timers :as ts]
|
||||||
[cljs.pprint :refer [pprint]]
|
[cljs.pprint :refer [pprint]]
|
||||||
|
@ -151,11 +151,13 @@
|
||||||
{:keys [index share-id section page-id] :or {section :interactions}} query-params
|
{:keys [index share-id section page-id] :or {section :interactions}} query-params
|
||||||
{:keys [file-id]} path-params]
|
{:keys [file-id]} path-params]
|
||||||
[:& fs/fullscreen-wrapper {}
|
[:& fs/fullscreen-wrapper {}
|
||||||
[:& viewer-page {:page-id page-id
|
(if (:token query-params)
|
||||||
|
[:& viewer/breaking-change-notice]
|
||||||
|
[:& viewer/viewer-page {:page-id page-id
|
||||||
:file-id file-id
|
:file-id file-id
|
||||||
:section section
|
:section section
|
||||||
:index index
|
:index index
|
||||||
:share-id share-id}]])
|
:share-id share-id}])])
|
||||||
|
|
||||||
:render-object
|
:render-object
|
||||||
(do
|
(do
|
||||||
|
|
|
@ -12,82 +12,68 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
|
[app.util.object :as obj]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(defn- go-to-dashboard
|
(mf/defc static-header
|
||||||
[profile]
|
{::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)]
|
(let [team-id (du/get-current-team-id profile)]
|
||||||
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))
|
(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
|
(mf/defc not-found
|
||||||
[]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
[:> static-header {}
|
||||||
[: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.image i/icon-empty]
|
||||||
[:div.main-message (tr "labels.not-found.main-message")]
|
[:div.main-message (tr "labels.not-found.main-message")]
|
||||||
[:div.desc-message (tr "labels.not-found.desc-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")]]]]]))
|
|
||||||
|
|
||||||
(mf/defc bad-gateway
|
(mf/defc bad-gateway
|
||||||
[]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
[:> static-header {}
|
||||||
[: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.image i/icon-empty]
|
||||||
[:div.main-message (tr "labels.bad-gateway.main-message")]
|
[:div.main-message (tr "labels.bad-gateway.main-message")]
|
||||||
[:div.desc-message (tr "labels.bad-gateway.desc-message")]
|
[:div.desc-message (tr "labels.bad-gateway.desc-message")]
|
||||||
[:div.sign-info
|
[:div.sign-info
|
||||||
[:a.btn-primary.btn-small
|
[:a.btn-primary.btn-small
|
||||||
{:on-click (st/emitf #(dissoc % :exception))}
|
{:on-click (st/emitf #(dissoc % :exception))}
|
||||||
(tr "labels.retry")]]]]]))
|
(tr "labels.retry")]]])
|
||||||
|
|
||||||
(mf/defc service-unavailable
|
(mf/defc service-unavailable
|
||||||
[]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
[:> static-header {}
|
||||||
[: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.image i/icon-empty]
|
||||||
[:div.main-message (tr "labels.service-unavailable.main-message")]
|
[:div.main-message (tr "labels.service-unavailable.main-message")]
|
||||||
[:div.desc-message (tr "labels.service-unavailable.desc-message")]
|
[:div.desc-message (tr "labels.service-unavailable.desc-message")]
|
||||||
[:div.sign-info
|
[:div.sign-info
|
||||||
[:a.btn-primary.btn-small
|
[:a.btn-primary.btn-small
|
||||||
{:on-click (st/emitf #(dissoc % :exception))}
|
{:on-click (st/emitf #(dissoc % :exception))}
|
||||||
(tr "labels.retry")]]]]]))
|
(tr "labels.retry")]]])
|
||||||
|
|
||||||
(mf/defc internal-error
|
(mf/defc internal-error
|
||||||
[]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
[:> static-header {}
|
||||||
[: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.image i/icon-empty]
|
||||||
[:div.main-message (tr "labels.internal-error.main-message")]
|
[:div.main-message (tr "labels.internal-error.main-message")]
|
||||||
[:div.desc-message (tr "labels.internal-error.desc-message")]
|
[:div.desc-message (tr "labels.internal-error.desc-message")]
|
||||||
[:div.sign-info
|
[:div.sign-info
|
||||||
[:a.btn-primary.btn-small
|
[:a.btn-primary.btn-small
|
||||||
{:on-click (st/emitf (dm/assign-exception nil))}
|
{:on-click (st/emitf (dm/assign-exception nil))}
|
||||||
(tr "labels.retry")]]]]]))
|
(tr "labels.retry")]]])
|
||||||
|
|
||||||
(mf/defc exception-page
|
(mf/defc exception-page
|
||||||
[{:keys [data] :as props}]
|
[{:keys [data] :as props}]
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.share-link]
|
[app.main.ui.share-link]
|
||||||
|
[app.main.ui.static :as static]
|
||||||
[app.main.ui.viewer.comments :refer [comments-layer]]
|
[app.main.ui.viewer.comments :refer [comments-layer]]
|
||||||
[app.main.ui.viewer.handoff :as handoff]
|
[app.main.ui.viewer.handoff :as handoff]
|
||||||
[app.main.ui.viewer.header :refer [header]]
|
[app.main.ui.viewer.header :refer [header]]
|
||||||
|
@ -150,3 +152,10 @@
|
||||||
(when-let [data (mf/deref refs/viewer-data)]
|
(when-let [data (mf/deref refs/viewer-data)]
|
||||||
(let [key (str (get-in data [:file :id]))]
|
(let [key (str (get-in data [:file :id]))]
|
||||||
[:& viewer {:params props :data data :key key}])))
|
[:& 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")]])
|
||||||
|
|
|
@ -2969,3 +2969,9 @@ msgstr "Update"
|
||||||
|
|
||||||
msgid "workspace.viewport.click-to-close-path"
|
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.
|
||||||
|
|
|
@ -2854,3 +2854,9 @@ msgstr "Actualizar"
|
||||||
|
|
||||||
msgid "workspace.viewport.click-to-close-path"
|
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
Add a link
Reference in a new issue