mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 16:00:19 -05: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")}
|
||||
|
||||
{: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!
|
||||
[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)]
|
||||
(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
|
||||
(fn []
|
||||
|
|
|
@ -759,8 +759,8 @@
|
|||
;; --- Mutation: Create Team Invitation
|
||||
|
||||
(def sql:upsert-team-invitation
|
||||
"insert into team_invitation(id, team_id, email_to, role, valid_until)
|
||||
values (?, ?, ?, ?, ?)
|
||||
"insert into team_invitation(id, team_id, email_to, role, valid_until, created_by)
|
||||
values (?, ?, ?, ?, ?, ?)
|
||||
on conflict(team_id, email_to) do
|
||||
update set role = ?, valid_until = ?, updated_at = now()
|
||||
returning *")
|
||||
|
@ -853,6 +853,7 @@
|
|||
invitation (db/exec-one! conn [sql:upsert-team-invitation id
|
||||
(:id team) (str/lower email)
|
||||
(name role) expire
|
||||
(:id profile)
|
||||
(name role) expire])
|
||||
updated? (not= id (:id invitation))
|
||||
profile-id (:id profile)
|
||||
|
|
|
@ -167,12 +167,24 @@
|
|||
(let [props {:team-id (:team-id claims)
|
||||
:role (:role claims)
|
||||
:invitation-id (:id invitation)}
|
||||
event (-> (audit/event-from-rpc-params params)
|
||||
(assoc ::audit/name "accept-team-invitation")
|
||||
(assoc ::audit/props props))]
|
||||
|
||||
accept-invitation-event
|
||||
(-> (audit/event-from-rpc-params params)
|
||||
(assoc ::audit/name "accept-team-invitation")
|
||||
(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)
|
||||
(audit/submit! cfg event)
|
||||
(assoc claims :state :created))
|
||||
|
||||
(ex/raise :type :validation
|
||||
|
|
|
@ -457,12 +457,14 @@
|
|||
on-drop
|
||||
(mf/use-fn
|
||||
(fn [e]
|
||||
(when (and (not (dnd/has-type? e "penpot/files"))
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file")))
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e))))))]
|
||||
(if can-edit
|
||||
(when (and (not (dnd/has-type? e "penpot/files"))
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file")))
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e))))
|
||||
(dom/prevent-default e))))]
|
||||
|
||||
[:div {:class (stl/css :dashboard-grid)
|
||||
:dragabble (dm/str can-edit)
|
||||
|
@ -576,24 +578,26 @@
|
|||
|
||||
on-drop
|
||||
(mf/use-fn
|
||||
(mf/deps files selected-files)
|
||||
(mf/deps files selected-files can-edit)
|
||||
(fn [e]
|
||||
(cond
|
||||
(dnd/has-type? e "penpot/files")
|
||||
(do
|
||||
(reset! dragging? false)
|
||||
(when (not= selected-project project-id)
|
||||
(let [data {:ids (into #{} (keys selected-files))
|
||||
:project-id project-id}
|
||||
mdata {:on-success on-drop-success}]
|
||||
(st/emit! (dd/move-files (with-meta data mdata))))))
|
||||
(if can-edit
|
||||
(cond
|
||||
(dnd/has-type? e "penpot/files")
|
||||
(do
|
||||
(reset! dragging? false)
|
||||
(when (not= selected-project project-id)
|
||||
(let [data {:ids (into #{} (keys selected-files))
|
||||
:project-id project-id}
|
||||
mdata {:on-success on-drop-success}]
|
||||
(st/emit! (dd/move-files (with-meta data mdata))))))
|
||||
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file"))
|
||||
(do
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e)))))))]
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file"))
|
||||
(do
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e)))))
|
||||
(dom/prevent-default e))))]
|
||||
|
||||
[:div {:class (stl/css :dashboard-grid)
|
||||
:dragabble (dm/str can-edit)
|
||||
|
|
|
@ -686,10 +686,12 @@
|
|||
(dp/open-plugin! manifest user-can-edit?)))))]
|
||||
[:> dropdown-menu-item* {:key (dm/str "plugins-menu-" idx)
|
||||
: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?))
|
||||
: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/props :obj}
|
||||
|
|
|
@ -113,3 +113,10 @@
|
|||
top: $s-192;
|
||||
}
|
||||
}
|
||||
|
||||
.item-icon {
|
||||
svg {
|
||||
@extend .button-icon;
|
||||
stroke: var(--icon-foreground);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue