diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx index 466f03154d1..8677f97aed3 100644 --- a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx +++ b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx @@ -1,6 +1,7 @@ import { zodResolver } from '@hookform/resolvers/zod' import { PermissionAction } from '@supabase/shared-types/out/constants' import { isNil } from 'lodash' +import { Check, ChevronsUpDown } from 'lucide-react' import Link from 'next/link' import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' @@ -21,10 +22,14 @@ import { useGetPermissions, } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization' -import { useIsOptedIntoProjectLevelPermissions } from 'hooks/ui/useFlag' import { useProfile } from 'lib/profile' import { Button, + CommandEmpty_Shadcn_, + CommandGroup_Shadcn_, + CommandInput_Shadcn_, + CommandItem_Shadcn_, + Command_Shadcn_, Dialog, DialogContent, DialogHeader, @@ -33,13 +38,13 @@ import { DialogTitle, DialogTrigger, FormControl_Shadcn_, - FormDescription_Shadcn_, FormField_Shadcn_, - FormItem_Shadcn_, - FormLabel_Shadcn_, - FormMessage_Shadcn_, Form_Shadcn_, Input_Shadcn_, + PopoverContent_Shadcn_, + PopoverTrigger_Shadcn_, + Popover_Shadcn_, + ScrollArea, SelectContent_Shadcn_, SelectGroup_Shadcn_, SelectItem_Shadcn_, @@ -49,17 +54,20 @@ import { TooltipContent_Shadcn_, TooltipTrigger_Shadcn_, Tooltip_Shadcn_, + cn, } from 'ui' +import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import { useGetRolesManagementPermissions } from './TeamSettings.utils' +import { useIsOptedIntoProjectLevelPermissions } from 'hooks/ui/useFlag' export const InviteMemberButton = () => { const { slug } = useParams() const { profile } = useProfile() const organization = useSelectedOrganization() const { permissions: permissions } = useGetPermissions() - const isOptedIntoProjectLevelPermissions = useIsOptedIntoProjectLevelPermissions(slug as string) const [isOpen, setIsOpen] = useState(false) + const [projectDropdownOpen, setProjectDropdownOpen] = useState(false) const { data: projects } = useProjectsQuery() const { data: members } = useOrganizationMembersQuery({ slug }) @@ -79,6 +87,8 @@ export const InviteMemberButton = () => { { enabled: canReadSubscriptions } ) const currentPlan = subscription?.plan + const isOptedIntoProjectLevelPermissions = + useIsOptedIntoProjectLevelPermissions(slug as string) && currentPlan?.id === 'enterprise' const userMemberData = members?.find((m) => m.gotrue_id === profile?.gotrue_id) const hasOrgRole = @@ -237,22 +247,22 @@ export const InviteMemberButton = () => { onSubmit={form.handleSubmit(onInviteMember)} > - {isOptedIntoProjectLevelPermissions && currentPlan?.id === 'enterprise' && ( + {isOptedIntoProjectLevelPermissions && ( ( - + form.setValue('applyToOrg', value)} /> - - Apply role to all projects in the organization - - + )} /> )} @@ -260,14 +270,13 @@ export const InviteMemberButton = () => { name="role" control={form.control} render={({ field }) => ( - - Member role + form.setValue('role', value)} > - + {orgScopedRoles.find((role) => role.id === Number(field.value))?.name ?? 'Unknown'} @@ -294,7 +303,7 @@ export const InviteMemberButton = () => { - + )} /> {!applyToOrg && ( @@ -302,38 +311,67 @@ export const InviteMemberButton = () => { name="projectRef" control={form.control} render={({ field }) => ( - - Select a project + - form.setValue('projectRef', value)} + - - {orgProjects.find((project) => project.ref === field.value)?.name ?? - 'Unknown'} - - - - {orgProjects.map((project) => { - return ( - - {project.name} - - ) - })} - - - + + + + + + + No projects found + + 7 ? 'h-[210px]' : ''} + > + {orgProjects.map((project) => { + return ( + { + form.setValue('projectRef', project.ref) + setProjectDropdownOpen(false) + }} + > + + {project.name} + + ) + })} + + + + + - - You can assign roles to multiple projects once the invite is accepted - - + )} /> )} @@ -341,8 +379,7 @@ export const InviteMemberButton = () => { name="email" control={form.control} render={({ field }) => ( - - Email address + { placeholder="Enter email address" /> - - + )} /> {org.name} - {org.slug === slug && } + {org.slug === slug && } ) @@ -106,7 +104,7 @@ const OrganizationDropdown = ({ isNewNav = false }: OrganizationDropdownProps) = onClick={() => setOpen(false)} > - +

New organization

diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx index dbd2a05352f..5e477b21b4a 100644 --- a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx +++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx @@ -1,3 +1,4 @@ +import { Check, ChevronsUpDown, Plus } from 'lucide-react' import Link from 'next/link' import { useRouter } from 'next/router' import { ParsedUrlQuery } from 'querystring' @@ -10,7 +11,6 @@ import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization' import { useSelectedProject } from 'hooks/misc/useSelectedProject' import { IS_PLATFORM } from 'lib/constants' -import { Code } from 'lucide-react' import type { Organization } from 'types' import { Button, @@ -21,14 +21,11 @@ import { CommandList_Shadcn_, CommandSeparator_Shadcn_, Command_Shadcn_, - IconCheck, - IconPlus, PopoverContent_Shadcn_, PopoverTrigger_Shadcn_, Popover_Shadcn_, ScrollArea, } from 'ui' -import { ChevronsUpDown } from 'lucide-react' // [Fran] the idea is to let users change projects without losing the current page, // but at the same time we need to redirect correctly between urls that might be @@ -83,7 +80,7 @@ const ProjectLink = ({ > {project.name} - {project.ref === ref && } + {project.ref === ref && } ) @@ -160,7 +157,7 @@ const ProjectDropdown = ({ isNewNav = false }: ProjectDropdownProps) => { }} className="w-full flex items-center gap-2" > - +

New project

diff --git a/packages/ui-patterns/form/Layout/FormLayout.tsx b/packages/ui-patterns/form/Layout/FormLayout.tsx index 713ab2a026e..3d8161b75da 100644 --- a/packages/ui-patterns/form/Layout/FormLayout.tsx +++ b/packages/ui-patterns/form/Layout/FormLayout.tsx @@ -290,14 +290,14 @@ export const FormLayout = React.forwardRef< > {description} - ) : ( + ) : description ? (

{description}

- ) + ) : null const LabelContents = () => ( <>