The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/projects pagination part 04 (#39348)
Joshen Lim0f4fc7eee908
diff --git a/apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsx b/apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsxindex 518dbd536ed..a0244db8bb1 100644--- a/apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsx+++ b/apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsx@@ -3,7 +3,7 @@ import { useMemo } from 'react'import { IS_PLATFORM } from 'common'import { useOrganizationsQuery } from 'data/organizations/organizations-query'-import { useProjectsQuery } from 'data/projects/projects-query'+import { useProjectsInfiniteQuery } from 'data/projects/projects-infinite-query'import { PageType, useRegisterCommands, useRegisterPage, useSetPage } from 'ui-patterns/CommandMenu'import { COMMAND_MENU_SECTIONS } from './CommandMenu.utils'@@ -13,11 +13,11 @@ const ORGANIZATION_SWITCHER_PAGE_NAME = 'Configure organization'export function useProjectSwitchCommand() {const setPage = useSetPage()- const { data } = useProjectsQuery({ enabled: IS_PLATFORM })- const projects = useMemo(- () => (data?.projects ?? []).map(({ name, ref }) => ({ name, ref })),- [data]- )+ // [Joshen] Using paginated data here which means we won't be showing all projects+ // Ideally we somehow support searching with Cmd K if we want to make this ideal+ // e.g Cmd K input to support async searching while in "switch project" state+ const { data } = useProjectsInfiniteQuery({}, { enabled: IS_PLATFORM })+ const projects = useMemo(() => data?.pages.flatMap((page) => page.projects), [data?.pages]) || []useRegisterPage(PROJECT_SWITCHER_PAGE_NAME,diff --git a/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx b/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsxindex c580103e103..e8c94cdb15d 100644--- a/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx+++ b/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx@@ -19,7 +19,7 @@ import Panel from 'components/ui/Panel'import { useOrganizationCreateMutation } from 'data/organizations/organization-create-mutation'import { useOrganizationsQuery } from 'data/organizations/organizations-query'import type { CustomerAddress, CustomerTaxId } from 'data/organizations/types'-import { useProjectsQuery } from 'data/projects/projects-query'+import { useProjectsInfiniteQuery } from 'data/projects/projects-infinite-query'import { SetupIntentResponse } from 'data/stripe/setup-intent-mutation'import { useConfirmPendingSubscriptionCreateMutation } from 'data/subscriptions/org-subscription-confirm-pending-create'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'@@ -94,13 +94,15 @@ type FormState = z.infer<typeof formSchema>const stripePromise = loadStripe(STRIPE_PUBLIC_KEY)-const newMandatoryAddressInput = true-/*** No org selected yet, create a new one* [Joshen] Need to refactor to use Form_Shadcn here*/-const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOrgFormProps) => {+export const NewOrgForm = ({+ onPaymentMethodReset,+ setupIntent,+ onPlanSelected,+}: NewOrgFormProps) => {const router = useRouter()const user = useProfile()const { resolvedTheme } = useTheme()@@ -108,7 +110,8 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOrconst isBillingEnabled = useIsFeatureEnabled('billing:all')const { data: organizations, isSuccess } = useOrganizationsQuery()- const { data } = useProjectsQuery()+ const { data } = useProjectsInfiniteQuery({})+ const projects = useMemo(() => data?.pages.flatMap((page) => page.projects) ?? [], [data?.pages])const [lastVisitedOrganization] = useLocalStorageQuery(LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,@@ -117,9 +120,13 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOrconst freeOrgs = (organizations || []).filter((it) => it.plan.id === 'free')+ // [Joshen] JFYI because we're now using a paginated endpoint, there's a chance that not all projects will be+ // factored in here (page limit is 100 results). This data is mainly used for the `hasFreeOrgWithProjects` check+ // in onSubmit below, which isn't a critical functionality imo so am okay for now. But ideally perhaps this data can+ // be computed on the API and returned in /profile or something (since this data is on the account level)const projectsByOrg = useMemo(() => {- return _.groupBy(data?.projects ?? [], 'organization_slug')- }, [data])+ return _.groupBy(projects, 'organization_slug')+ }, [projects])const [isOrgCreationConfirmationModalVisible, setIsOrgCreationConfirmationModalVisible] =useState(false)@@ -657,5 +664,3 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOr</form>)}--export default NewOrgFormdiff --git a/apps/studio/components/interfaces/Organization/index.ts b/apps/studio/components/interfaces/Organization/index.tsindex 6d2f34a57da..ad48fc64483 100644--- a/apps/studio/components/interfaces/Organization/index.ts+++ b/apps/studio/components/interfaces/Organization/index.ts@@ -1,4 +1,3 @@export { default as Documents } from './Documents/Documents'export { default as IntegrationSettings } from './IntegrationSettings/IntegrationSettings'export { default as InvoicesSettings } from './InvoicesSettings/InvoicesSettings'-export { default as NewOrgForm } from './NewOrg/NewOrgForm'diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsxindex 542053c815b..446dc8c7986 100644--- a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx+++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx@@ -7,7 +7,7 @@ import { useState } from 'react'import { useParams } from 'common'import { OrganizationProjectSelector } from 'components/ui/OrganizationProjectSelector'import ShimmeringLoader from 'components/ui/ShimmeringLoader'-import { useProjectsQuery } from 'data/projects/projects-query'+import { useProjectDetailQuery } from 'data/projects/project-detail-query'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'@@ -35,24 +35,21 @@ export const sanitizeRoute = (route: string, routerQueries: ParsedUrlQuery) => {export const ProjectDropdown = () => {const router = useRouter()const { ref } = useParams()- const { data: project } = useSelectedProjectQuery()- const { data, isLoading: isLoadingProjects } = useProjectsQuery()+ const { data: project, isLoading: isLoadingProject } = useSelectedProjectQuery()const { data: selectedOrganization } = useSelectedOrganizationQuery()- const projectCreationEnabled = useIsFeatureEnabled('projects:create')-const isBranch = project?.parentRef !== project?.ref+ const { data: parentProject, isLoading: isLoadingParentProject } = useProjectDetailQuery(+ { ref: project?.parent_project_ref },+ { enabled: isBranch }+ )+ const selectedProject = parentProject ?? project- const projects = (data?.projects ?? [])- .filter((x) => x.organization_id === selectedOrganization?.id)- .sort((a, b) => a.name.localeCompare(b.name))- const selectedProject = isBranch- ? projects?.find((p) => p.ref === project?.parentRef)- : projects?.find((p) => p.ref === ref)+ const projectCreationEnabled = useIsFeatureEnabled('projects:create')const [open, setOpen] = useState(false)- if (isLoadingProjects || !selectedProject) {+ if (isLoadingProject || (isBranch && isLoadingParentProject) || !selectedProject) {return <ShimmeringLoader className="w-[90px]" />}diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsxindex fe558c231fa..1b8f39e782c 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx@@ -20,9 +20,9 @@ import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganizationimport { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import { useHotKey } from 'hooks/ui/useHotKey'import { IS_PLATFORM } from 'lib/constants'+import { useRouter } from 'next/router'import { useAppStateSnapshot } from 'state/app-state'import { Badge, cn } from 'ui'-import { useRouter } from 'next/router'import { BreadcrumbsView } from './BreadcrumbsView'import { FeedbackDropdown } from './FeedbackDropdown'import { HelpPopover } from './HelpPopover'diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsxindex 0dff796b0b7..a1779c5aa5c 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx@@ -9,13 +9,12 @@ import { Markdown } from 'components/interfaces/Markdown'import { ButtonTooltip } from 'components/ui/ButtonTooltip'import type { ItemRenderer } from 'components/ui/InfiniteList'import { Notification, NotificationData } from 'data/notifications/notifications-v2-query'-import { ProjectInfo } from 'data/projects/projects-query'+import { useProjectDetailQuery } from 'data/projects/project-detail-query'import type { Organization } from 'types'import { CriticalIcon, WarningIcon } from 'ui'interface NotificationRowProps {setRowHeight: (idx: number, height: number) => void- getProject: (ref: string) => ProjectInfogetOrganizationById: (id: number) => OrganizationgetOrganizationBySlug: (slug: string) => OrganizationonUpdateNotificationStatus: (id: string, status: 'archived' | 'seen') => void@@ -27,7 +26,6 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({listRef,item: notification,setRowHeight,- getProject,getOrganizationById,getOrganizationBySlug,onUpdateNotificationStatus,@@ -35,10 +33,12 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({}) => {const ref = useRef<HTMLDivElement>(null)const { ref: viewRef, inView } = useInView()- const { status, priority } = notification+ const { status, priority } = notificationconst data = notification.data as NotificationData- const project = data.project_ref !== undefined ? getProject(data.project_ref) : undefined++ const { data: project } = useProjectDetailQuery({ ref: data.project_ref })+const organization =data.org_slug !== undefined? getOrganizationBySlug(data.org_slug)diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsxindex ba8ee16dc26..ffd7e5ba2b3 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx@@ -1,8 +1,9 @@-import { RotateCcw, Settings2Icon } from 'lucide-react'-import { useState } from 'react'+import { RotateCcw, Settings2Icon, X } from 'lucide-react'+import { useMemo, useState } from 'react'import {Button,Checkbox_Shadcn_,+ CommandEmpty_Shadcn_,CommandGroup_Shadcn_,CommandInput_Shadcn_,CommandItem_Shadcn_,@@ -19,18 +20,31 @@ import {} from 'ui'import { CommandGroup } from '@ui/components/shadcn/ui/command'+import { useDebounce } from '@uidotdev/usehooks'import { useOrganizationsQuery } from 'data/organizations/organizations-query'-import { useProjectsQuery } from 'data/projects/projects-query'+import { useProjectsInfiniteQuery } from 'data/projects/projects-infinite-query'import { useNotificationsStateSnapshot } from 'state/notifications'import { CriticalIcon, WarningIcon } from 'ui'+import { Input } from 'ui-patterns/DataInputs/Input'++// [Joshen] Opting to not use infinite loading for projects in this UI specifically+// since the UX feels quite awkward having infinite loading for just a specific section in this Popoverexport const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archived' }) => {const [open, setOpen] = useState(false)const snap = useNotificationsStateSnapshot()+ const [search, setSearch] = useState('')+ const debouncedSearch = useDebounce(search, 500)+const { data: organizations } = useOrganizationsQuery()- const { data } = useProjectsQuery()- const projects = data?.projects ?? []+ const { data } = useProjectsInfiniteQuery(+ { search: search.length === 0 ? search : debouncedSearch },+ { keepPreviousData: true }+ )+ const projects = useMemo(() => data?.pages.flatMap((page) => page.projects), [data?.pages]) || []+ const projectCount = data?.pages[0].pagination.count ?? 0+ const pageLimit = data?.pages[0].pagination.limit ?? 0return (<Popover_Shadcn_ modal={true} open={open} onOpenChange={setOpen}>@@ -47,6 +61,9 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi<PopoverContent_Shadcn_ className="p-0 w-64" side="bottom" align="end"><Command_Shadcn_><CommandInput_Shadcn_ placeholder="Find filter..." />++ <CommandEmpty_Shadcn_>No filters found that match your search</CommandEmpty_Shadcn_>+<CommandList_Shadcn_><ScrollArea className="max-h-[240px] py-1 overflow-y-auto"><CommandGroup_Shadcn_>@@ -67,12 +84,14 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi<Checkbox_Shadcn_name="unread"checked={snap.filterStatuses.includes('unread')}- ></Checkbox_Shadcn_>+ />Unread</Label_Shadcn_></CommandItem_Shadcn_></CommandGroup_Shadcn_>+<CommandSeparator_Shadcn_ />+<CommandGroup_Shadcn_><DropdownMenuLabel>Priority</DropdownMenuLabel><CommandItem_Shadcn_@@ -91,7 +110,7 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi<Checkbox_Shadcn_name="warning"checked={snap.filterPriorities.includes('Warning')}- ></Checkbox_Shadcn_>+ /><WarningIcon className="size-4" />Warning</Label_Shadcn_>@@ -112,13 +131,15 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi<Checkbox_Shadcn_name="critical"checked={snap.filterPriorities.includes('Critical')}- ></Checkbox_Shadcn_>+ /><CriticalIcon className="size-4" />Critical</Label_Shadcn_></CommandItem_Shadcn_></CommandGroup_Shadcn_>+<CommandSeparator_Shadcn_ />+<CommandGroup_Shadcn_><DropdownMenuLabel>Organizations</DropdownMenuLabel>{(organizations ?? []).map((org) => (@@ -140,21 +161,45 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi<Checkbox_Shadcn_name={`${org.slug}`}checked={snap.filterOrganizations.includes(org.slug)}- className=""- ></Checkbox_Shadcn_>+ />{org.name}</Label_Shadcn_></CommandItem_Shadcn_>))}</CommandGroup_Shadcn_>+<CommandSeparator_Shadcn_ />+<CommandGroup_Shadcn_><DropdownMenuLabel>Projects</DropdownMenuLabel>+ {/*+ [Joshen] Adding a separate search input field here for projects as the+ top level CommandInput doesn't work well with a mix of sync and async data+ */}+ <div className="px-2 mb-2">+ <Input+ size="tiny"+ className="rounded"+ placeholder="Search for a project"+ value={search}+ onChange={(e) => setSearch(e.target.value)}+ actions={+ search.length > 0 ? (+ <X+ size={14}+ className="cursor-pointer mr-1"+ onClick={() => setSearch('')}+ />+ ) : null+ }+ />+ </div>{(projects ?? []).map((project) => (<CommandItem_Shadcn_key={project.ref}+ value={project.ref}className="flex items-center gap-x-2"- onSelect={(event) => {+ onSelect={() => {snap.setFilters(project.ref, 'projects')}}>@@ -168,21 +213,27 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi<Checkbox_Shadcn_name={`${project.ref}`}checked={snap.filterProjects.includes(project.ref)}- className=""- ></Checkbox_Shadcn_>+ />{project.name}</Label_Shadcn_></CommandItem_Shadcn_>))}+ {projectCount > pageLimit && (+ <p className="text-foreground-lighter text-xs pt-2 px-2">+ Not all projects are shown here. Try searching to find a specific project.+ </p>+ )}</CommandGroup_Shadcn_></ScrollArea>+<CommandSeparator_Shadcn_ />+<CommandGroup><CommandItem_Shadcn_onSelect={() => snap.resetFilters()}className="flex gap-x-2 items-center">- <RotateCcw className="text-foreground-muted" size={12} strokeWidth={1} />+ <RotateCcw size={12} />Reset filters</CommandItem_Shadcn_></CommandGroup>diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsxindex 1e30b9525a1..bf3b1dd16a3 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx@@ -11,7 +11,6 @@ import { useNotificationsV2Query } from 'data/notifications/notifications-v2-queimport { useNotificationsSummaryQuery } from 'data/notifications/notifications-v2-summary-query'import { useNotificationsV2UpdateMutation } from 'data/notifications/notifications-v2-update-mutation'import { useOrganizationsQuery } from 'data/organizations/organizations-query'-import { useProjectsQuery } from 'data/projects/projects-query'import { useNotificationsStateSnapshot } from 'state/notifications'import {Button,@@ -40,9 +39,6 @@ export const NotificationsPopoverV2 = () => {// so opting to simplify and implement it here for nowconst rowHeights = useRef<{ [key: number]: number }>({})- const { data: projectsData } = useProjectsQuery({ enabled: open })- const projects = projectsData?.projects ?? []-const { data: organizations } = useOrganizationsQuery({ enabled: open })const {data,@@ -210,7 +206,6 @@ export const NotificationsPopoverV2 = () => {rowHeights.current = { ...rowHeights.current, [idx]: height }}},- getProject: (ref: string) => projects?.find((project) => project.ref === ref)!,getOrganizationById: (id: number) =>organizations?.find((org) => org.id === id)!,getOrganizationBySlug: (slug: string) =>diff --git a/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx b/apps/studio/components/layouts/ProjectLayout/LoadingState.tsxindex 36da56931d6..cfd897d7a8e 100644--- a/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx@@ -1,16 +1,12 @@import { useParams } from 'common'import ShimmeringLoader from 'components/ui/ShimmeringLoader'-import { useProjectsQuery } from 'data/projects/projects-query'+import { useProjectDetailQuery } from 'data/projects/project-detail-query'export const LoadingState = () => {const { ref } = useParams()- const { data, isLoading } = useProjectsQuery()- const allProjects = data?.projects ?? []+ const { data: project, isLoading } = useProjectDetailQuery({ ref })- const projectName =- ref !== 'default'- ? allProjects?.find((project) => project.ref === ref)?.name- : 'Welcome to your project'+ const projectName = ref !== 'default' ? project?.name : 'Welcome to your project'return (<div className="w-full mx-auto">diff --git a/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx b/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsxindex e7cc40af960..9bcdaf7e5ab 100644--- a/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx+++ b/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx@@ -1,6 +1,5 @@import { motion } from 'framer-motion'import { BarChart, FileText, Shield } from 'lucide-react'-// End of third-party importsimport { useParams } from 'common'import { LINTER_LEVELS } from 'components/interfaces/Linter/Linter.constants'@@ -59,7 +58,7 @@ export const AIOnboarding = ({<h3 className="heading-meta text-foreground-light mb-3 mx-4">Suggestions</h3>{prompts.map((item, index) => (<motion.div- key={index}+ key={item.title}initial={{ y: 5, opacity: 0 }}animate={{ y: 0, opacity: 1 }}transition={{ duration: 0.3, delay: index * 0.05 }}@@ -86,7 +85,7 @@ export const AIOnboarding = ({{isLintsLoading ? (<div className="px-4 flex flex-col gap-2">{Array.from({ length: 6 }).map((_, index) => (- <Skeleton className="h-4 w-full" />+ <Skeleton key={`loader-${index}`} className="h-4 w-full" />))}</div>) : (@@ -99,6 +98,7 @@ export const AIOnboarding = ({{performanceErrorLints.map((lint, index) => {return (<Button+ key={`${lint.name}-${index}`}size="small"type="text"className="w-full justify-start"@@ -129,6 +129,7 @@ export const AIOnboarding = ({{securityErrorLints.map((lint, index) => {return (<Button+ key={`${lint.name}-${index}`}size="small"type="text"className="w-full justify-start"@@ -149,6 +150,7 @@ export const AIOnboarding = ({<h3 className="heading-meta text-foreground-light mb-3 mx-4">Ideas</h3>{prompts.map((item, index) => (<Button+ key={`${item.title}-${index}`}size="small"type="text"className="w-full justify-start"diff --git a/apps/studio/data/projects/project-detail-query.ts b/apps/studio/data/projects/project-detail-query.tsindex f8ef072e248..c002b77ee34 100644--- a/apps/studio/data/projects/project-detail-query.ts+++ b/apps/studio/data/projects/project-detail-query.ts@@ -20,16 +20,21 @@ export interface Project extends Omit<ProjectDetail, 'status'> {status: components['schemas']['ProjectDetailResponse']['status']}-export async function getProjectDetail({ ref }: ProjectDetailVariables, signal?: AbortSignal) {+export async function getProjectDetail(+ { ref }: ProjectDetailVariables,+ signal?: AbortSignal,+ headers?: Record<string, string>+) {if (!ref) throw new Error('Project ref is required')const { data, error } = await get('/platform/projects/{ref}', {params: { path: { ref } },signal,+ headers,})if (error) handleError(error)- return data as unknown as Project+ return data as Project}export type ProjectDetailData = Awaited<ReturnType<typeof getProjectDetail>>diff --git a/apps/studio/data/projects/projects-infinite-query.ts b/apps/studio/data/projects/projects-infinite-query.tsindex 859cf2adee6..bc3e9bb6f47 100644--- a/apps/studio/data/projects/projects-infinite-query.ts+++ b/apps/studio/data/projects/projects-infinite-query.ts@@ -6,10 +6,7 @@ import { useProfile } from 'lib/profile'import { ResponseError } from 'types'import { projectKeys } from './keys'-// [Joshen] Try to keep this value a multiple of 6 (common denominator of 2 and 3) to fit the cards view-// So that the last row will always be a full row of cards while there's a next page-// API max rows is 100, I'm just choosing 96 here as the highest value thats a multiple of 6-const DEFAULT_LIMIT = 96+const DEFAULT_LIMIT = 100interface GetProjectsInfiniteVariables {limit?: numberdiff --git a/apps/studio/data/projects/projects-query.ts b/apps/studio/data/projects/projects-query.tsindex 17e69df2734..2553f260bf6 100644--- a/apps/studio/data/projects/projects-query.ts+++ b/apps/studio/data/projects/projects-query.ts@@ -1,5 +1,4 @@-import { QueryClient, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'-import { useCallback, useRef } from 'react'+import { QueryClient, useQuery, UseQueryOptions } from '@tanstack/react-query'import type { components } from 'data/api'import { get, handleError } from 'data/fetchers'@@ -51,28 +50,6 @@ export const useProjectsQuery = <TData = ProjectsData>({)}-export function prefetchProjects(client: QueryClient) {- return client.prefetchQuery(projectKeys.list(), ({ signal }) => getProjects({ signal }))-}--export function useProjectsPrefetch() {- const client = useQueryClient()-- return useCallback(() => {- prefetchProjects(client)- }, [client])-}--export function useAutoProjectsPrefetch() {- const prefetch = useProjectsPrefetch()-- const called = useRef<boolean>(false)- if (called.current === false) {- called.current = true- prefetch()- }-}-export function invalidateProjectsQuery(client: QueryClient) {return client.invalidateQueries(projectKeys.list())}diff --git a/apps/studio/lib/ai/org-ai-details.ts b/apps/studio/lib/ai/org-ai-details.tsindex 4c04eaa2fe2..7f9cf99576e 100644--- a/apps/studio/lib/ai/org-ai-details.ts+++ b/apps/studio/lib/ai/org-ai-details.ts@@ -1,5 +1,5 @@import { getOrganizations } from 'data/organizations/organizations-query'-import { getProjects } from 'data/projects/projects-query'+import { getProjectDetail } from 'data/projects/project-detail-query'import { getAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'export const getOrgAIDetails = async ({@@ -11,28 +11,20 @@ export const getOrgAIDetails = async ({authorization: stringprojectRef: string}) => {- const [organizations, projects] = await Promise.all([- getOrganizations({- headers: {- 'Content-Type': 'application/json',- ...(authorization && { Authorization: authorization }),- },- }),- getProjects({- headers: {- 'Content-Type': 'application/json',- ...(authorization && { Authorization: authorization }),- },- }),+ const headers = {+ 'Content-Type': 'application/json',+ ...(authorization && { Authorization: authorization }),+ }++ const [organizations, selectedProject] = await Promise.all([+ getOrganizations({ headers }),+ getProjectDetail({ ref: projectRef }, undefined, headers),])const selectedOrg = organizations.find((org) => org.slug === orgSlug)- const selectedProject = projects.projects.find(- (project) => project.ref === projectRef || project.preview_branch_refs.includes(projectRef)- )// If the project is not in the organization specific by the org slug, return an error- if (selectedProject?.organization_slug !== selectedOrg?.slug) {+ if (selectedProject?.organization_id !== selectedOrg?.id) {throw new Error('Project and organization do not match')}diff --git a/apps/studio/pages/new/index.tsx b/apps/studio/pages/new/index.tsxindex b8c9cf76533..467c1410f62 100644--- a/apps/studio/pages/new/index.tsx+++ b/apps/studio/pages/new/index.tsx@@ -1,7 +1,7 @@import HCaptcha from '@hcaptcha/react-hcaptcha'import { useCallback, useEffect, useState } from 'react'-import { NewOrgForm } from 'components/interfaces/Organization'+import { NewOrgForm } from 'components/interfaces/Organization/NewOrg/NewOrgForm'import AppLayout from 'components/layouts/AppLayout/AppLayout'import DefaultLayout from 'components/layouts/DefaultLayout'import WizardLayout from 'components/layouts/WizardLayout'diff --git a/apps/studio/pages/org/[slug]/index.tsx b/apps/studio/pages/org/[slug]/index.tsxindex 77159c82864..71d5cc8872a 100644--- a/apps/studio/pages/org/[slug]/index.tsx+++ b/apps/studio/pages/org/[slug]/index.tsx@@ -6,17 +6,15 @@ import OrganizationLayout from 'components/layouts/OrganizationLayout'import { PageLayout } from 'components/layouts/PageLayout/PageLayout'import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'import { InlineLink } from 'components/ui/InlineLink'-import { useAutoProjectsPrefetch } from 'data/projects/projects-query'import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'import type { NextPageWithLayout } from 'types'import { Admonition } from 'ui-patterns'const ProjectsPage: NextPageWithLayout = () => {- const { data: org } = useSelectedOrganizationQuery()const isUserMFAEnabled = useIsMFAEnabled()- const disableAccessMfa = org?.organization_requires_mfa && !isUserMFAEnabled+ const { data: org } = useSelectedOrganizationQuery()- useAutoProjectsPrefetch()+ const disableAccessMfa = org?.organization_requires_mfa && !isUserMFAEnabledreturn (<ScaffoldContainer className="flex-grow flex">