mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Merge pull request #5280 from penpot/palba-enhancements-viewer-role
Enhancements for viewer role
This commit is contained in:
commit
df416af19b
8 changed files with 65 additions and 32 deletions
|
@ -424,7 +424,10 @@
|
||||||
:fn (mg/resource "app/migrations/sql/0133-mod-file-table.sql")}
|
:fn (mg/resource "app/migrations/sql/0133-mod-file-table.sql")}
|
||||||
|
|
||||||
{:name "0134-mod-file-change-table"
|
{:name "0134-mod-file-change-table"
|
||||||
:fn (mg/resource "app/migrations/sql/0134-mod-file-change-table.sql")}])
|
:fn (mg/resource "app/migrations/sql/0134-mod-file-change-table.sql")}
|
||||||
|
|
||||||
|
{:name "0135-mod-team-invitation-table.sql"
|
||||||
|
:fn (mg/resource "app/migrations/sql/0135-mod-team-invitation-table.sql")}])
|
||||||
|
|
||||||
(defn apply-migrations!
|
(defn apply-migrations!
|
||||||
[pool name migrations]
|
[pool name migrations]
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE team_invitation
|
||||||
|
ADD COLUMN created_by uuid NULL REFERENCES profile(id) ON DELETE SET NULL;
|
|
@ -383,7 +383,9 @@
|
||||||
invitation (when-let [token (:invitation-token params)]
|
invitation (when-let [token (:invitation-token params)]
|
||||||
(tokens/verify (::setup/props cfg) {:token token :iss :team-invitation}))
|
(tokens/verify (::setup/props cfg) {:token token :iss :team-invitation}))
|
||||||
|
|
||||||
props (audit/profile->props profile)
|
props (-> (audit/profile->props profile)
|
||||||
|
(assoc :from-invitation (some? invitation)))
|
||||||
|
|
||||||
|
|
||||||
create-welcome-file-when-needed
|
create-welcome-file-when-needed
|
||||||
(fn []
|
(fn []
|
||||||
|
|
|
@ -759,8 +759,8 @@
|
||||||
;; --- Mutation: Create Team Invitation
|
;; --- Mutation: Create Team Invitation
|
||||||
|
|
||||||
(def sql:upsert-team-invitation
|
(def sql:upsert-team-invitation
|
||||||
"insert into team_invitation(id, team_id, email_to, role, valid_until)
|
"insert into team_invitation(id, team_id, email_to, role, valid_until, created_by)
|
||||||
values (?, ?, ?, ?, ?)
|
values (?, ?, ?, ?, ?, ?)
|
||||||
on conflict(team_id, email_to) do
|
on conflict(team_id, email_to) do
|
||||||
update set role = ?, valid_until = ?, updated_at = now()
|
update set role = ?, valid_until = ?, updated_at = now()
|
||||||
returning *")
|
returning *")
|
||||||
|
@ -853,6 +853,7 @@
|
||||||
invitation (db/exec-one! conn [sql:upsert-team-invitation id
|
invitation (db/exec-one! conn [sql:upsert-team-invitation id
|
||||||
(:id team) (str/lower email)
|
(:id team) (str/lower email)
|
||||||
(name role) expire
|
(name role) expire
|
||||||
|
(:id profile)
|
||||||
(name role) expire])
|
(name role) expire])
|
||||||
updated? (not= id (:id invitation))
|
updated? (not= id (:id invitation))
|
||||||
profile-id (:id profile)
|
profile-id (:id profile)
|
||||||
|
|
|
@ -167,12 +167,24 @@
|
||||||
(let [props {:team-id (:team-id claims)
|
(let [props {:team-id (:team-id claims)
|
||||||
:role (:role claims)
|
:role (:role claims)
|
||||||
:invitation-id (:id invitation)}
|
:invitation-id (:id invitation)}
|
||||||
event (-> (audit/event-from-rpc-params params)
|
|
||||||
|
accept-invitation-event
|
||||||
|
(-> (audit/event-from-rpc-params params)
|
||||||
(assoc ::audit/name "accept-team-invitation")
|
(assoc ::audit/name "accept-team-invitation")
|
||||||
(assoc ::audit/props props))]
|
(assoc ::audit/props props))
|
||||||
|
|
||||||
|
accept-invitation-from-event
|
||||||
|
(-> (audit/event-from-rpc-params params)
|
||||||
|
(assoc ::audit/profile-id (:created-by invitation))
|
||||||
|
(assoc ::audit/name "accept-team-invitation-from")
|
||||||
|
(assoc ::audit/props (assoc props
|
||||||
|
:profile-id (:id profile)
|
||||||
|
:email (:email profile))))]
|
||||||
|
|
||||||
|
(audit/submit! cfg accept-invitation-event)
|
||||||
|
(audit/submit! cfg accept-invitation-from-event)
|
||||||
|
|
||||||
(accept-invitation cfg claims invitation profile)
|
(accept-invitation cfg claims invitation profile)
|
||||||
(audit/submit! cfg event)
|
|
||||||
(assoc claims :state :created))
|
(assoc claims :state :created))
|
||||||
|
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
|
|
|
@ -457,12 +457,14 @@
|
||||||
on-drop
|
on-drop
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [e]
|
(fn [e]
|
||||||
|
(if can-edit
|
||||||
(when (and (not (dnd/has-type? e "penpot/files"))
|
(when (and (not (dnd/has-type? e "penpot/files"))
|
||||||
(or (dnd/has-type? e "Files")
|
(or (dnd/has-type? e "Files")
|
||||||
(dnd/has-type? e "application/x-moz-file")))
|
(dnd/has-type? e "application/x-moz-file")))
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(reset! dragging? false)
|
(reset! dragging? false)
|
||||||
(import-files (.-files (.-dataTransfer e))))))]
|
(import-files (.-files (.-dataTransfer e))))
|
||||||
|
(dom/prevent-default e))))]
|
||||||
|
|
||||||
[:div {:class (stl/css :dashboard-grid)
|
[:div {:class (stl/css :dashboard-grid)
|
||||||
:dragabble (dm/str can-edit)
|
:dragabble (dm/str can-edit)
|
||||||
|
@ -576,8 +578,9 @@
|
||||||
|
|
||||||
on-drop
|
on-drop
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps files selected-files)
|
(mf/deps files selected-files can-edit)
|
||||||
(fn [e]
|
(fn [e]
|
||||||
|
(if can-edit
|
||||||
(cond
|
(cond
|
||||||
(dnd/has-type? e "penpot/files")
|
(dnd/has-type? e "penpot/files")
|
||||||
(do
|
(do
|
||||||
|
@ -593,7 +596,8 @@
|
||||||
(do
|
(do
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(reset! dragging? false)
|
(reset! dragging? false)
|
||||||
(import-files (.-files (.-dataTransfer e)))))))]
|
(import-files (.-files (.-dataTransfer e)))))
|
||||||
|
(dom/prevent-default e))))]
|
||||||
|
|
||||||
[:div {:class (stl/css :dashboard-grid)
|
[:div {:class (stl/css :dashboard-grid)
|
||||||
:dragabble (dm/str can-edit)
|
:dragabble (dm/str can-edit)
|
||||||
|
|
|
@ -686,10 +686,12 @@
|
||||||
(dp/open-plugin! manifest user-can-edit?)))))]
|
(dp/open-plugin! manifest user-can-edit?)))))]
|
||||||
[:> dropdown-menu-item* {:key (dm/str "plugins-menu-" idx)
|
[:> dropdown-menu-item* {:key (dm/str "plugins-menu-" idx)
|
||||||
:on-click on-click
|
:on-click on-click
|
||||||
:title (when-not can-open? (tr "workspace.plugins.error.need-editor"))
|
|
||||||
:class (stl/css-case :submenu-item true :menu-disabled (not can-open?))
|
:class (stl/css-case :submenu-item true :menu-disabled (not can-open?))
|
||||||
:on-key-down on-key-down}
|
:on-key-down on-key-down}
|
||||||
[:span {:class (stl/css :item-name)} name]]))])))
|
[:span {:class (stl/css :item-name)} name]
|
||||||
|
(when-not can-open?
|
||||||
|
[:span {:class (stl/css :item-icon)
|
||||||
|
:title (tr "workspace.plugins.error.need-editor")} i/help])]))])))
|
||||||
|
|
||||||
(mf/defc menu
|
(mf/defc menu
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
|
|
|
@ -113,3 +113,10 @@
|
||||||
top: $s-192;
|
top: $s-192;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item-icon {
|
||||||
|
svg {
|
||||||
|
@extend .button-icon;
|
||||||
|
stroke: var(--icon-foreground);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue