Home / Function/ getCellEditor() — supabase Function Reference

getCellEditor() — supabase Function Reference

Architecture documentation for the getCellEditor() function in gridColumns.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  2c945c79_d5b1_c927_1673_28ab2f987c8d["getCellEditor()"]
  68372542_2f36_da50_23ab_dbe74b8156c6["getGridColumns()"]
  68372542_2f36_da50_23ab_dbe74b8156c6 -->|calls| 2c945c79_d5b1_c927_1673_28ab2f987c8d
  67fa7102_dda9_7162_c1c9_1fd1b78605b0["DateTimeEditor()"]
  2c945c79_d5b1_c927_1673_28ab2f987c8d -->|calls| 67fa7102_dda9_7162_c1c9_1fd1b78605b0
  style 2c945c79_d5b1_c927_1673_28ab2f987c8d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/grid/utils/gridColumns.tsx lines 119–194

function getCellEditor(
  columnDefinition: SupaColumn,
  columnType: ColumnType,
  isEditable: boolean,
  onExpandJSONEditor: (column: string, row: any) => void,
  onExpandTextEditor: (column: string, row: any) => void
) {
  if (!isEditable) {
    if (['array', 'json'].includes(columnType)) {
      // eslint-disable-next-line react/display-name
      return (p: any) => (
        <JsonEditor {...p} isEditable={isEditable} onExpandEditor={onExpandJSONEditor} />
      )
    } else if (!['number', 'boolean'].includes(columnType)) {
      // eslint-disable-next-line react/display-name
      return (p: any) => (
        <TextEditor {...p} isEditable={isEditable} onExpandEditor={onExpandTextEditor} />
      )
    } else {
      return
    }
  }
  if (columnDefinition.isPrimaryKey || !columnDefinition.isUpdatable) {
    return
  }

  switch (columnType) {
    case 'boolean': {
      // eslint-disable-next-line react/display-name
      return (p: any) => <BooleanEditor {...p} isNullable={columnDefinition.isNullable} />
    }
    case 'date': {
      return DateTimeEditor('date', columnDefinition.isNullable || false)
    }
    case 'datetime': {
      return columnDefinition.format.endsWith('z')
        ? DateTimeEditor('datetimetz', columnDefinition.isNullable || false)
        : DateTimeEditor('datetime', columnDefinition.isNullable || false)
    }
    case 'time': {
      return columnDefinition.format.endsWith('z') ? TimeWithTimezoneEditor : TimeEditor
    }
    case 'enum': {
      const options = columnDefinition.enum!.map((x) => {
        return { label: x, value: x }
      })
      // eslint-disable-next-line react/display-name
      return (p: any) => (
        <SelectEditor {...p} options={options} isNullable={columnDefinition.isNullable} />
      )
    }
    case 'array':
    case 'json': {
      // eslint-disable-next-line react/display-name
      return (p: any) => <JsonEditor {...p} onExpandEditor={onExpandJSONEditor} />
    }
    case 'number': {
      return NumberEditor
    }
    case 'citext':
    case 'text': {
      // eslint-disable-next-line react/display-name
      return (p: any) => (
        <TextEditor
          {...p}
          isEditable={isEditable}
          isNullable={columnDefinition.isNullable}
          onExpandEditor={onExpandTextEditor}
        />
      )
    }
    default: {
      return undefined
    }
  }
}

Subdomains

Called By

Frequently Asked Questions

What does getCellEditor() do?
getCellEditor() is a function in the supabase codebase.
What does getCellEditor() call?
getCellEditor() calls 1 function(s): DateTimeEditor.
What calls getCellEditor()?
getCellEditor() is called by 1 function(s): getGridColumns.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free