Extended the account ownership transfer tests and implemented several updates. This includes transferring the ownership only to an existing account member, sorting team members based on role hierarchy and whether a member is the primary owner. In the permissions check, prevented non-members from creating invitations and enhanced the styling of role badges depending on if they are custom or not.
35 lines
876 B
TypeScript
35 lines
876 B
TypeScript
import { cva } from 'class-variance-authority';
|
|
|
|
import { Badge } from '@kit/ui/badge';
|
|
import { Trans } from '@kit/ui/trans';
|
|
|
|
type Role = string;
|
|
|
|
const roles = {
|
|
owner: '',
|
|
member:
|
|
'bg-blue-50 hover:bg-blue-50 text-blue-500 dark:bg-blue-500/10 dark:hover:bg-blue-500/10',
|
|
};
|
|
|
|
const roleClassNameBuilder = cva('font-medium capitalize shadow-none', {
|
|
variants: {
|
|
role: roles,
|
|
},
|
|
});
|
|
|
|
export const RoleBadge: React.FC<{
|
|
role: Role;
|
|
}> = ({ role }) => {
|
|
// @ts-expect-error: hard to type this since users can add custom roles
|
|
const className = roleClassNameBuilder({ role });
|
|
const isCustom = !(role in roles);
|
|
|
|
return (
|
|
<Badge className={className} variant={isCustom ? 'outline' : 'default'}>
|
|
<span data-test={'member-role-badge'}>
|
|
<Trans i18nKey={`common:roles.${role}.label`} defaults={role} />
|
|
</span>
|
|
</Badge>
|
|
);
|
|
};
|