From 005728009b79c2466188f432245c6c0d5cdce8bc Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 29 Nov 2023 16:34:59 +0100 Subject: [PATCH] Add owner role support Update checks for admin to include owner role Updated role list to include role for users Updated activity with new event type handler --- src/components/Navbar.tsx | 2 +- src/components/UserEdit.tsx | 5 ++++- src/views/Activity.tsx | 14 ++++++++++++++ src/views/Peers.tsx | 2 +- src/views/RegularUsers.tsx | 2 +- src/views/Users.tsx | 2 +- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index d96bf7bd..2c278630 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -161,7 +161,7 @@ const Navbar = () => { return false; } - if (user.role?.toLowerCase() === "admin") { + if (user.role?.toLowerCase() === "admin" || user.role?.toLowerCase() === "owner") { return true; } return !adminOnlyTabs.find((t) => t === key); diff --git a/src/components/UserEdit.tsx b/src/components/UserEdit.tsx index f17f4bb5..e3f1c44f 100644 --- a/src/components/UserEdit.tsx +++ b/src/components/UserEdit.tsx @@ -120,7 +120,7 @@ const UserEdit = (props: any) => { if (users) { let currentUser = users.find((user) => user?.is_current); if (currentUser) { - setIsAdmin(currentUser.role === "admin"); + setIsAdmin(currentUser.role === "admin" || currentUser.role === "owner"); } } }, [users]); @@ -411,6 +411,9 @@ const UserEdit = (props: any) => { + diff --git a/src/views/Activity.tsx b/src/views/Activity.tsx index 1ee49544..3fc8af6d 100644 --- a/src/views/Activity.tsx +++ b/src/views/Activity.tsx @@ -362,6 +362,20 @@ export const Activity = () => { ); } return "-"; + case "transferred.owner.role": + if (event.meta.email || event.meta.username || event.target_id) { + return renderMultiRowSpan( + event.meta.username ? event.meta.username : event.target_id, + event.meta.email ? event.meta.email : "User" + ); + } + if (event.meta.user_name) { + return renderMultiRowSpan( + event.meta.user_name, + event.meta.is_service_user ? "Service User" : "User" + ); + } + return "-"; case "setupkey.group.add": case "setupkey.group.delete": return renderMultiRowSpan(event.meta.setupkey, "Setup Key"); diff --git a/src/views/Peers.tsx b/src/views/Peers.tsx index 7225929d..b6ca5980 100644 --- a/src/views/Peers.tsx +++ b/src/views/Peers.tsx @@ -126,7 +126,7 @@ export const Peers = () => { if (users) { let currentUser = users.find((user) => user.is_current); if (currentUser) { - setIsAdmin(currentUser.role === "admin"); + setIsAdmin(currentUser.role === "admin" || currentUser.role === "owner"); } } }, [users]); diff --git a/src/views/RegularUsers.tsx b/src/views/RegularUsers.tsx index ff8a2db5..e920e623 100644 --- a/src/views/RegularUsers.tsx +++ b/src/views/RegularUsers.tsx @@ -262,7 +262,7 @@ export const RegularUsers = () => { if (users) { let currentUser = users.find((user) => user.is_current); if (currentUser) { - setIsAdmin(currentUser.role === "admin"); + setIsAdmin(currentUser.role === "admin" || currentUser.role === "owner"); } } }, [users]); diff --git a/src/views/Users.tsx b/src/views/Users.tsx index b7132c8d..2c5efbd8 100644 --- a/src/views/Users.tsx +++ b/src/views/Users.tsx @@ -52,7 +52,7 @@ export const Users = () => { if(users) { let currentUser = users.find((user) => user.is_current) if(currentUser) { - setIsAdmin(currentUser.role === 'admin'); + setIsAdmin(currentUser.role === 'admin' || currentUser.role === 'owner'); } } }, [users])