unfoldingWord / tc-create-app

translationCore Create
https://create.translationcore.com/
MIT License
0 stars 5 forks source link

tCC refactor #1154

Closed birchamp closed 2 years ago

klappy commented 2 years ago

Refactor TODOs

Things to prioritize:

IN PROGRESS:

Cypress tests

Other issues noted:

LATER:

Confusing Naming conventions

Console Errors

Borrow, Bend, Break, Begat, Build

Dependency updates

DONE:

Consistent Functional Design patterns

Confusing Naming conventions

KISS: Keep It Stupid Simple

Performance bottleneck:

Shorten files <125 lines to reduce cognitive load

DRY: Don't Repeat Yourself

Bugs to Address

mandolyte commented 2 years ago

On uw-tsv-parser...

At the end, there are two lines that can be changed to fix things up...

Usage:

Note! the usage below is taken from the master branch.

In tc-create, this parser is used in these places:

NOTE: the parser is not present in the refactored code

Then in datatable-translatable, it shows first in the properties for src/components/datatable/DataTable.context.js

export function DataTableContextProvider({
  children,
  sourceFile,
  targetFile,
  delimiters,
  parser,
  config: {
    compositeKeyIndices,
    columnsFilter,
  },
}) 

Thru out the above file, the existence of the parser is checked for and is used when present. Here is just one example of many:

  // parse sourceFile when updated
  useEffect(() => {
    if (parser && parser.tsvStringToTable) {
      console.log("DataTable.context() using tsv parser for source")
      const { data: rows } = parser.tsvStringToTable(sourceFile);
      setSourceRows(rows);
    } else {
      if (delimiters) {
        const { rows } = parseDataTable({ table: sourceFile, delimiters });
        setSourceRows(rows);
      }
    }
  }, [sourceFile, delimiters, parser]);

To update refactored code

  1. Add this import back into TranslatableTSV.js:

    import * as parser from 'uw-tsv-parser';
  2. Add this property to <DataTable />

        parser={parser}
klappy commented 2 years ago

@mandolyte Just implemented and works like a charm!!! Thanks!!

klappy commented 2 years ago

OBS row header/toolbars now display!

klappy commented 2 years ago

bumped minor version to v1.5.0