harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
36 stars 30 forks source link

Rewrite frontend of legal document search + add; fixes #1933 #1963

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

This is the frontend half of #1956 to complete #1933.

There are two places in the code where users can add legal documents—from the "Add Content" button on the right, and from the "Quick Add" field in the table of contents. This is intended to replace both, ultimately, but this PR only includes the "Add Content" functionality.

Some of this code is duplicative of the existing legal doc flow. The final PR will make this work net-negative in terms of lines of code, but for now this is mostly additive.

This is a fairly big PR but the work was hard to roll out incrementally since it replaces a feature already there.

The UI looks very similar to before, with changes that are designed to aid readability and bring these results more in line with the presentation of the casebook search results.

Before

image

After

image

The most substantive UI change happens after a case is selected. Previously the page would do a full refresh and take them to the edit-resource page without any notification of what occurred (the legal doc was added to their casebook at the end or in the current section).

Now when they select a search result, they are notified about what happened and prompted to make a choice about what to do next:

image

Full changelist

TODO

There's explicitly no exception handling on the fetch requests right now. They should recover if the backend errors so the UI doesn't freeze, but still report up to Sentry. I'd like to research how best to do this.

There are unit tests for only one component. There should be some coverage for all three. (IMO this work is better suited for unit tests + mocks than Playwright tests, which would require a lot of backend fixtures when the backend is already covered by Python tests.)

I'd like to put this branch up on staging for some human testing before even considering merging, given the size of the PR.

lizadaly commented 1 year ago

This is ready for review before merging to staging for manual testing.