Skip to content

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

feat: resolve conflicts and redundant changes

gitstart1a42700a1f0a
diff --cc studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 23dc0ebb37c,99ce84b03f4..1a2e2c056db
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@@ -1,16 -1,32 +1,32 @@@
- import { FC, useState } from 'react'
- import { find, isEmpty, isUndefined } from 'lodash'
- import { Query, Dictionary } from 'components/grid'
+ import { useState } from 'react'
+ import { QueryKey, useQueryClient } from '@tanstack/react-query'
+ import { find, isEmpty, isUndefined, noop } from 'lodash'
+ import { Dictionary } from 'components/grid'
import { Modal } from 'ui'
- import type { PostgresRelationship, PostgresTable, PostgresColumn } from '@supabase/postgres-meta'
+ import type { PostgresTable, PostgresColumn } from '@supabase/postgres-meta'
-import { useStore } from 'hooks'
+import { useStore, useUrlState } from 'hooks'
+ import { entityTypeKeys } from 'data/entity-types/keys'
+ import { useTableRowCreateMutation } from 'data/table-rows/table-row-create-mutation'
+ import { useTableRowUpdateMutation } from 'data/table-rows/table-row-update-mutation'
import { RowEditor, ColumnEditor, TableEditor } from '.'
import { ImportContent } from './TableEditor/TableEditor.types'
- import { ColumnField, CreateColumnPayload, UpdateColumnPayload } from './SidePanelEditor.types'
+ import {
+ ColumnField,
+ CreateColumnPayload,
+ ExtendedPostgresRelationship,
+ UpdateColumnPayload,
+ } from './SidePanelEditor.types'
+ import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import ConfirmationModal from 'components/ui/ConfirmationModal'
+ import JsonEdit from './RowEditor/JsonEditor/JsonEditor'
+ import { JsonEditValue } from './RowEditor/RowEditor.types'
+ import { sqlKeys } from 'data/sql/keys'
+ import ForeignRowSelector, {
+ ForeignRowSelectorProps,
+ } from './RowEditor/ForeignRowSelector/ForeignRowSelector'
- interface Props {
+ export interface SidePanelEditorProps {
selectedSchema: string
selectedTable?: PostgresTable
selectedRowToEdit?: Dictionary<any>
@@@ -37,13 -61,13 +61,14 @@@ const SidePanelEditor = (
sidePanelKey,
isDuplicating = false,
closePanel,
- onRowCreated = () => {},
- onRowUpdated = () => {},
- onTableCreated = () => {},
- onColumnSaved = () => {},
- }) => {
+ onRowCreated = noop,
+ onRowUpdated = noop,
+ onTableCreated = noop,
+ onColumnSaved = noop,
+ }: SidePanelEditorProps) => {
+ const [_, setParams] = useUrlState({ arrayKeys: ['filter', 'sort'] })
const { meta, ui } = useStore()
+ const queryClient = useQueryClient()
const [isEdited, setIsEdited] = useState<boolean>(false)
const [isClosingPanel, setIsClosingPanel] = useState<boolean>(false)
@@@ -139,16 -263,13 +264,21 @@@
if (response?.error) {
ui.setNotification({ category: 'error', message: response.error.message })
} else {
- await meta.tables.loadById(selectedTable!.id)
+ if (
+ !isNewRecord &&
+ payload.name &&
+ selectedColumnToEdit &&
+ selectedColumnToEdit.name !== payload.name
+ ) {
+ reAddRenamedColumnSortAndFilter(selectedColumnToEdit.name, payload.name)
+ }
-
+ queryClient.invalidateQueries(sqlKeys.query(project?.ref, ['foreign-key-constraints']))
+ await Promise.all([
+ meta.tables.loadById(selectedTable!.id),
+ queryClient.invalidateQueries(
+ sqlKeys.query(project?.ref, [selectedTable!.schema, selectedTable!.name])
+ ),
+ ])
onColumnSaved(configuration.isEncrypted)
setIsEdited(false)
closePanel()