Files
supabase/apps/studio/components/layouts/ProjectIntegrationsLayout.tsx
T
Raminder SinghandSaxon Fletcher 5a41d0155e chore: integration UI refinement (#45507)
This PR:

* Refactors integrations page implementation to make it simpler and
easier to understand.
* Integration category pages from marketplace db show category name and
description.
* Shows featured integrations coming from the marketplace db at the top
of the page.
* Hides empty categories:
https://linear.app/supabase/issue/INT-113/hide-empty-categories-on-dashboard-integrations-page

Below design related fixes will be done in a separate PR:
https://github.com/supabase/supabase/pull/45856. So this PR is ready to
merge with current fixes.

<details>

~~Design fixes needed after consulting with the design team:~~

- [ ] ~~Do not use inverted colors on images for featured integrations.
This leads to inconsistent images for the featured marketplace listings.
E.g. Grafana listing shown in the featured listings:~~
<img width="463" height="260" alt="image"
src="https://github.com/user-attachments/assets/76816807-667f-44b0-b68c-5e1ca342be1f"
/>

~~vs shown on it's own page:~~

<img width="909" height="667" alt="image"
src="https://github.com/user-attachments/assets/00efda48-3e4e-4b05-87ad-cbbce9047c94"
/>

- [ ] ~~The images on featured marketplace integrations should not be
truncated as seen in the first image above.~~
- [ ] ~~The **Install integration** button feels floating far out on the
right.~~
- [ ] ~~The description under the title is too long and truncated.
Requested by Doppler here:
https://supabase.slack.com/archives/C0AL11JG5MG/p1778009104728819?thread_ts=1777654129.027269&cid=C0AL11JG5MG~~
- [ ] ~~The content section doesn't render bulleted lists correctly.~~
</details>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
  * Dedicated "Featured Integrations" section on the integrations page.
* Integrations can be marked as featured to appear in the featured
section.

* **Improvements**
  * Sidebar shows only categories that contain integrations.
  * Integration image handling improved for featured cards.
* Updated loading placeholders for integrations to provide a smoother
loading experience.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45507)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
2026-05-14 02:36:28 +05:30

179 lines
5.5 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { IS_PLATFORM, useFeatureFlags, useFlag, useParams } from 'common'
import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { Menu, Separator } from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns'
import { useInstalledIntegrations } from '@/components/interfaces/Integrations/Landing/useInstalledIntegrations'
import { ProjectLayout } from '@/components/layouts/ProjectLayout'
import AlertError from '@/components/ui/AlertError'
import { ProductMenu } from '@/components/ui/ProductMenu'
import { marketplaceCategoriesQueryOptions } from '@/data/marketplace/integration-categories-query'
import { marketplaceIntegrationsQueryOptions } from '@/data/marketplace/integrations-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { withAuth } from '@/hooks/misc/withAuth'
/**
* Layout component for the Integrations section
* Provides sidebar navigation for integrations
*/
export const ProjectIntegrationsLayout = withAuth(({ children }: PropsWithChildren) => {
const router = useRouter()
const segments = router.asPath.split('/')
// construct the page url to be used to determine the active state for the sidebar
const page = `${segments[3]}${segments[4] ? `/${segments[4]}` : ''}`
return (
<ProjectLayout
product="Integrations"
browserTitle={{ section: 'Integrations' }}
isBlocking={false}
productMenu={
<>
<IntegrationCategoriesMenu page={page} />
<Separator />
<InstalledIntegrationsMenu page={page} />
</>
}
>
{children}
</ProjectLayout>
)
})
const IntegrationCategoriesMenu = ({ page }: { page: string }) => {
const router = useRouter()
const { ref } = useParams()
const { hasLoaded: flagsLoaded } = useFeatureFlags()
const isMarketplaceEnabled = useFlag('marketplaceIntegrations')
const urlParams = new URLSearchParams(router.asPath.split('?')[1] || '')
const categoryParam = urlParams.get('category')
const pageKey = categoryParam || page
const { integrationsWrappers: showWrappers } = useIsFeatureEnabled(['integrations:wrappers'])
const { data: categories = [], isPending: isPendingCategories } = useQuery(
marketplaceCategoriesQueryOptions({ enabled: isMarketplaceEnabled })
)
const { data: listings = [], isPending: isPendingListings } = useQuery(
marketplaceIntegrationsQueryOptions({ enabled: isMarketplaceEnabled })
)
const populatedCategoryIds = new Set(
listings.flatMap((listing) =>
Array.isArray(listing.categories)
? (listing.categories as Array<{ id: string }>).map((c) => c.id)
: []
)
)
const nonEmptyCategories = categories.filter(
(category) => category.id && populatedCategoryIds.has(category.id)
)
const isLoading = IS_PLATFORM
? !flagsLoaded || (isMarketplaceEnabled && (isPendingCategories || isPendingListings))
: false
const allCategories = [
{
name: 'All',
key: 'integrations',
url: `/project/${ref}/integrations`,
pages: ['integrations'],
items: [],
},
...(showWrappers
? [
{
name: 'Wrappers',
key: 'wrapper',
url: `/project/${ref}/integrations?category=wrapper`,
items: [],
},
]
: []),
{
name: 'Postgres Modules',
key: 'postgres_extension',
url: `/project/${ref}/integrations?category=postgres_extension`,
items: [],
},
...nonEmptyCategories.map((category) => ({
name: category.name ?? '',
key: category.slug ?? '',
url: `/project/${ref}/integrations?category=${category.slug}`,
items: [],
})),
]
return (
<>
{isLoading ? (
<div className="px-4 py-6 md:px-6">
<Menu type="pills">
<Menu.Group title={<span className="uppercase font-mono">Explore</span>} />
</Menu>
<GenericSkeletonLoader />
</div>
) : (
<ProductMenu
page={pageKey}
menu={[{ key: 'explore', title: 'Explore', items: allCategories }]}
/>
)}
</>
)
}
const InstalledIntegrationsMenu = ({ page }: { page: string }) => {
const { ref } = useParams()
const {
installedIntegrations: integrations,
error,
isLoading,
isSuccess,
isError,
} = useInstalledIntegrations()
const installedIntegrationItems = integrations.map((integration) => ({
name: integration.name,
label: integration.status,
key: `integrations/${integration.id}`,
url: `/project/${ref}/integrations/${integration.id}/overview`,
icon: (
<div className="relative w-6 h-6 bg-white border rounded-sm flex items-center justify-center">
{integration.icon({ className: 'p-1' })}
</div>
),
items: [],
}))
return (
<>
{(isLoading || isError) && (
<div className="px-4 py-6 md:px-6">
<Menu type="pills">
<Menu.Group title={<span className="uppercase font-mono">Installed</span>} />
</Menu>
{isLoading && <GenericSkeletonLoader />}
{isError && (
<AlertError
showIcon={false}
error={error}
subject="Failed to retrieve installed integrations"
/>
)}
</div>
)}
{isSuccess && (
<ProductMenu
page={page}
menu={[{ key: 'installed', title: 'Installed', items: installedIntegrationItems }]}
/>
)}
</>
)
}