User:MarkTraceur/UploadWizard/Refactor

There was some discussion about refactoring bits of UploadWizard, so I figured I'd make a tasks page.

Add/remove flow

edit

The big nasty-looking array that we use for keeping lists of uploads really needs to be fixed. bugzilla:39746 is the initial bug reporting the issue, but User:TheDJ recently ran up against the problem in gerrit:65318, so maybe we should revisit it.

What it looks like now

edit

Basically we just push UploadWizardUpload objects onto an array, then when we delete them, we put something falsy in their place. We don't splice the array or anything, which is weird, because apparently other bits of the code expect the index to never, ever change. Also because there is no central location keeping track of these changes, we are unable to properly update the various stages of the UI consistently.

What it should probably look like

edit

The bits of the code that expect an Upload object to always be in the same place need to change. We should have callbacks and references that refer to the uploads, not hacky dependencies on uncertain aspects of arrays. Maybe even have a specialized UploadList class that can keep track of this complexity for us, rather than trying to hack in the complexity all over our codebase.

How we progress through stages

edit

On top of UploadList data, we would have a stage controller. The stage controller would be responsible for keeping track of which state we are in (with validation ?), and is responsible for the individual stage UI being in sync with the UploadList data.

This could also maybe make it possible to go back and forth between stages...?