0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Merge pull request #5422 from penpot/eva-fix-demote-owner

🐛  Fix admin can demote owner
This commit is contained in:
Alejandro 2024-12-05 09:37:22 +01:00 committed by GitHub
commit bd1286aace
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 6 deletions

View file

@ -0,0 +1,30 @@
[
{
"~:is-admin": true,
"~:email": "bar@example.com",
"~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3",
"~:name": "Han Solo",
"~:fullname": "Han Solo",
"~:is-owner": true,
"~:modified-at": "~m1713533116365",
"~:can-edit": true,
"~:is-active": true,
"~:id": "~u1e162163-87b7-805b-8005-5fd05514b6d3",
"~:profile-id": "~u1e162163-87b7-805b-8005-5fd05514b6d3",
"~:created-at": "~m1733324626956"
},
{
"~:is-admin": true,
"~:email": "foo@example.com",
"~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3",
"~:name": "Princesa Leia",
"~:fullname": "Princesa Leia",
"~:is-owner": false,
"~:modified-at": "~m1713533116365",
"~:can-edit": true,
"~:is-active": true,
"~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b",
"~:profile-id": "~uf56647eb-19a7-8115-8003-b6bc939ecd1b",
"~:created-at": "~m1713533116365"
}
]

View file

@ -35,7 +35,7 @@
},
"~:permissions": {
"~:type": "~:membership",
"~:is-owner": true,
"~:is-owner": false,
"~:is-admin": true,
"~:can-edit": true
},

View file

@ -52,3 +52,20 @@ test("Lists files in the drafts page", async ({ page }) => {
dashboardPage.page.getByRole("button", { name: /New File 2/ }),
).toBeVisible();
});
test("Bug 9443, Admin can not demote owner", async ({ page }) => {
const dashboardPage = new DashboardPage(page);
await dashboardPage.setupDashboardFull();
await DashboardPage.mockRPC(
page,
"get-team-members?team-id=*",
"dashboard/get-team-members-admin.json",
);
await dashboardPage.goToSecondTeamMembersSection();
await expect(page.getByRole("heading", { name: "Members" })).toBeVisible();
await expect(page.getByRole("combobox", { name: "Admin" })).toBeVisible();
await expect(page.getByText("Owner")).toBeVisible();
await expect(page.getByRole("combobox", { name: "Owner" })).toHaveCount(0);
});

View file

@ -278,27 +278,30 @@
is-you (= (:id profile) (:id member))
can-change-rol (or is-owner is-admin)
not-superior (or is-admin (and can-change-rol (or member-is-admin member-is-editor member-is-viewer)))
not-superior (or (and (not member-is-owner) is-admin) (and can-change-rol (or member-is-admin member-is-editor member-is-viewer)))
role (cond
member-is-owner "labels.owner"
member-is-admin "labels.admin"
member-is-editor "labels.editor"
:else "labels.viewer")
:else "labels.viewer")
on-show (mf/use-fn #(reset! show? true))
on-hide (mf/use-fn #(reset! show? false))]
[:*
(if (and can-change-rol not-superior (not (and is-you is-owner)))
[:div {:class (stl/css :rol-selector :has-priv)
:role "combobox"
:aria-labelledby "role-label-id"
:on-click on-show}
[:span {:class (stl/css :rol-label)} (tr role)]
[:span {:class (stl/css :rol-label)
:id "role-label-id"} (tr role)]
arrow-icon]
[:div {:class (stl/css :rol-selector)}
[:span {:class (stl/css :rol-label)} (tr role)]])
[:& dropdown {:show @show? :on-close on-hide}
[:ul {:class (stl/css :roles-dropdown)}
[:ul {:class (stl/css :roles-dropdown)
:role "listbox"}
[:li {:on-click on-set-viewer
:class (stl/css :rol-dropdown-item)}
(tr "labels.viewer")]