-
Notifications
You must be signed in to change notification settings - Fork 108
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
chore: Refactor publisher listing app #4859
Conversation
e8b453b
to
78e4d2a
Compare
1d6f97c
to
4fa04a9
Compare
a76dba9
to
f63be2f
Compare
f63be2f
to
3c18464
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that there is no more Function type :) It would be great if you could add more details about the PR like how you organized and grouped files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great refactor! LGTM 🚀
Done
Currently the listing view uses data directly from the template. This will be problematic when moving to the publisher app as it would require the data for every view to be embedded into one template. This PR refactors the app so that the data comes from an API endpoint,
/api/:snap_name/listing
in this case.This application is split into sections, one for each section of the listing page, e.g Listing details, Contact information and Additional information. Each one of these components contains sub-components that are only relevant to that component.
The data for the
GET
request has been formatted so it works out of the box with the form which uses React Hook Form. For thePOST
request, the store API requires the data in a specific format, for example all of the images (icon, banner, and screenshots) need to be present in an array, even if only one of them has changed. Therefore there are some utilities to identify changed fields and format the data so it can be saved.React Query is used to manage the data requests. Each method has been separated into a hook to make reuse easier. The
ListingForm
component is a child component of the mainApp
component, with the data passed to that component once it is available, in order to avoid the state where no data is available.Once the form has saved successfully it makes a new
GET
request to get the latest data and then calls thereset
method from React Hook Form with the new default values so the form is then in a reset state with the latest data.The application makes use of shared components for the
PageHeader
andSaveAndPreview
. These are used by the rest of the publisher app and it will make it easier to integrate the listing page into the publisher app once this PR is merged.How to QA
Testing