mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 02:09:50 -04:00
56de26fe22
This PR migrates the whole monorepo to use Tailwind v4: - Removed `@tailwindcss/container-queries` plugin since it's included by default in v4, - Bump all instances of Tailwind to v4. Made minimal changes to the shared config to remove non-supported features (`alpha` mentions), - Migrate all apps to be compatible with v4 configs, - Fix the `typography.css` import in 3 apps, - Add missing rules which were included by default in v3, - Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot of classes - Rename all misnamed classes according to https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all apps. --------- Co-authored-by: Jordi Enric <jordi.err@gmail.com>
138 lines
5.2 KiB
TypeScript
138 lines
5.2 KiB
TypeScript
import { Search } from 'lucide-react'
|
|
import { parseAsString, useQueryState } from 'nuqs'
|
|
import { buttonVariants, cn, Tabs_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
|
|
import { Admonition } from 'ui-patterns/admonition'
|
|
import { Input } from 'ui-patterns/DataInputs/Input'
|
|
|
|
import { IntegrationCard, IntegrationLoadingCard } from './IntegrationCard'
|
|
import { useAvailableIntegrations } from './useAvailableIntegrations'
|
|
import { useInstalledIntegrations } from './useInstalledIntegrations'
|
|
import AlertError from '@/components/ui/AlertError'
|
|
import { NoSearchResults } from '@/components/ui/NoSearchResults'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
|
|
type IntegrationCategory = 'all' | 'wrapper' | 'postgres_extensions' | 'custom'
|
|
const CATEGORIES = [
|
|
{ key: 'all', label: 'All Integrations' },
|
|
{ key: 'wrapper', label: 'Wrappers' },
|
|
{ key: 'postgres_extension', label: 'Postgres Modules' },
|
|
] as const
|
|
|
|
export const AvailableIntegrations = () => {
|
|
const { integrationsWrappers } = useIsFeatureEnabled(['integrations:wrappers'])
|
|
|
|
const [selectedCategory, setSelectedCategory] = useQueryState(
|
|
'category',
|
|
parseAsString.withDefault('all').withOptions({ clearOnDefault: true })
|
|
)
|
|
const [search, setSearch] = useQueryState(
|
|
'search',
|
|
parseAsString.withDefault('').withOptions({ clearOnDefault: true })
|
|
)
|
|
|
|
const { data: allIntegrations = [] } = useAvailableIntegrations()
|
|
const { installedIntegrations, error, isError, isLoading, isSuccess } = useInstalledIntegrations()
|
|
|
|
const installedIds = installedIntegrations.map((i) => i.id)
|
|
|
|
// available integrations for install
|
|
const availableIntegrations = integrationsWrappers
|
|
? allIntegrations
|
|
: allIntegrations.filter((x) => !x.id.endsWith('_wrapper'))
|
|
const integrationsByCategory =
|
|
selectedCategory === 'all'
|
|
? availableIntegrations
|
|
: availableIntegrations.filter((i) => i.type === selectedCategory)
|
|
|
|
const filteredIntegrations = (
|
|
search.length > 0
|
|
? integrationsByCategory.filter((i) => i.name.toLowerCase().includes(search.toLowerCase()))
|
|
: integrationsByCategory
|
|
).sort((a, b) => a.name.localeCompare(b.name))
|
|
|
|
return (
|
|
<>
|
|
<Tabs_Shadcn_
|
|
className="mt-4"
|
|
value={selectedCategory}
|
|
onValueChange={(value) => setSelectedCategory(value as IntegrationCategory)}
|
|
>
|
|
<TabsList_Shadcn_ className="px-4 md:px-10 gap-2 border-b-0 border-t pt-5">
|
|
{CATEGORIES.map((category) => (
|
|
<TabsTrigger_Shadcn_
|
|
key={category.key}
|
|
value={category.key}
|
|
onClick={() => setSelectedCategory(category.key as IntegrationCategory)}
|
|
className={cn(
|
|
buttonVariants({
|
|
size: 'tiny',
|
|
type: selectedCategory === category.key ? 'default' : 'outline',
|
|
}),
|
|
selectedCategory === category.key ? 'text-foreground' : 'text-foreground-lighter',
|
|
'rounded-full! px-3'
|
|
)}
|
|
>
|
|
{category.label}
|
|
</TabsTrigger_Shadcn_>
|
|
))}
|
|
<Input
|
|
value={search}
|
|
onChange={(e) => {
|
|
setSearch(e.target.value)
|
|
setSelectedCategory('all')
|
|
}}
|
|
containerClassName="group w-40 ml-5"
|
|
icon={
|
|
<Search
|
|
size={14}
|
|
className="transition text-foreground-lighter group-hover:text-foreground"
|
|
/>
|
|
}
|
|
iconContainerClassName="p-0"
|
|
className="pl-7 rounded-none border-0! border-transparent bg-transparent shadow-none! ring-0! ring-offset-0!"
|
|
placeholder="Search..."
|
|
/>
|
|
</TabsList_Shadcn_>
|
|
</Tabs_Shadcn_>
|
|
<div className="p-4 md:p-10 md:py-8 flex flex-col gap-y-5">
|
|
<div className="grid xl:grid-cols-3 2xl:grid-cols-4 gap-x-4 gap-y-3">
|
|
{isLoading &&
|
|
new Array(3)
|
|
.fill(0)
|
|
.map((_, idx) => <IntegrationLoadingCard key={`integration-loading-${idx}`} />)}
|
|
{isError && (
|
|
<AlertError
|
|
className="xl:col-span-3 2xl:col-span-4"
|
|
subject="Failed to retrieve available integrations"
|
|
error={error}
|
|
/>
|
|
)}
|
|
{isSuccess &&
|
|
filteredIntegrations.map((i) => (
|
|
<IntegrationCard key={i.id} {...i} isInstalled={installedIds.includes(i.id)} />
|
|
))}
|
|
{isSuccess && search.length > 0 && filteredIntegrations.length === 0 && (
|
|
<NoSearchResults
|
|
className="xl:col-span-3 2xl:col-span-4"
|
|
searchString={search}
|
|
onResetFilter={() => setSearch('')}
|
|
/>
|
|
)}
|
|
{isSuccess &&
|
|
selectedCategory !== 'all' &&
|
|
search.length === 0 &&
|
|
filteredIntegrations.length === 0 && (
|
|
<Admonition
|
|
showIcon={false}
|
|
className="xl:col-span-3 2xl:col-span-4"
|
|
type="default"
|
|
title="All integrations in this category are currently in use"
|
|
description="Manage your installed integrations in the section above"
|
|
/>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|