The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Dont autopopulate date time fields if they have default value, show the default values as comments instead
Joshen Lim59b4e849f8d6
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/DateTimeInput.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/DateTimeInput.tsxindex 047b5d1296f..83d8a7afe67 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/DateTimeInput.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/DateTimeInput.tsx@@ -1,4 +1,4 @@-import { FC } from 'react'+import { FC, ReactNode } from 'react'import { Input } from 'ui'import { getColumnType } from './DateTimeInput.utils'import dayjs from 'dayjs'@@ -7,7 +7,7 @@ interface Props {name: stringformat: stringvalue: string- description: string+ description: string | ReactNodeonChange: (value: string) => void}@@ -31,12 +31,20 @@ const DateTimeInput: FC<Props> = ({ value, onChange, name, format, description }className="w-full"label={name}descriptionText={- description && description.length !== 0- ? description- : format.includes('tz')- ? `Your local timezone will be automatically applied (${dayjs().format('ZZ')})`- : undefined+ <div className="space-y-1">+ {description}+ {format.includes('tz') && (+ <p>Your local timezone will be automatically applied ({dayjs().format('ZZ')})</p>+ )}+ </div>}+ // descriptionText={+ // description && description.length !== 0+ // ? description+ // : format.includes('tz')+ // ? `Your local timezone will be automatically applied (${dayjs().format('ZZ')})`+ // : undefined+ // }labelOptional={format}size="small"value={value}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsxindex d4fe3ec2c99..8d62c177f1c 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx@@ -166,12 +166,18 @@ const InputField: FC<Props> = ({}if (includes(DATETIME_TYPES, field.format)) {+ console.log(field)return (<DateTimeInputname={field.name}format={field.format}value={field.value ?? ''}- description={field.comment}+ description={+ <>+ {field.defaultValue && <p>Default: {field.defaultValue}</p>}+ {field.comment && <p>{field.comment}</p>}+ </>+ }onChange={(value: any) => onUpdateField({ [field.name]: value })}/>)diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsxindex b343b3e02af..c4c87baf6d4 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx@@ -57,7 +57,7 @@ const RowEditor: FC<Props> = ({useEffect(() => {if (visible) {setErrors({})- const rowFields = generateRowFields(row, selectedTable, isNewRecord)+ const rowFields = generateRowFields(row, selectedTable)setRowFields(rowFields)}}, [visible])diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.tsindex fa1117d2c14..93b513f42d8 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts@@ -1,7 +1,7 @@import dayjs from 'dayjs'-import { find, isUndefined, compact, includes, isEqual, omitBy, isNull, isString } from 'lodash'+import { find, isUndefined, compact, isEqual, omitBy, isNull, isString } from 'lodash'import { Dictionary } from 'components/grid'-import { PostgresColumn, PostgresTable } from '@supabase/postgres-meta'+import { PostgresTable } from '@supabase/postgres-meta'import { uuidv4, minifyJSON, tryParseJson } from 'lib/helpers'import { RowField } from './RowEditor.types'@@ -9,19 +9,15 @@ import { DATETIME_TYPES, TIME_TYPES, TIMESTAMP_TYPES } from '../SidePanelEditor.export const generateRowFields = (row: Dictionary<any> | undefined,- table: PostgresTable,- isNewRecord?: boolean+ table: PostgresTable): RowField[] => {const { relationships, primary_keys } = table// @ts-ignoreconst primaryKeyColumns = primary_keys.map((key) => key.name)return table.columns.map((column) => {- const defaultValue = column?.default_value as string | nullconst value = isUndefined(row)? ''- : isNewRecord && defaultValue?.includes('now()')- ? nowDateTimeValue(column.format): DATETIME_TYPES.includes(column.format)? convertPostgresDatetimeToInputDatetime(column.format, row[column.name]): parseValue(row[column.name], column.format)@@ -130,21 +126,6 @@ const parseDescription = (description: string | null) => {}}-const nowDateTimeValue = (format: string) => {- switch (format) {- case 'timestamptz':- return dayjs().format('YYYY-MM-DDTHH:mm:ss')- case 'timestamp':- return dayjs().format('YYYY-MM-DDTHH:mm:ss')- case 'timetz':- return dayjs().format('HH:mm:ss')- case 'time':- return dayjs().format('HH:mm:ss')- default:- return dayjs().format('YYYY-MM-DD')- }-}-const convertPostgresDatetimeToInputDatetime = (format: string, value: string) => {if (value) {value = value.includes('-') ? value.replaceAll('-', '/') : value