The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
more hooks rule fixes
Alaister Youngc12fcc9119ce
diff --git a/studio/components/grid/components/grid/SelectColumn.tsx b/studio/components/grid/components/grid/SelectColumn.tsxindex 34aced493ec..7bd46667430 100644--- a/studio/components/grid/components/grid/SelectColumn.tsx+++ b/studio/components/grid/components/grid/SelectColumn.tsx@@ -32,6 +32,8 @@ export const SelectColumn: CalculatedColumn<any, any> = {)},formatter: (props: FormatterProps<SupaRow>) => {+ // [Alaister] formatter is actually a valid React component, so we can use hooks here+ // eslint-disable-next-line react-hooks/rules-of-hooksconst [isRowSelected, onRowSelectionChange] = useRowSelection()return (<SelectCellFormatter@@ -49,6 +51,8 @@ export const SelectColumn: CalculatedColumn<any, any> = {)},groupFormatter: (props: GroupFormatterProps<SupaRow>) => {+ // [Alaister] groupFormatter is actually a valid React component, so we can use hooks here+ // eslint-disable-next-line react-hooks/rules-of-hooksconst [isRowSelected, onRowSelectionChange] = useRowSelection()return (<SelectCellFormatterdiff --git a/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx b/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsxindex d2e80f1aed6..1dd3ab709bf 100644--- a/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx+++ b/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx@@ -64,6 +64,9 @@ const TemplateEditor: FC<Props> = ({ template }) => {return (<Form id={formId} className="!border-t-0" initialValues={INITIAL_VALUES} onSubmit={onSubmit}>{({ isSubmitting, resetForm, values, initialValues }: any) => {+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {// Form is reset once remote data is loaded in storeresetForm({diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxindex 4014bc69c75..8d658333d9b 100644--- a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -125,6 +125,9 @@ const SmtpForm = () => {const isValidSmtpConfig = isSmtpEnabled(values)const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {if (isLoaded) {const formValues = generateFormValues(config)diff --git a/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx b/studio/components/interfaces/Database/Wrappers/EditWrapper.tsxindex 9c20cf9680d..5fbdf4b711e 100644--- a/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx+++ b/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx@@ -207,6 +207,9 @@ const EditWrapper = () => {<Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>{({ isSubmitting, handleReset, values, initialValues, resetForm }: any) => {+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksconst [loadingSecrets, setLoadingSecrets] = useState(false)const initialTables = formatWrapperTables(wrapper?.tables ?? [])@@ -216,6 +219,9 @@ const EditWrapper = () => {const encryptedOptions = wrapperMeta.server.options.filter((option) => option.encrypted)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {const fetchEncryptedValues = async () => {setLoadingSecrets(true)diff --git a/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx b/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsxindex 5be829db53d..212bd8dfc3c 100644--- a/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx+++ b/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx@@ -123,6 +123,9 @@ const EdgeFunctionDetails: FC<Props> = () => {{({ isSubmitting, handleReset, values, initialValues, resetForm }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {if (selectedFunction !== undefined) {const formValues = {diff --git a/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx b/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsxindex db8b8d7b2fa..b5279fd1753 100644--- a/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx+++ b/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx@@ -64,6 +64,9 @@ const BillingEmail = () => {{({ isSubmitting, handleReset, values, initialValues, resetForm }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {const values = { billing_email: billing_email ?? '' }resetForm({ values, initialValues: values })diff --git a/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx b/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsxindex 5c0887534c9..0354a87a0b9 100644--- a/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx+++ b/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx@@ -72,6 +72,9 @@ const GeneralSettings = () => {{({ isSubmitting, handleReset, values, initialValues, resetForm }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {const values = { name: name ?? '', isOptedIntoAi }resetForm({ values, initialValues: values })diff --git a/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx b/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsxindex 23225e0ff3b..4ac9ce6acbe 100644--- a/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx+++ b/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx@@ -130,8 +130,11 @@ const InviteMemberButton = ({><Form validationSchema={schema} initialValues={initialValues} onSubmit={onInviteMember}>{({ values, isSubmitting, resetForm }: any) => {- // Catches 'roles' when its available and then adds a default value for role select+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {+ // Catches 'roles' when its available and then adds a default value for role selectif (roles) {resetForm({values: {diff --git a/studio/components/interfaces/Reports/Reports.utils.tsx b/studio/components/interfaces/Reports/Reports.utils.tsxindex 52fec0b482a..668031dd552 100644--- a/studio/components/interfaces/Reports/Reports.utils.tsx+++ b/studio/components/interfaces/Reports/Reports.utils.tsx@@ -1,4 +1,3 @@-import { useStore } from 'hooks'import useDbQuery from 'hooks/analytics/useDbQuery'import useLogsQuery, { LogsQueryData, LogsQueryHandlers } from 'hooks/analytics/useLogsQuery'import {@@ -20,10 +19,10 @@ export const queryParamsToObject = (params: string) => {type PresetHookResult = [LogsQueryData | DbQueryData, LogsQueryHandlers | DbQueryHandler]type PresetHooks = Record<keyof PresetConfig['queries'], () => PresetHookResult>-export const queriesFactory = <T extends string>(queries: BaseQueries<T>): PresetHooks => {- const { ui } = useStore()- const projectRef = ui.selectedProject?.ref ?? 'default'-+export const queriesFactory = <T extends string>(+ queries: BaseQueries<T>,+ projectRef: string+): PresetHooks => {const hooks: PresetHooks = Object.entries<ReportQuery>(queries).reduce((acc, [k, { sql, queryType }]) => {if (queryType === 'db') {diff --git a/studio/components/interfaces/Settings/API/PostgrestConfig.tsx b/studio/components/interfaces/Settings/API/PostgrestConfig.tsxindex 2ed7d977be9..f52a9da6473 100644--- a/studio/components/interfaces/Settings/API/PostgrestConfig.tsx+++ b/studio/components/interfaces/Settings/API/PostgrestConfig.tsx@@ -90,6 +90,9 @@ const PostgrestConfig: FC<Props> = ({}) => {{({ isSubmitting, handleReset, resetForm, values, initialValues }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {if (config) {const values = {diff --git a/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsxindex 44fcec66a5f..6944c059b4b 100644--- a/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx+++ b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx@@ -104,6 +104,9 @@ const AddRestrictionModal: FC<Props> = ({const isValidCIDR = isValidBlockSize && !isPrivate && addressRange !== undefined+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksconst [isFetchingAddress, setIsFetchingAddress] = useState(false)const getClientIpAddress = async () => {diff --git a/studio/components/interfaces/Settings/Logs/LogEventChart.tsx b/studio/components/interfaces/Settings/Logs/LogEventChart.tsxindex cc81a902c95..0a4581b2941 100644--- a/studio/components/interfaces/Settings/Logs/LogEventChart.tsx+++ b/studio/components/interfaces/Settings/Logs/LogEventChart.tsx@@ -9,10 +9,9 @@ interface Props {}const LogEventChart: React.FC<Props> = ({ data, onBarClick }) => {- if (!data) return null// TODO: remove once endpoint returns iso timestamp directlyconst transformedData = useMemo(() => {- return data.map((d) => {+ return data?.map((d) => {const iso = isUnixMicro(d.timestamp)? unixMicroToIsoTimestamp(d.timestamp): dayjs(d.timestamp).toISOString()@@ -27,6 +26,8 @@ const LogEventChart: React.FC<Props> = ({ data, onBarClick }) => {})}, [JSON.stringify(data)])+ if (!data) return null+return (<BarChartminimalHeaderdiff --git a/studio/components/interfaces/Settings/Logs/LogTable.tsx b/studio/components/interfaces/Settings/Logs/LogTable.tsxindex 33f7bae53f5..c0f430681c7 100644--- a/studio/components/interfaces/Settings/Logs/LogTable.tsx+++ b/studio/components/interfaces/Settings/Logs/LogTable.tsx@@ -150,8 +150,6 @@ const LogTable = ({}}, [stringData])- if (!data) return null-// [Joshen] Hmm quite hacky now, but will doconst maxHeight = !queryType ? 'calc(100vh - 42px - 10rem)' : 'calc(100vh - 42px - 3rem)'@@ -252,6 +250,8 @@ const LogTable = ({</div>)+ if (!data) return null+return (<><sectiondiff --git a/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/LogsErrorRenderers.stories.tsx b/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/LogsErrorRenderers.stories.tsxindex a01305d7df6..b0a2e2d6800 100644--- a/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/LogsErrorRenderers.stories.tsx+++ b/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/LogsErrorRenderers.stories.tsx@@ -17,14 +17,16 @@ export const ErrorRenderers = () => (}}>{[- <DefaultErrorRenderer isCustomQuery={false} error="some string error" />,+ <DefaultErrorRenderer key="one" isCustomQuery={false} error="some string error" />,<DefaultErrorRenderer+ key="two"isCustomQuery={false}error={{error: { code: 123, errors: [], status: 'something', message: 'some logflare error' },}}/>,<ResourcesExceededErrorRenderer+ key="three"isCustomQueryerror={{error: {@@ -39,6 +41,7 @@ export const ErrorRenderers = () => (/>,<ResourcesExceededErrorRenderer+ key="four"isCustomQuery={false}error={{error: {diff --git a/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx b/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsxindex 135381a6600..5f0d7bd944f 100644--- a/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx+++ b/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx@@ -108,6 +108,7 @@ const EncryptionKeysManagement: FC<Props> = ({}) => {searchValue.length > 0? [<Button+ key="clear"size="tiny"type="text"icon={<IconX />}diff --git a/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx b/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsxindex f958330b5d2..4d91ec8b592 100644--- a/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx+++ b/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx@@ -96,6 +96,9 @@ const EditSecretModal: FC<Props> = ({ selectedSecret, onClose }) => {onSubmit={onUpdateSecret}>{({ isSubmitting, resetForm }: any) => {+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {if (selectedSecret !== undefined && selectedSecret.decryptedSecret === undefined) {fetchSecretValue()diff --git a/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx b/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsxindex 614e6e09b19..9f276da5e3f 100644--- a/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx+++ b/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx@@ -63,6 +63,7 @@ const SecretsManagement: FC<Props> = ({}) => {searchValue.length > 0? [<Button+ key="clear"size="tiny"type="text"icon={<IconX />}diff --git a/studio/components/interfaces/Storage/EditBucketModal.tsx b/studio/components/interfaces/Storage/EditBucketModal.tsxindex ebc2c9615c7..b812880c31b 100644--- a/studio/components/interfaces/Storage/EditBucketModal.tsx+++ b/studio/components/interfaces/Storage/EditBucketModal.tsx@@ -105,6 +105,9 @@ const EditBucketModal = ({ visible, bucket, onClose }: EditBucketModalProps) =>isSubmitting: booleanresetForm: any}) => {+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {if (visible && bucket !== undefined) {const { value: fileSizeLimit } = convertFromBytes(bucket.file_size_limit ?? 0)diff --git a/studio/components/interfaces/Support/SupportForm.tsx b/studio/components/interfaces/Support/SupportForm.tsxindex 34dff31cf3f..85b226fb346 100644--- a/studio/components/interfaces/Support/SupportForm.tsx+++ b/studio/components/interfaces/Support/SupportForm.tsx@@ -213,6 +213,9 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {isFreeProject &&['Performance', 'Problem'].includes(values.category)+ // [Alaister] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooksuseEffect(() => {if (values.projectRef === 'no-project') {const updatedValues = { ...values, organizationSlug: sortedOrganizations[0]?.slug }diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsxindex 58032980a25..a2cb85890a0 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx@@ -591,15 +591,14 @@ const SidePanelEditor = ({setIsEdited(false)closePanel()}}- children={- <Modal.Content>- <p className="py-4 text-sm text-scale-1100">- There are unsaved changes. Are you sure you want to close the panel? Your changes will- be lost.- </p>- </Modal.Content>- }- />+ >+ <Modal.Content>+ <p className="py-4 text-sm text-scale-1100">+ There are unsaved changes. Are you sure you want to close the panel? Your changes will+ be lost.+ </p>+ </Modal.Content>+ </ConfirmationModal></>)}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsxindex 289de9cfcce..7f021b47133 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx@@ -347,12 +347,11 @@ const TableEditor: FC<Props> = ({onUpdateField({ isRLSEnabled: !tableFields.isRLSEnabled })setRlsConfirmVisible(false)}}- children={- <Modal.Content>- <RLSDisableModalContent />- </Modal.Content>- }- />+ >+ <Modal.Content>+ <RLSDisableModalContent />+ </Modal.Content>+ </ConfirmationModal></div></SidePanel.Content></>diff --git a/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx b/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsxindex 5b45d0b9064..2aab4a73a7c 100644--- a/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx+++ b/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx@@ -2,7 +2,7 @@ import { FC, ReactNode, useEffect, useState } from 'react'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'-import { useStore, withAuth } from 'hooks'+import { useFlag, useStore, withAuth } from 'hooks'import BaseLayout from '../'import Error from 'components/ui/Error'import ProductMenu from 'components/ui/ProductMenu'@@ -25,6 +25,7 @@ const DatabaseLayout: FC<Props> = ({ title, children }) => {const vaultExtension = meta.extensions.byId('supabase_vault')const isVaultEnabled = vaultExtension !== undefined && vaultExtension.installed_version !== null+ const foreignDataWrappersEnabled = useFlag('foreignDataWrappers')const [loaded, setLoaded] = useState<boolean>(isInitialized)@@ -71,7 +72,9 @@ const DatabaseLayout: FC<Props> = ({ title, children }) => {<BaseLayoutisLoading={!loaded}product="Database"- productMenu={<ProductMenu page={page} menu={generateDatabaseMenu(project)} />}+ productMenu={+ <ProductMenu page={page} menu={generateDatabaseMenu(project, foreignDataWrappersEnabled)} />+ }><main style={{ maxHeight: '100vh' }} className="flex-1 overflow-y-auto">{children}diff --git a/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.ts b/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsindex 48961f0397a..cb37f05173e 100644--- a/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.ts+++ b/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.ts@@ -1,16 +1,16 @@import { Project } from 'types'import { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'-import { useFlag } from 'hooks'import { IS_PLATFORM } from 'lib/constants'-export const generateDatabaseMenu = (project?: Project): ProductMenuGroup[] => {+export const generateDatabaseMenu = (+ project?: Project,+ foreignDataWrappersEnabled: boolean = false+): ProductMenuGroup[] => {const ref = project?.ref ?? 'default'const HOOKS_RELEASED = '2021-07-30T15:33:54.383Z'const showHooksRoute = project?.inserted_at ? project.inserted_at > HOOKS_RELEASED : false- const foreignDataWrappersEnabled = useFlag('foreignDataWrappers')-return [{title: 'Database',diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsxindex a8b8ec910f7..19594685dc7 100644--- a/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx@@ -158,6 +158,7 @@ const FeedbackWidget: FC<Props> = ({size="small"overlay={[<Dropdown.Item+ key="upload-screenshot"icon={<IconUpload size={14} />}onClick={() => {if (uploadButtonRef.current) (uploadButtonRef.current as any).click()@@ -166,6 +167,7 @@ const FeedbackWidget: FC<Props> = ({Upload screenshot</Dropdown.Item>,<Dropdown.Item+ key="capture-screenshot"icon={<IconCamera size={14} />}onClick={() => captureScreenshot()}>diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsxindex f6eaad649a7..1abeb05a6d7 100644--- a/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx@@ -42,10 +42,10 @@ const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder =ui.selectedProject?.subscription_tier === PRICING_TIER_PRODUCT_IDS.TEAMconst showOverUsageBadge =+ useFlag('overusageBadge') &&selectedProject?.subscription_tier !== undefined &&!projectHasNoLimits &&- resourcesExceededLimits.length > 0 &&- useFlag('overusageBadge')+ resourcesExceededLimits.length > 0return (<divdiff --git a/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsxindex e7b4edd8600..bcbcb7e54fd 100644--- a/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx+++ b/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx@@ -114,6 +114,7 @@ const SideBarContent = observer(() => {side="bottom"overlay={[<Dropdown.Item+ key="new-ai-query"onClick={() => {setIsOpen(true)setPages([COMMAND_ROUTES.GENERATE_SQL])diff --git a/studio/components/layouts/SettingsLayout/SettingsLayout.tsx b/studio/components/layouts/SettingsLayout/SettingsLayout.tsxindex d60013f47b0..f2317eb6eee 100644--- a/studio/components/layouts/SettingsLayout/SettingsLayout.tsx+++ b/studio/components/layouts/SettingsLayout/SettingsLayout.tsx@@ -1,7 +1,7 @@import { FC, ReactNode, useEffect } from 'react'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'-import { useStore, withAuth } from 'hooks'+import { useFlag, useStore, withAuth } from 'hooks'import { generateSettingsMenu } from './SettingsMenu.utils'import BaseLayout from '../'@@ -24,7 +24,8 @@ const SettingsLayout: FC<Props> = ({ title, children }) => {? router.pathname.split('/')[5]: router.pathname.split('/')[4]- const menuRoutes = generateSettingsMenu(projectRef, projectBaseInfo)+ const isVaultEnabled = useFlag('vaultExtension')+ const menuRoutes = generateSettingsMenu(projectRef, projectBaseInfo, isVaultEnabled)useEffect(() => {if (ui.selectedProject?.ref) {diff --git a/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts b/studio/components/layouts/SettingsLayout/SettingsMenu.utils.tsindex ddaed65b6cd..651fea4d5c6 100644--- a/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts+++ b/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts@@ -1,11 +1,12 @@import { ProjectBase } from 'types'-import { useFlag } from 'hooks'import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'import { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'-export const generateSettingsMenu = (ref: string, project?: ProjectBase): ProductMenuGroup[] => {- const isVaultEnabled = useFlag('vaultExtension')-+export const generateSettingsMenu = (+ ref: string,+ project?: ProjectBase,+ isVaultEnabled: boolean = false+): ProductMenuGroup[] => {const isProjectBuilding = project?.status !== PROJECT_STATUS.ACTIVE_HEALTHYconst buildingUrl = `/project/${ref}/building`diff --git a/studio/components/layouts/TableEditorLayout/EntityListItem.tsx b/studio/components/layouts/TableEditorLayout/EntityListItem.tsxindex cea0d9f124c..2e0d5fdeb19 100644--- a/studio/components/layouts/TableEditorLayout/EntityListItem.tsx+++ b/studio/components/layouts/TableEditorLayout/EntityListItem.tsx@@ -154,7 +154,10 @@ const EntityListItem = ({>Duplicate Table</Dropdown.Item>,- <Link href={`/project/${projectRef}/auth/policies?search=${entity.id}`}>+ <Link+ key="view-policies"+ href={`/project/${projectRef}/auth/policies?search=${entity.id}`}+ ><a><Dropdown.Item key="delete-table" icon={<IconLock size="tiny" />}>View Policiesdiff --git a/studio/components/to-be-cleaned/Docs/Pages/Introduction.tsx b/studio/components/to-be-cleaned/Docs/Pages/Introduction.tsxindex 1385f70b9bd..a125f6c4006 100644--- a/studio/components/to-be-cleaned/Docs/Pages/Introduction.tsx+++ b/studio/components/to-be-cleaned/Docs/Pages/Introduction.tsx@@ -51,8 +51,9 @@ export default function Introduction({ autoApiService, selectedLang }: Props) {<div className="not-prose mb-6"><p>Read the reference documentation:</p><div className="flex items-center gap-4 mt-2">- {libs.map((lib) => (+ {libs.map((lib, i) => (<a+ key={i}href={lib.url}target="_blank"rel="noreferrer"diff --git a/studio/components/to-be-cleaned/ModalsDeprecated/ConfirmModal.js b/studio/components/to-be-cleaned/ModalsDeprecated/ConfirmModal.jsindex 88bba5b5509..e25a3d57690 100644--- a/studio/components/to-be-cleaned/ModalsDeprecated/ConfirmModal.js+++ b/studio/components/to-be-cleaned/ModalsDeprecated/ConfirmModal.js@@ -56,14 +56,13 @@ function ConfirmModal({</Button></div>}- children={- description && (- <Modal.Content>- <p className="py-4 text-sm text-scale-1100">{description}</p>- </Modal.Content>- )- }- />+ >+ {description && (+ <Modal.Content>+ <p className="py-4 text-sm text-scale-1100">{description}</p>+ </Modal.Content>+ )}+ </Modal>)}diff --git a/studio/components/to-be-cleaned/Reports/Reports.utils.ts b/studio/components/to-be-cleaned/Reports/Reports.utils.tsindex 44881dfd8be..4908a994be5 100644--- a/studio/components/to-be-cleaned/Reports/Reports.utils.ts+++ b/studio/components/to-be-cleaned/Reports/Reports.utils.ts@@ -11,6 +11,9 @@ import { NEW_REPORT_SKELETON } from './Reports.constants'*/export const createReport = async ({ router }: any) => {const { ref } = router.query+ // [Alaister] despite it's name, useProjectContentStore is not a real react hook+ // so we can safely disable the eslint rule here+ // eslint-disable-next-line react-hooks/rules-of-hooksconst contentStore = useProjectContentStore(ref)const { data: newReport, error } = await contentStore.create(NEW_REPORT_SKELETON)@@ -30,6 +33,9 @@ export const createReport = async ({ router }: any) => {*/export const deleteReport = async ({ router, id }: any) => {const { ref } = router.query+ // [Alaister] despite it's name, useProjectContentStore is not a real react hook+ // so we can safely disable the eslint rule here+ // eslint-disable-next-line react-hooks/rules-of-hooksconst contentStore = useProjectContentStore(ref)const { data: delReport, error } = await contentStore.del(id)diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsxindex be84f2c6a88..e76d3cc9ac1 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx@@ -122,6 +122,8 @@ const FileExplorerRow: FC<Props> = ({const isPreviewed = !isEmpty(selectedFilePreview) && isEqual(selectedFilePreview.id, item.id)const canUpdateFiles = checkPermissions(PermissionAction.STORAGE_ADMIN_WRITE, '*')+ const { show } = useContextMenu()+const onSelectFile = async (columnIndex: number, file: any) => {popColumnAtIndex(columnIndex)popOpenedFoldersAtIndex(columnIndex - 1)@@ -153,14 +155,14 @@ const FileExplorerRow: FC<Props> = ({closeFilePreview()}- if (item.status === STORAGE_ROW_STATUS.EDITING) {- const inputRef = useRef<any>(null)- const [itemName, setItemName] = useState(item.name)+ const inputRef = useRef<any>(null)+ const [itemName, setItemName] = useState(item.name)- useEffect(() => {- if (inputRef.current) inputRef.current.select()- }, [])+ useEffect(() => {+ if (inputRef.current) inputRef.current.select()+ }, [])+ if (item.status === STORAGE_ROW_STATUS.EDITING) {const onSetItemName = async (event: any) => {event.preventDefault()event.stopPropagation()@@ -314,7 +316,6 @@ const FileExplorerRow: FC<Props> = ({const createdAt = item.created_at ? new Date(item.created_at).toLocaleString() : '-'const updatedAt = item.updated_at ? new Date(item.updated_at).toLocaleString() : '-'- const { show } = useContextMenu()const displayMenu = (event: any, rowType: any) => {show(event, {id:diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsxindex a396c81f47a..d8c424dc48e 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx@@ -29,8 +29,8 @@ const FolderContextMenu: FC<Props> = ({ id = '' }) => {<span className="ml-2 text-xs">Download</span></Item>{canUpdateFiles && [- <Separator />,- <Item onClick={({ props }) => setSelectedItemsToDelete([props.item])}>+ <Separator key="separator" />,+ <Item key="delete" onClick={({ props }) => setSelectedItemsToDelete([props.item])}><IconTrash2 size="tiny" /><span className="ml-2 text-xs">Delete</span></Item>,diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsxindex 2dd3a029e33..2fa07292614 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx@@ -205,6 +205,7 @@ const PreviewPane = () => {align="center"overlay={[<Dropdown.Item+ key="expires-one-week"onClick={async () =>await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.WEEK)}@@ -212,6 +213,7 @@ const PreviewPane = () => {Expire in 1 week</Dropdown.Item>,<Dropdown.Item+ key="expires-one-month"onClick={async () =>await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.MONTH)}@@ -219,13 +221,17 @@ const PreviewPane = () => {Expire in 1 month</Dropdown.Item>,<Dropdown.Item+ key="expires-one-year"onClick={async () =>await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.YEAR)}>Expire in 1 year</Dropdown.Item>,- <Dropdown.Item onClick={() => setSelectedFileCustomExpiry(file)}>+ <Dropdown.Item+ key="custom-expiry"+ onClick={() => setSelectedFileCustomExpiry(file)}+ >Custom expiry</Dropdown.Item>,]}diff --git a/studio/components/to-be-cleaned/forms/SchemaForm.js b/studio/components/to-be-cleaned/forms/SchemaForm.jsindex fa65c7b1560..6be0056b6f1 100644--- a/studio/components/to-be-cleaned/forms/SchemaForm.js+++ b/studio/components/to-be-cleaned/forms/SchemaForm.js@@ -21,8 +21,9 @@ const SchemaForm = ({onSubmit={onSubmit}submitField={() => <></>}model={model}- children={children}- />+ >+ {children}+ </AutoForm>)}export default SchemaFormdiff --git a/studio/components/to-be-cleaned/forms/SchemaFormPanel.js b/studio/components/to-be-cleaned/forms/SchemaFormPanel.jsindex 5ff2947a07c..62f37c2f18e 100644--- a/studio/components/to-be-cleaned/forms/SchemaFormPanel.js+++ b/studio/components/to-be-cleaned/forms/SchemaFormPanel.js@@ -86,7 +86,6 @@ export default function SchemaFormPanel({formRef={(ref) => (formRef = ref)}schema={schema}model={model}- children={children}onSubmit={async (args) => {onSubmit(args).then(() => {@@ -95,7 +94,9 @@ export default function SchemaFormPanel({}).catch(() => setSubmitButtonLoading(false))}}- />+ >+ {children}+ </SchemaForm></div></section>)diff --git a/studio/pages/project/[ref]/logs/explorer/templates.tsx b/studio/pages/project/[ref]/logs/explorer/templates.tsxindex 5879f1d5437..e34e422ba2c 100644--- a/studio/pages/project/[ref]/logs/explorer/templates.tsx+++ b/studio/pages/project/[ref]/logs/explorer/templates.tsx@@ -1,16 +1,15 @@import React, { useState } from 'react'-import { useRouter } from 'next/router'import { observer } from 'mobx-react-lite'+import { useParams } from 'common'import { IconCode, Button, Popover } from 'ui'-import { TEMPLATES } from 'components/interfaces/Settings/Logs'+import { LogTemplate, TEMPLATES } from 'components/interfaces/Settings/Logs'import LogsLayout from 'components/layouts/LogsLayout/LogsLayout'import CardButton from 'components/ui/CardButton'import { NextPageWithLayout } from 'types'import LogsExplorerHeader from 'components/ui/Logs/LogsExplorerHeader'export const LogsTemplatesPage: NextPageWithLayout = () => {- const router = useRouter()- const { ref } = router.query+ const { ref: projectRef } = useParams()return (<div className="mx-auto h-full w-full px-5 py-6">@@ -19,57 +18,7 @@ export const LogsTemplatesPage: NextPageWithLayout = () => {{TEMPLATES.sort((a, b) => a.label!.localeCompare(b.label!)).filter((template) => template.mode === 'custom').map((template, i) => {- const [showPreview, setShowPreview] = useState(false)- return (- <CardButton- key={i}- title={template.label}- icon={- <div- className="duration-400 flex h-6 w-6 items-center justify-center rounded- bg-scale-1200- text-scale-100- transition-colors- group-hover:bg-brand-900- group-hover:text-brand-1200- "- >- <div className="scale-100 group-hover:scale-110">- <IconCode size={12} strokeWidth={2} />- </div>- </div>- }- containerHeightClassName="h-40"- linkHref={`/project/${ref}/logs/explorer?q=${encodeURI(template.searchString)}`}- description={template.description}- footer={- <div className="flex flex-row justify-end">- <Popover- onOpenChange={setShowPreview}- open={showPreview}- className="rounded-lg bg-scale-100"- size="content"- overlay={- <pre className="whitespace-pre-line break-words rounded-lg bg-scale-100 p-4 text-sm">- {template.searchString}- </pre>- }- >- <Button- type="default"- as="span"- onClick={(e) => {- e.preventDefault()- setShowPreview(!showPreview)- }}- >- Preview- </Button>- </Popover>- </div>- }- />- )+ return <Template key={i} projectRef={projectRef} template={template} />})}</div></div>@@ -79,3 +28,57 @@ export const LogsTemplatesPage: NextPageWithLayout = () => {LogsTemplatesPage.getLayout = (page) => <LogsLayout>{page}</LogsLayout>export default observer(LogsTemplatesPage)++const Template = ({ projectRef, template }: { projectRef?: string; template: LogTemplate }) => {+ const [showPreview, setShowPreview] = useState(false)++ return (+ <CardButton+ title={template.label}+ icon={+ <div+ className="duration-400 flex h-6 w-6 items-center justify-center rounded+ bg-scale-1200+ text-scale-100+ transition-colors+ group-hover:bg-brand-900+ group-hover:text-brand-1200+ "+ >+ <div className="scale-100 group-hover:scale-110">+ <IconCode size={12} strokeWidth={2} />+ </div>+ </div>+ }+ containerHeightClassName="h-40"+ linkHref={`/project/${projectRef}/logs/explorer?q=${encodeURI(template.searchString)}`}+ description={template.description}+ footer={+ <div className="flex flex-row justify-end">+ <Popover+ onOpenChange={setShowPreview}+ open={showPreview}+ className="rounded-lg bg-scale-100"+ size="content"+ overlay={+ <pre className="whitespace-pre-line break-words rounded-lg bg-scale-100 p-4 text-sm">+ {template.searchString}+ </pre>+ }+ >+ <Button+ type="default"+ as="span"+ onClick={(e) => {+ e.preventDefault()+ setShowPreview(!showPreview)+ }}+ >+ Preview+ </Button>+ </Popover>+ </div>+ }+ />+ )+}diff --git a/studio/pages/project/[ref]/reports/query-performance.tsx b/studio/pages/project/[ref]/reports/query-performance.tsxindex 1bcbd7cfb15..905b3de1ce6 100644--- a/studio/pages/project/[ref]/reports/query-performance.tsx+++ b/studio/pages/project/[ref]/reports/query-performance.tsx@@ -7,7 +7,7 @@ import Table from 'components/to-be-cleaned/Table'import CopyButton from 'components/ui/CopyButton'import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'import { executeSql } from 'data/sql/execute-sql-query'-import { useFlag } from 'hooks'+import { useFlag, useStore } from 'hooks'import { observer } from 'mobx-react-lite'import { useState } from 'react'import ReactMarkdown from 'react-markdown'@@ -22,7 +22,9 @@ const QueryPerformanceReport: NextPageWithLayout = () => {const [showResetgPgStatStatements, setShowResetgPgStatStatements] = useState(false)const tableIndexEfficiencyEnabled = useFlag('tableIndexEfficiency')const config = PRESET_CONFIG[Presets.QUERY_PERFORMANCE]- const hooks = queriesFactory(config.queries)+ const { ui } = useStore()+ const projectRef = ui.selectedProject?.ref ?? 'default'+ const hooks = queriesFactory(config.queries, projectRef)const mostFrequentlyInvoked = hooks.mostFrequentlyInvoked()const mostTimeConsuming = hooks.mostTimeConsuming()const slowestExecutionTime = hooks.slowestExecutionTime()