mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-06 01:15:42 +01:00
Allow team managers to transfer websites to teams
This commit is contained in:
parent
b006747a45
commit
0988808b75
@ -71,7 +71,7 @@ export function WebsiteTransferForm({
|
||||
{result.data
|
||||
.filter(({ teamUser }) =>
|
||||
teamUser.find(
|
||||
({ role, userId }) => role === ROLES.teamOwner && userId === user.id,
|
||||
({ role, userId }) => [ ROLES.teamOwner, ROLES.teamManager ].includes(role) && userId === user.id,
|
||||
),
|
||||
)
|
||||
.map(({ id, name }) => {
|
||||
|
@ -106,7 +106,7 @@ export async function canTransferWebsiteToUser({ user }: Auth, websiteId: string
|
||||
if (website.teamId && user.id === userId) {
|
||||
const teamUser = await getTeamUser(website.teamId, userId);
|
||||
|
||||
return teamUser?.role === ROLES.teamOwner;
|
||||
return teamUser && hasPermission(teamUser.role, PERMISSIONS.websiteTransferToUser);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -118,7 +118,7 @@ export async function canTransferWebsiteToTeam({ user }: Auth, websiteId: string
|
||||
if (website.userId && website.userId === user.id) {
|
||||
const teamUser = await getTeamUser(teamId, user.id);
|
||||
|
||||
return teamUser?.role === ROLES.teamOwner;
|
||||
return teamUser && hasPermission(teamUser.role, PERMISSIONS.websiteTransferToTeam);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -160,6 +160,8 @@ export const PERMISSIONS = {
|
||||
websiteCreate: 'website:create',
|
||||
websiteUpdate: 'website:update',
|
||||
websiteDelete: 'website:delete',
|
||||
websiteTransferToTeam: 'website:transfer-to-team',
|
||||
websiteTransferToUser: 'website:transfer-to-user',
|
||||
teamCreate: 'team:create',
|
||||
teamUpdate: 'team:update',
|
||||
teamDelete: 'team:delete',
|
||||
@ -180,12 +182,15 @@ export const ROLE_PERMISSIONS = {
|
||||
PERMISSIONS.websiteCreate,
|
||||
PERMISSIONS.websiteUpdate,
|
||||
PERMISSIONS.websiteDelete,
|
||||
PERMISSIONS.websiteTransferToTeam,
|
||||
PERMISSIONS.websiteTransferToUser,
|
||||
],
|
||||
[ROLES.teamManager]: [
|
||||
PERMISSIONS.teamUpdate,
|
||||
PERMISSIONS.websiteCreate,
|
||||
PERMISSIONS.websiteUpdate,
|
||||
PERMISSIONS.websiteDelete,
|
||||
PERMISSIONS.websiteTransferToTeam,
|
||||
],
|
||||
[ROLES.teamMember]: [
|
||||
PERMISSIONS.websiteCreate,
|
||||
|
Loading…
Reference in New Issue
Block a user