readthedocs.org
readthedocs.org copied to clipboard
Dashboard: add missing CreateView for models
So far with the new dashboard, I've been working around inconsistencies in our dashboard CRUD UIs. The main issue is that some UIs do not have a CreateView and dedicated URL, and instead are a hybrid ListView/CreateView that shows a form and a model listing in the same view. This presents a couple issues:
- A long listing pushes the form well out of view, so it's not clear how to add new instances
- This doesn't match the UX of the rest of the views that do have dedicated CreateView instances, where the user clicks a button in the top right corner of the listing view to go to a form page.
I did come up with a temporary solution that addresses both of these problems, using a modal to display the form:
- https://github.com/readthedocs/ext-theme/pull/218
However, this is not a great substitute, and it comes with it's own problems. I'd prefer to have a singular UX here: all models have a dedicated create view and URL endpoint for just the form interaction, and the listing view links to the create view with a button in the top right corner of the listing UI.
I've opened individual issues for some of these in the past, but it might be easy enough to add these in one go. A non-exhaustive list of the models that do not have proper views for just adding a new model instance are:
- [ ] All of the organization create/edit views are also the listing views.
- [ ] Owner model
- TBD?
- [ ] Profile email model
- [ ] Project models
- [ ] Maintainers model
- [ ] Translation model
- [ ] Email notification model
And in terms of the amount of work here, I hope that we can keep scope pretty low too, and just treat this as a new addition to the application:
- [ ] Add new view and URL without changing existing views
- [ ] Use the new URLs/views only in the new dashboard
- [ ] Eventually deprecate the old, hybrid views, after dashboard release
The other day I commented in the chat that, for CRUD views, we could use a new package that came to replace Django vanilla views: https://noumenal.es/neapolitan/
If we want to go in the CRUD views direction, we could give it a try and standardize our views.
I wouldn't mind trying Neapolitan out at some point, but maybe for this case I'd rather just add the missing views rather than rework what we have to fit Neapolitan's model. We should only need to add a single Vanilla/native Django view for each missing view, so we can keep work pretty minimal. This sounds like the easiest option for now.
Neapolitan would be nice to try if we add a new model, so we can avoid writing 4 or 5 separate views.
Some notes:
- Organization owners already have their own view for adding a new owner
https://github.com/readthedocs/readthedocs.org/blob/1552b1692b42d502adfaec0ffab0fad618a8c367/readthedocs/organizations/views/private.py#L145-L152
- For adding new emails, we make use of allauth views, which use the same endpoint, but with a different action
https://github.com/readthedocs/readthedocs.org/blob/1552b1692b42d502adfaec0ffab0fad618a8c367/readthedocs/templates/account/email.html#L52-L56
All others are valid.