Skip to content

Commit

Permalink
Add owner role support
Browse files Browse the repository at this point in the history
Update checks for admin to include owner role

Updated role list to include role for users

Updated activity with new event type handler
  • Loading branch information
mlsmaycon committed Nov 29, 2023
1 parent f4d6ce5 commit 0057280
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/components/UserEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -411,6 +411,9 @@ const UserEdit = (props: any) => {
<Option value="user">
<Text type={"secondary"}>user</Text>
</Option>
<Option value="owner">
<Text type={"secondary"}>owner</Text>
</Option>
</Select>
</Form.Item>
</Col>
Expand Down
14 changes: 14 additions & 0 deletions src/views/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/views/Peers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/views/RegularUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/views/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 0057280

Please sign in to comment.