jataware / dojo

5 stars 0 forks source link

Refactor RunJobs.js #113

Open ccjoel opened 1 year ago

ccjoel commented 1 year ago

RunJobs.js contains the component that calls/waits for api/elwood/rqworker dataset-and-model-output processing. It currently uses state to track the job it is tracking, although it only displays a loading animation to the user.

While and if we continue to only display a loading animation, we should remove the use of state/effect and track the processing outside of react state (say with a Ref or completely outside of React with promises).

This will both simplify the code and allow us to remove the "disable eslint" blocks on the file.

adamgilg commented 1 year ago

I did a minor refactor of this to make it work with React 18. In doing so I brought all of the dependencies into the deps array for the useEffect, and I made sure that clicking back from the next steps would still skip the RunJobs step (with a new wrapper component/context setup). You can see the changes here.

This fixes everything I think needs fixing with this file. The skipping step is now simplified greatly, and the useEffect only runs again if the props that are passed down to the whole step change.

It'll be done when https://github.com/jataware/dojo/pull/166 is merged.