Files
supabase/apps/studio/components/layouts/Scaffold.tsx
Jonathan Summers-MuirandJoshen Lim 9f420962e1 Feat/compute and disk (#30068)
* inited. added disk config to a new page

* add instances

* move moar

* moved things around. billing badges updated. compute added

* tidy

* new components

* form now dynamically updating itself

* updated compute form. moved warning panels. added collapsible for advanced options

* review dialog now only showing what is relevant

* Update DiskManagementForm.tsx

* compute sizes now a reccomendation

* fix old form

* started adding flags

* removed unused code. fixed issue with IOPS price showing on smaller compute

* moar clearning

* IOPS logic wrong way round

* type fixes

* start adding better error handling

* TIDY

* moved everything to own file

* tidy

* fix hydration issue

* moved some components around

* clean up

* inline errors

* update form message

* Update DiskManagementForm.tsx

* error fields fixed. some formatting issues. nano added as an option

* fix constants

* add some plan restrictions

* moar

* units updated. labels updated

* Update DiskManagement.schema.ts

* fix a ton of type issues

* text udpates

* add panel to suggest switching to io2

* more notice board stuff

* number formatting. moved a file

* Update DiskManagementForm.tsx

* remove console logs

* upgrade comms. more type fixes

* add empty states for the old areas

* more links

* updated some label issues

* hide labels when chart is active

* Update DiskManagement.utils.ts

* Delete next-env.d.ts

* Update DiskManagementForm.tsx

* Update DiskManagement.schema.ts

* text updates

* Update DiskManagement.constants.tsx

* Update next-env.d.ts

* Update next-env.d.ts

* Small clean uop

* Clean up empty files

* Clean up spelling

* Clean up more

* Fix typo in file name

* Clean up import statements

* Update DiskManagementForm.tsx

* fix issues

* Update ProjectLayout.tsx

* Remove unused import

* Fix

* Address nit

* Update database.tsx

* remove supress toast

* Update DiskManagement.schema.ts

* Update database.tsx

* change upgrade comms

* Update DiskManagementPanelForm.tsx

* fixes

* fix button size on old form

* Update DiskManagementForm.tsx

* Update StorageTypeField.tsx

* update labels on compute

* dont show banner when infra is FLY

* update comms. hide disk config for FLY

* Fix TS

* Last round of clean upo

* fix message state

* fix message

* Fix TS

* Update DiskManagement.utils.ts

* fix errors

* Update BillingChangeBadge.tsx

* fixed some label issues

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-11-04 09:05:37 +00:00

168 lines
4.8 KiB
TypeScript

import React from 'react'
import { cn } from 'ui'
export const MAX_WIDTH_CLASSES = 'mx-auto w-full max-w-[1200px]'
export const PADDING_CLASSES = 'px-6 lg:px-14 xl:px-24 2xl:px-32'
export const MAX_WIDTH_CLASSES_COLUMN = 'min-w-[420px]'
const ScaffoldHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return (
<header
{...props}
ref={ref}
className={cn('w-full', 'flex-col gap-3 py-6', className)}
></header>
)
}
)
const ScaffoldTitle = React.forwardRef<
HTMLHeadingElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => {
return <h1 ref={ref} {...props} className={cn('text-2xl', className)} />
})
const ScaffoldDescription = React.forwardRef<
HTMLHeadingElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => {
return <span ref={ref} {...props} className={cn('text-sm text-foreground-light', className)} />
})
const ScaffoldContainer = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & { bottomPadding?: boolean }
>(({ className, bottomPadding, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn(MAX_WIDTH_CLASSES, PADDING_CLASSES, bottomPadding && 'pb-16', className)}
/>
)
})
const ScaffoldDivider = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return <div ref={ref} {...props} className={cn('w-full h-px bg-border', className)} />
}
)
const ScaffoldSection = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn('flex flex-col gap-3 py-6', 'lg:grid md:grid-cols-12 lg:py-12', className)}
/>
)
}
)
const ScaffoldColumn = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn('flex flex-col gap-3', MAX_WIDTH_CLASSES_COLUMN, className)}
/>
)
}
)
const ScaffoldSectionDetail = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, children, title, ...props }, ref) => {
return (
<div ref={ref} {...props} className={cn('col-span-4 xl:col-span-5 prose text-sm', className)}>
{title && <h2>{title}</h2>}
{children}
</div>
)
})
const ScaffoldSectionContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn('col-span-8 xl:col-span-7', 'flex flex-col gap-6', className)}
/>
)
})
// Table and filters
const ScaffoldFilterAndContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
return <div ref={ref} {...props} className={cn('flex flex-col gap-3 items-center', className)} />
})
// Actions Group
const ScaffoldActionsContainer = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
return <div ref={ref} {...props} className={cn('flex w-full items-center', className)} />
})
// Actions Group
const ScaffoldActionsGroup = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return <div ref={ref} {...props} className={cn('flex flex-row gap-3', className)} />
}
)
// For older layouts
const ScaffoldContainerLegacy = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn(MAX_WIDTH_CLASSES, PADDING_CLASSES, 'my-8 flex flex-col gap-8', className)}
/>
)
})
ScaffoldHeader.displayName = 'ScaffoldHeader'
ScaffoldTitle.displayName = 'ScaffoldTitle'
ScaffoldDescription.displayName = 'ScaffoldDescription'
ScaffoldContainer.displayName = 'ScaffoldContainer'
ScaffoldDivider.displayName = 'ScaffoldDivider'
ScaffoldSection.displayName = 'ScaffoldSection'
ScaffoldColumn.displayName = 'ScaffoldColumn'
ScaffoldSectionDetail.displayName = 'ScaffoldSectionDetail'
ScaffoldSectionContent.displayName = 'ScaffoldSectionContent'
ScaffoldFilterAndContent.displayName = 'ScaffoldFilterAndContent'
ScaffoldActionsContainer.displayName = 'ScaffoldActionsContainer'
ScaffoldActionsGroup.displayName = 'ScaffoldActionsGroup'
ScaffoldContainerLegacy.displayName = 'ScaffoldContainerLegacy'
export {
ScaffoldHeader,
ScaffoldTitle,
ScaffoldDescription,
ScaffoldContainer,
ScaffoldDivider,
ScaffoldSection,
ScaffoldColumn,
ScaffoldSectionDetail,
ScaffoldSectionContent,
ScaffoldFilterAndContent,
ScaffoldActionsContainer,
ScaffoldActionsGroup,
ScaffoldContainerLegacy,
}