0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-20 11:41:47 -05:00

🐛 Fix corner case of change rol to viewer when editing a text

This commit is contained in:
Pablo Alba 2024-10-21 16:10:53 +02:00
parent 4622dd0e0d
commit 68f560e29b
3 changed files with 42 additions and 36 deletions
frontend/src/app/main

View file

@ -118,22 +118,25 @@
:created-at (:created-at commit)
:commit-id commit-id
:changes (vec changes)
:features features}]
:features features}
permissions (:permissions state)]
(->> (rp/cmd! :update-file params)
(rx/mapcat (fn [{:keys [revn lagged] :as response}]
(log/debug :hint "changes persisted" :commit-id (dm/str commit-id) :lagged (count lagged))
(rx/of (ptk/data-event ::commit-persisted commit)
(update-file-revn file-id revn))))
;; Prevent commit changes by a team member without edition permission
(when (:can-edit permissions)
(->> (rp/cmd! :update-file params)
(rx/mapcat (fn [{:keys [revn lagged] :as response}]
(log/debug :hint "changes persisted" :commit-id (dm/str commit-id) :lagged (count lagged))
(rx/of (ptk/data-event ::commit-persisted commit)
(update-file-revn file-id revn))))
(rx/catch (fn [cause]
(rx/concat
(if (= :authentication (:type cause))
(rx/empty)
(rx/of (ptk/data-event ::error cause)
(update-status :error)))
(rx/of (discard-persistence-state))
(rx/throw cause))))))))))
(rx/catch (fn [cause]
(rx/concat
(if (= :authentication (:type cause))
(rx/empty)
(rx/of (ptk/data-event ::error cause)
(update-status :error)))
(rx/of (discard-persistence-state))
(rx/throw cause)))))))))))
(defn- run-persistence-task

View file

@ -18,8 +18,8 @@
[app.main.data.workspace.common :as dwc]
[app.main.data.workspace.edition :as dwe]
[app.main.data.workspace.layout :as dwly]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.texts :as dwt]
[app.util.globals :refer [global]]
[app.util.mouse :as mse]
[app.util.object :as obj]
@ -106,7 +106,8 @@
(rx/of :interrupt
(dwe/clear-edition-mode)
(dwc/set-workspace-read-only false))
(->> (rx/of (dc/change-team-role msg))
(->> (rx/of (dc/change-team-role msg)
::dwt/update-editor-state)
;; Delay so anything that launched :interrupt can finish
(rx/delay 100))
(if (= :viewer role)

View file

@ -34,30 +34,32 @@
{::mf/wrap [mf/memo]
::mf/wrap-props false}
[]
(let [status (mf/deref ref:persistence-status)]
[:div {:class (stl/css :persistence-status-widget)}
(case status
:pending
[:div {:class (stl/css :status-icon :pending-status)
:title (tr "workspace.header.unsaved")}
i/status-alert]
(let [status (mf/deref ref:persistence-status)
workspace-read-only? (mf/use-ctx ctx/workspace-read-only?)]
(when-not workspace-read-only?
[:div {:class (stl/css :persistence-status-widget)}
(case status
:pending
[:div {:class (stl/css :status-icon :pending-status)
:title (tr "workspace.header.unsaved")}
i/status-alert]
:saving
[:div {:class (stl/css :status-icon :pending-status)
:title (tr "workspace.header.unsaved")}
i/status-alert]
:saving
[:div {:class (stl/css :status-icon :pending-status)
:title (tr "workspace.header.unsaved")}
i/status-alert]
:saved
[:div {:class (stl/css :status-icon :saved-status)
:title (tr "workspace.header.saved")}
i/status-tick]
:saved
[:div {:class (stl/css :status-icon :saved-status)
:title (tr "workspace.header.saved")}
i/status-tick]
:error
[:div {:class (stl/css :status-icon :error-status)
:title "There was an error saving the data. Please refresh if this persists."}
i/status-wrong]
:error
[:div {:class (stl/css :status-icon :error-status)
:title "There was an error saving the data. Please refresh if this persists."}
i/status-wrong]
nil)]))
nil)])))
;; --- Zoom Widget