mathesar icon indicating copy to clipboard operation
mathesar copied to clipboard

Improve typing of table Row interface

Open pavish opened this issue 2 years ago • 0 comments

Problem

Table rows currently (at the time of creating this issue) comprise 6 different types:

  • Record row
  • Group header row
  • Dummy row (for loading states) - This is also a type of Record row
  • New row (newly added rows) - This is also a type of Record row
  • New placeholder row (this is the placeholder row shown at the end) - This is also a type of Record row
  • New help text row (this is the help text row mentioning 'New records will be repositioned on refresh' when new rows are added).

All these different types are currently represented by a single interface Row in /src/stores/table-data/records.ts. This may lead to bugs and regressions.

Proposed solution

  • Introduce interfaces for each type of row.
  • Modify the Row interface to a discriminated union of all the types of rows.

Additional context

  • https://github.com/centerofci/mathesar/pull/1229
  • https://github.com/centerofci/mathesar/pull/1236

pavish avatar Mar 26 '22 06:03 pavish