mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Part 5 of a 6-PR stack migrating all `next/link` imports in `apps/studio` onto TanStack Router's `Link` (or plain `<a>` for known external URLs) and removing `compat/next/link.tsx`. | Part | PR | Scope | | --- | --- | --- | | 1 | #54304 | `data/prefetchers/PrefetchableLink.tsx` and `components/ui/**` | | 2 | #54305 | `components/layouts/**` and top-level shell components | | 3 | #54306 | Database, TableGridEditor, Storage, SQLEditor, BranchManagement, Branching, Functions, Realtime | | 4 | #54307 | Integrations, Settings, Observability, LogDrains, Issues, Linter, Reports, QueryPerformance, QuerySources, ConfigDrift, DiskManagement, Compute | | **5** | **#54308 ← this PR** | **Remaining `components/interfaces/**` (Org, Billing, Auth, Support, Home, SignIn, ConnectSheet, etc.)** | | 6 | #54309 | Remove `compat/next/link.tsx` shim, Vite alias, and update basePath tests/docs | Migrates the remaining `components/interfaces/**` directories off `next/link`, leaving zero `next/link` component imports in `apps/studio`. **Changed:** - Replaced `next/link` across all 73 remaining interface files (`Organization`, `OrganizationInvite`, `Billing`, `Auth`, `Support`, `ProjectHome`, `Home`, `Project`, `ProjectCreation`, `ProjectAPIDocs`, `ApiAuthorization`, `App`, `ConnectSheet`, `SignIn`, `APIKeys`, `Account`, `CliLogin`, `Docs`, `JwtSecrets`, `Platform`) - Converted the sole remaining `UrlObject` link (`<Link href={{ pathname: '/sign-in-sso', query }}>`) in `SignInSSOForm.tsx` to `<Link to="/sign-in-sso" search={query}>` - Migrated `SupportLink.tsx` onto `DynamicLink` (`createSupportFormUrl(...)`) - Standardized external `target="_blank"` anchors with `rel="noreferrer noopener"`, switched `OverviewMetrics.tsx` observability link to typed `<Link to="/project/$ref/observability/auth">`, and adopted `InlineLink` / `InlineLinkClassName` on inline paragraph links per review feedback Addresses [FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link) ## To test - [ ] Check Organization (billing, usage, team, documents, AWS Marketplace), Auth (providers, templates, rate limits, users, OAuth apps), Support form/links, Project Home, Connect sheet, and Sign-In/SSO links - [ ] Verify `SignInWithSSOButton` preserves query params when navigating to `/sign-in-sso` - [ ] Verify `SupportLink` pre-populates support form query parameters cleanly --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
111 lines
4.3 KiB
TypeScript
111 lines
4.3 KiB
TypeScript
import { MessageSquareIcon } from 'lucide-react'
|
|
import { AnimatePresence, motion } from 'motion/react'
|
|
import { useCallback, useEffect, useState } from 'react'
|
|
import { AiIconAnimation, Button } from 'ui'
|
|
|
|
import { NO_ORG_MARKER, NO_PROJECT_MARKER } from './SupportForm.utils'
|
|
import { DynamicLink } from '@/components/ui/DynamicLink'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
interface AIAssistantOptionProps {
|
|
projectRef?: string | null
|
|
organizationSlug?: string | null
|
|
onClick?: () => void
|
|
}
|
|
|
|
export const AIAssistantOption = ({
|
|
projectRef,
|
|
organizationSlug,
|
|
onClick,
|
|
}: AIAssistantOptionProps) => {
|
|
const track = useTrack()
|
|
const [isVisible, setIsVisible] = useState(false)
|
|
|
|
useEffect(() => {
|
|
const timer = setTimeout(() => setIsVisible(true), 800)
|
|
return () => clearTimeout(timer)
|
|
}, [])
|
|
|
|
const onAiAssistantClicked = useCallback(() => {
|
|
track('ai_assistant_in_support_form_clicked', undefined, {
|
|
project: projectRef === null || projectRef === NO_PROJECT_MARKER ? undefined : projectRef,
|
|
organization:
|
|
organizationSlug === null || organizationSlug === NO_ORG_MARKER
|
|
? undefined
|
|
: organizationSlug,
|
|
})
|
|
|
|
onClick?.()
|
|
}, [onClick, projectRef, organizationSlug, track])
|
|
|
|
// If no specific project selected, use the wildcard route
|
|
const aiLink = `/project/${projectRef !== NO_PROJECT_MARKER ? projectRef : '_'}?sidebar=ai-assistant&slug=${organizationSlug}`
|
|
|
|
if (!organizationSlug || organizationSlug === NO_ORG_MARKER) return null
|
|
|
|
return (
|
|
<AnimatePresence>
|
|
{isVisible && (
|
|
<motion.aside
|
|
initial={{ height: 0, opacity: 0 }}
|
|
animate={{ height: 'auto', opacity: 1 }}
|
|
exit={{ height: 0, opacity: 0 }}
|
|
className="w-full overflow-hidden border rounded-md relative bg-200"
|
|
>
|
|
<div className="flex items-center p-6">
|
|
<div className="flex flex-col gap-3 z-2 shrink-0 w-full">
|
|
<div>
|
|
<h5 className="text-sm font-medium text-foreground">Try Supabase Assistant</h5>
|
|
<p className="text-sm text-foreground-lighter">
|
|
Ask our AI assistant to help you with your support issue.
|
|
</p>
|
|
</div>
|
|
<div>
|
|
{onClick ? (
|
|
<Button
|
|
size="tiny"
|
|
icon={<AiIconAnimation size={14} />}
|
|
onClick={onAiAssistantClicked}
|
|
>
|
|
Ask the Assistant
|
|
</Button>
|
|
) : (
|
|
<DynamicLink href={aiLink} onClick={onAiAssistantClicked}>
|
|
<Button size="tiny" icon={<AiIconAnimation size={14} />}>
|
|
Ask the Assistant
|
|
</Button>
|
|
</DynamicLink>
|
|
)}
|
|
</div>
|
|
</div>
|
|
{/* Decorative background */}
|
|
<div className="absolute z-1 scale-75 -right-40 md:-right-24 -top-6 md:top-0">
|
|
<div className="relative grow flex flex-col gap-3 w-[400px]">
|
|
<div className="flex items-start gap-3 pl-12">
|
|
<div className="w-8 h-8 rounded-full bg-background-surface-300 flex items-center justify-center">
|
|
<MessageSquareIcon size={16} className="text-foreground-lighter" />
|
|
</div>
|
|
<div className="flex-1 bg-background-surface-200 rounded-lg p-4 max-w-[280px]">
|
|
<p className="text-sm text-foreground-lighter">
|
|
Hi! I'm your AI assistant. How can I help you today?
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-start justify-end gap-3 pr-10">
|
|
<div className="bg-background-surface-200 rounded-lg p-4 max-w-[280px]">
|
|
<p className="text-sm text-foreground-lighter">
|
|
I can help you with database queries, API endpoints, or any other technical
|
|
questions you might have.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="absolute -inset-2 bg-linear-to-l from-transparent via-background-200 via-90% to-background-200 to-100% z-1" />
|
|
</div>
|
|
</div>
|
|
</motion.aside>
|
|
)}
|
|
</AnimatePresence>
|
|
)
|
|
}
|