Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Updates as per PR comments

Joshen Lim6a469c66d8af
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx
index 1a06ef1e23a..7707f653d1e 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx
@@ -2,24 +2,22 @@ import { FC, useState } from 'react'
import { Button } from '@supabase/ui'
interface ActionBarProps {
+ loading?: boolean
+ disableApply?: boolean
+ children?: any
applyButtonLabel?: string
backButtonLabel?: string
- children?: any
- disableApply?: boolean
applyFunction?: (resolve: any) => void
closePanel: () => void
- loading?: boolean
- noApplyFunction?: boolean
}
const ActionBar: FC<ActionBarProps> = ({
+ loading = false,
+ disableApply = false,
+ children = undefined,
applyButtonLabel = 'Apply',
backButtonLabel = 'Back',
- children = null,
- disableApply = false,
- applyFunction = null,
- closePanel,
- loading = undefined,
- noApplyFunction = false,
+ applyFunction = undefined,
+ closePanel = () => {},
}) => {
const [isRunning, setIsRunning] = useState(false)
@@ -40,13 +38,8 @@ const ActionBar: FC<ActionBarProps> = ({
{children}
- {applyFunction && (
- /**
- * old solution
- * this is necessary when loading is handled by this component
- *
- * author @mildtomato
- */
+ {applyFunction !== undefined ? (
+ // Old solution, necessary when loading is handled by this component itself
<Button
size="small"
onClick={onSelectApply}
@@ -55,17 +48,9 @@ const ActionBar: FC<ActionBarProps> = ({
>
{applyButtonLabel}
</Button>
- )}
-
- {noApplyFunction && (
- /**
- * new solution to avoid using applyFunction
- * this is necessary for handling loading by form itself
- *
- * this does not require he applyCallback() above
- *
- * author @mildtomato
- */
+ ) : (
+ // New solution, when using the Form component, loading is handled by the Form itself
+ // Does not require applyFunction() callback
<Button size="small" disabled={disableApply} loading={loading}>
{applyButtonLabel}
</Button>
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
index 3105b83253c..6b6b5eb41f8 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
@@ -113,10 +113,6 @@ const RowEditor: FC<Props> = ({
}
}
- function resolve() {
- setLoading(false)
- }
-
const onSaveChanges = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
@@ -139,9 +135,9 @@ const RowEditor: FC<Props> = ({
configuration.rowIdx = row!.idx
}
- saveChanges(payload, isNewRecord, configuration, resolve)
+ saveChanges(payload, isNewRecord, configuration, () => setLoading(false))
} else {
- resolve()
+ setLoading(false)
}
}
@@ -230,7 +226,6 @@ const RowEditor: FC<Props> = ({
backButtonLabel="Cancel"
applyButtonLabel="Save"
closePanel={closePanel}
- noApplyFunction
/>
</div>
</div>
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 8ebe4b389de..2bf463db4ae 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@ -55,7 +55,7 @@ const SidePanelEditor: FC<Props> = ({
payload: any,
isNewRecord: boolean,
configuration: { identifiers: any; rowIdx: number },
- resolve: any
+ onComplete: Function
) => {
let saveRowError = false
if (isNewRecord) {
@@ -96,7 +96,7 @@ const SidePanelEditor: FC<Props> = ({
}
}
- resolve()
+ onComplete()
if (!saveRowError) {
setIsEdited(false)
closePanel()
@@ -270,7 +270,7 @@ const SidePanelEditor: FC<Props> = ({
}}
children={
<Modal.Content>
- <p className="py-4 text-sm text-scale-1100">
+ <p className="text-scale-1100 py-4 text-sm">
There are unsaved changes. Are you sure you want to close the panel? Your changes will
be lost.
</p>