Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend Vue 3 Upgrade #652

Merged
merged 111 commits into from
Jul 14, 2023
Merged

Frontend Vue 3 Upgrade #652

merged 111 commits into from
Jul 14, 2023

Conversation

sgfost
Copy link
Contributor

@sgfost sgfost commented Jun 1, 2023

Adds a new frontend codebase written with Vue 3 using the composition API and served/bundled with Vite. Additionally, django-webpack-loader is replaced with django-vite for the integration of bundled vue components into Django/jinja templates.

Components and APIs are either ported or rewritten and based off of the previous Vue 2 codebase. Unfortunately an incremental migration was not feasible so here we are with this massive merge request.

More detailed information can be found in the (currently expanding) documentation for the codebase.

Implementation Differences/Replacements

Hot reloading/bundling

Vite (which uses rollup for bundling) is used instead of vue-cli and webpack. This fixes/provides much faster hot-reloading in development mode and functions largely the same when bundling for production. django-webpack-loader is replaced by django-vite for integrating into the django backend, which functions similarly.

Composition

The Vue composition API replaces the class-based options API style of the previous codebase. This extends to replacing class-based APIs with composable functions.

Form Management

Form management/validation is partially handled with vorms which provides a very lightweight API that is very similar to React Hook Form. Yup is still used for validation. The idea is to provide a lightweight/reusable API for building forms that replaces the class/inheritance-based system in the previous codebase (which is no longer an option with Vue 3).

UX Upgrades

Porting everything provided a great opportunity for design upgrades/refreshes where needed. Most notable changes include:

  • Slightly rework search/filtering (codebases, profiles, jobs, events)
  • Upgrades for complex form input components (particularly list entries)
  • Slightly improved validation/error messaging for simple forms and add unsaved alerts
  • Overhaul of release editor page to cut down on clutter and streamline the process (particularly editing contributors)

Maintainability

Starting from scratch allowed some significant re-organization and reduction of the amount of code/dependencies. The hope is that the architecture and individual components should be easier to understand/work on.

Remaining Related Work

  • more thoroughly test in a prod. environment (staging)
  • Add more test coverage, currently unit tests for crucial pieces of code are in place but we should make use of the e2e testing setup added here or component tests if needed
  • small refactor of client/server exchange to use camelCasing for requests/responses to avoid snake_casing mixed into the vue/js code comses/planning#118
  • add a better markdown editing component, currently a basic textarea with an indicator is used as a placeholder comses/planning#115

sgfost and others added 30 commits March 9, 2023 17:37
add server origin for static files in development
some breakage from bootstrap upgrade + better centering
TODO:
- broken imports for multiselect etc.
- clean up unused sass/styles
- inferring text color on buttons etc based on background color
  incorrectly
- any other inconsistencies and easy fixes (*-right -> *-end, etc)
- recreate jumbotron class
- fix badge breaking changes
continuation of bootstrap 4 -> 5
continuation of bootstrap 4 -> 5
continuation of bootrap 4 -> 5
- split _custom into pages/components and rename remaining styles to
  global
- remove unused styles and refactor for readability

[no ci]
now in line with our current js code style rather than defaults

- added workflow for checking code
TODO: run test suite in github CI, potentially lint/format/test all in
one workflow

[no ci]
now runs in the docker container
- `yarn test` for running unit tests
- `yarn test:watch` for running unit tests with vite watching for file
changes
notes on the setup, will go more in depth in the developer wiki

[no ci]
for some reason this was no problem in dev mode but couldn't build

[no ci]
we also want to rebuild docker-compose.yml when its used in the build
target
caused django tests to fail due to sharing the same settings that were
modified to accomodate a pseudo-production mode
fix for collectstatic failing when checking out the vite build branch
because shared/vite/ was not being created
use a more unique id than just name for fields
sgfost added 5 commits May 30, 2023 17:12
essentially a complete re-write that intends to eliminate most of the
confusion around the contributor form

the main 2 elements are the list that got a facelift but remains
similar, and the add/edit modal form which saves a new addition
automatically

TODO:
- implement re-ordering, deleting, and editing existing items

ref #367
ref comses/planning#109
editing modal got split up into a reusable form that contains just the
editing portion so we can use it for adding and editing contributors

currently, reordering requires saving and disables other actions until
that has happened to avoid spamming save requests and complicated
behavior when modifying the out-of-sync list

resolves #367
resolves comses/planning#109
- create components/releaseEditor/ to house components used only in the
  release editor app, given that it is almost as large as the rest of
  the codebase
@sgfost sgfost added the frontend label Jun 1, 2023
@sgfost
Copy link
Contributor Author

sgfost commented Jun 1, 2023

Of course this PR is massive, I'm open to finding a way to split it up

sgfost and others added 5 commits June 8, 2023 10:49
replaced by (now) consistent use of extractDataParams function

resolves #448
otherwise there is no feedback the changes were actually made without a
browser refresh or another action to trigger a re-fetch
this initialization is required by the server and got removed from the
TaggerField when accomodating cases when this wasn't desired
- ignore holder.js img src so that rollup doesn't try to resolve it as a
  dependency and break the module/holder.js script
- fix bootstrap tooltip/modal types, previously we were importing a
  namespace and then mangling it into a type
- turn off django_vite dev mode in staging/prod
@sgfost
Copy link
Contributor Author

sgfost commented Jun 17, 2023

1 remaining issue (at least among the immediately obvious) - In prod mode there seems to be a conflict with how holder.js and vite work which leads to anything that uses a holder.js placeholder failing to load in. Investigating workarounds..

fixed c33ddbc

uses https://github.com/vbabiy/djangorestframework-camel-case to
automatically parse/render camelCase <-> snake_case

- renamed some query params for job/event filtering to use "After"
  instead of "__gte"
- fixed bug where files would not reload after uploading in release
  editor
- fixed issue where certain tag fields were not initialized properly

resolves comses/planning#118
@sgfost
Copy link
Contributor Author

sgfost commented Jun 20, 2023

camelCase refactor added, should be the last change barring any feedback or additional bugs being uncovered

- remove renderer class overrides on some API views, instead relying on
  the new default CamelCaseJSONRenderer
- fix permissions for peer review list_review_event_log
- correct multi-word values for sort/filtering which mistakenly got
  camelCased
- finished reverting accidentally camelCased values
- request state errors should be cleared on success

resolves comses/planning#127
fix issue where the SelectField component would not allow selecting any
option after a failed validation by updating the field value manually
and adding a default option

possibly related: vuejs/vue#4524
@alee alee mentioned this pull request Jul 13, 2023
1 task
- move Edit Metadata button above sidebar
- remove peer reviewed badge from releases that aren't specifically
peer reviewed and add text about one of the versions being peer
reviewed
- add recommendation to peer review reminders modal text to only request
  peer review for unpublished models
- update peer review guidance

resolves comses/planning#33
resolves comses/planning#76
resolves comses/planning#129
@alee alee merged commit b0a65f5 into main Jul 14, 2023
@alee alee deleted the vue3-replace branch September 5, 2023 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants