benwinding / react-admin-import-csv

A csv file import button for react-admin

Home Page:https://benwinding.github.io/react-admin-import-csv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

preCommitCallback running to late

fkowal opened this issue · comments

Hi

I wanted to discuss an issue i ran into to hopefully find a solution

The issue is that the preCommitCallback is called to late in the pipeline

My business case is that Business guy goes to react-admin exports an CSV
fills out some missing information in 1 column and the imports the data back into the system

ie. He export 1000 rows, he fills only 50 and the uses the import CSV

So during import id like the pipeline to looks like

parseCSV -> preCommitCallback -> collisionDetection ....

With the currency pipeline
parseCSV -> collsionDetection -> ... -> very end preCommitCallback

The Override/replace Modal shows 950 rows that are going to be ignored

My suggestion would be

  1. add a config: {transform?: (csvRows[]) => csvRows[]) and invoke this right after GetCSVItems
  2. move th preCommitCallback invocation from being the last step to right after GetCSVItems

Adding this transformation after GetCsvItems would also greatly limits the data fetched/send to GetIdsColliding

I am also open to hearing other ideas

Hi @fkowal,

Thanks for opening a new issue to discuss this further.

So during import id like the pipeline to looks like
parseCSV -> preCommitCallback -> collisionDetection ....

  1. add a config: {transform?: (csvRows[]) => csvRows[]) and invoke this right after GetCSVItems
  2. move th preCommitCallback invocation from being the last step to right after GetCSVItems

Yes that seems like a better flow in my opinion, you can make a pull request if you'd like to try, or I can have a look at it in the next few weeks.

Some of these design decisions came after much discussion in this issue here #21. We basically decided to just immediately import all items which weren't colliding, and only warn if there were collisions (like the windows copy dialogue)