Files
supabase/apps/studio/components/ui/Forms/FormSection.tsx
T
Ivan Vasilov c5bf65b0b4 feat: Create FDW for S3 Vectors buckets (#40206)
* Fix childProps in Admonition so that they're added as a prop to the main div.

* Replace the admonition with Alert in Wrapper tab page to add a gap between childs.

* Add s3 vectors fdw.

* Minor fix to FormSection.

* Update the fdw mutations to support passing in options.

* Refactor the vector flow to create fdws.

* Revert cron description change.

* If the bucket can't be created, don't create a fdw.

* Update/delete the fdw when deleting a table or a bucket.

* Minor fixes.

* Clean up the delete modal.

* Handle edge cases when missing a wrapper.

* Remove the admonition in the create bucket modal.

* Fix the loading state when creating a bucket.

* Fix the createWrapper sheet to work with s3 vectors.

* Fix undefined wrapperMeta issue.

* Create the schema when installing a wrapper.

* Tiny cleanup.

* Clean up unneeded useState. Create a wrapper only if the all conditions are met.

* Fix all comments.

* Add s3 vectors for docs.

* Add a link and fix the file name for S3 Vectors in docs.

* Hide the table editor button if the wrapper instance is missing.

* Small fixes.
2025-11-12 11:00:38 +01:00

95 lines
2.0 KiB
TypeScript

import { Children } from 'react'
import { cn } from 'ui'
export const FormSection = ({
children,
id,
header,
disabled,
className,
}: {
children: React.ReactNode
id?: string
header?: React.ReactNode
disabled?: boolean
visible?: boolean
className?: string
}) => {
const classes = [
'grid grid-cols-12 gap-6 px-4 md:px-8 py-4 md:py-8',
`${disabled ? ' opacity-30' : ' opacity-100'}`,
`${className}`,
]
return (
<div id={id} className={classes.join(' ')}>
{header}
{children}
</div>
)
}
export const FormSectionLabel = ({
children,
className = '',
description,
}: {
children: React.ReactNode | string
className?: string
description?: React.ReactNode
}) => {
if (description !== undefined) {
return (
<div className={cn('flex flex-col space-y-2 col-span-12 lg:col-span-5', className)}>
<label className="text-foreground text-sm">{children}</label>
{description}
</div>
)
} else {
return (
<label className={`text-foreground col-span-12 text-sm lg:col-span-5 ${className}`}>
{children}
</label>
)
}
}
const Shimmer = () => (
<div className="flex w-full flex-col gap-2">
<div className="shimmering-loader h-2 w-1/3 rounded"></div>
<div className="flex flex-col justify-between space-y-2">
<div className="shimmering-loader h-[34px] w-2/3 rounded" />
</div>
</div>
)
export const FormSectionContent = ({
children,
loading = true,
loaders,
fullWidth,
className,
}: {
children: React.ReactNode | string
loading?: boolean
loaders?: number
fullWidth?: boolean
className?: string
}) => {
return (
<div
className={`
relative col-span-12 flex flex-col gap-6 @lg:col-span-7
${fullWidth && '!col-span-12'}
${className}
`}
>
{loading
? !!loaders
? new Array(loaders).fill(0).map((_, idx) => <Shimmer key={idx} />)
: Children.map(children, (_, idx) => <Shimmer key={idx} />)
: children}
</div>
)
}