feat: wip

This commit is contained in:
David Nguyen
2023-12-27 17:32:56 +11:00
parent ca703fc221
commit 917a1271bf
8 changed files with 170 additions and 112 deletions

View File

@ -84,7 +84,9 @@ export const ConfirmTeamEmailTemplate = ({
</Text>
<ul className="mb-0 mt-2">
<li className="text-sm">View all documents sent to this email address</li>
<li className="text-sm">
View all documents sent to and from this email address
</li>
<li className="mt-1 text-sm">
Allow document recipients to reply directly to this email address
</li>

View File

@ -8,15 +8,12 @@ export const TEAM_MEMBER_ROLE_MAP: Record<keyof typeof TeamMemberRole, string> =
export const TEAM_MEMBER_ROLE_PERMISSIONS_MAP = {
/**
* Includes updating team name, url, logo, emails.
*
* Todo: Teams - Clean this up, merge etc.
* Includes permissions to:
* - Manage team members
* - Manage team settings, changing name, url, etc.
*/
MANAGE_TEAM: [TeamMemberRole.ADMIN, TeamMemberRole.MANAGER],
DELETE_INVITATIONS: [TeamMemberRole.ADMIN, TeamMemberRole.MANAGER],
DELETE_TEAM_MEMBERS: [TeamMemberRole.ADMIN, TeamMemberRole.MANAGER],
DELETE_TEAM_TRANSFER_REQUEST: [TeamMemberRole.ADMIN],
UPDATE_TEAM_MEMBERS: [TeamMemberRole.ADMIN, TeamMemberRole.MANAGER],
} satisfies Record<string, TeamMemberRole[]>;
/**

View File

@ -30,7 +30,7 @@ export const deleteTeamMemberInvitations = async ({
userId,
teamId,
role: {
in: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['DELETE_INVITATIONS'],
in: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_TEAM'],
},
},
});

View File

@ -36,7 +36,7 @@ export const deleteTeamMembers = async ({
some: {
userId,
role: {
in: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['DELETE_TEAM_MEMBERS'],
in: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_TEAM'],
},
},
},

View File

@ -1,5 +1,5 @@
import { prisma } from '@documenso/prisma';
import { TeamMemberRole } from '@documenso/prisma/client';
import type { TeamMemberRole } from '@documenso/prisma/client';
import { TEAM_MEMBER_ROLE_PERMISSIONS_MAP } from '../../constants/teams';
@ -27,7 +27,7 @@ export const updateTeamMember = async ({
some: {
userId,
role: {
in: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['UPDATE_TEAM_MEMBERS'],
in: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_TEAM'],
},
},
},

View File

@ -84,57 +84,64 @@ export function Combobox<T = OptionValue>({
return selectedOptions.map((option) => option.label).join(', ');
}, [selectedOptions, emptySelectionPlaceholder, loading]);
const showClearButton = enableClearAllButton && selectedValues.length > 0;
return (
<Popover open={open && !loading} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
role="combobox"
disabled={loading}
aria-expanded={open}
className="relative w-[200px] px-3"
>
<AnimatePresence>
{loading ? (
<div className="absolute inset-0 flex items-center justify-center">
<Loader className="h-5 w-5 animate-spin text-gray-500 dark:text-gray-100" />
</div>
) : (
<motion.div
className="flex w-full justify-between"
initial={{
opacity: 0,
}}
animate={{
opacity: 1,
}}
exit={{
opacity: 0,
}}
>
<span className="truncate">{buttonLabel}</span>
<div className="ml-2 flex flex-row items-center">
{enableClearAllButton && selectedValues.length > 0 && (
// Todo: Teams - Can't have nested buttons.
<button
className="mr-1 flex h-4 w-4 items-center justify-center rounded-full bg-gray-300"
onClick={(e) => {
e.preventDefault();
onChange([]);
}}
>
<XIcon className="text-muted-foreground h-3.5 w-3.5" />
</button>
)}
<ChevronsUpDown className="h-4 w-4 shrink-0 opacity-50" />
<div className="relative">
<PopoverTrigger asChild>
<Button
variant="outline"
role="combobox"
disabled={loading}
aria-expanded={open}
className="relative w-[200px] px-3"
>
<AnimatePresence>
{loading ? (
<div className="absolute inset-0 flex items-center justify-center">
<Loader className="h-5 w-5 animate-spin text-gray-500 dark:text-gray-100" />
</div>
</motion.div>
)}
</AnimatePresence>
</Button>
</PopoverTrigger>
) : (
<motion.div
className="flex w-full justify-between"
initial={{
opacity: 0,
}}
animate={{
opacity: 1,
}}
exit={{
opacity: 0,
}}
>
<span className="truncate">{buttonLabel}</span>
<div
className={cn('ml-2 flex flex-row items-center', {
'ml-6': showClearButton,
})}
>
<ChevronsUpDown className="h-4 w-4 shrink-0 opacity-50" />
</div>
</motion.div>
)}
</AnimatePresence>
</Button>
</PopoverTrigger>
{/* This is placed outside the trigger since we can't have nested buttons. */}
{showClearButton && (
<div className="absolute bottom-0 right-8 top-0 flex items-center justify-center">
<button
className="flex h-4 w-4 items-center justify-center rounded-full bg-gray-300"
onClick={() => onChange([])}
>
<XIcon className="text-muted-foreground h-3.5 w-3.5" />
</button>
</div>
)}
</div>
<PopoverContent className="w-[200px] p-0">
<Command>