-
Notifications
You must be signed in to change notification settings - Fork 56
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
[cms] feat: switch proposal token to proposal name on invoice lineitem #2041
[cms] feat: switch proposal token to proposal name on invoice lineitem #2041
Conversation
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.
Hey mate good job!
Was getting a CSRF token issue, but then switched to decred/politeia#1242 and it is working fine now. 👍
after moving the batch proposals csrf issue fix to decred/politeia#1242, we now depend on it instead of decred/politeia#1224 |
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.
tACK
Waiting on decred/politeia#1242 |
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 think the useApprovedProposals
should have its own file on src/hooks/api
and the useProposalsBatch
should be moved to its own file there as well. Saying that because we want to keep shared stuff outside politeia and cms containers.
This diff now allows users to select proposals by its name, instead of its token. Since getting proposals names require a batching request, and those requests are bounded by 20 proposals for each request, those requests have to be done more than once in case the token from the invoice (details and diff), or the proposal (new and edit actions) are not on the dropdown list.
746c501
to
a689f16
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.
Good job, will merge when decred/politeia#1242 gets in.
- add onFetchRemainingProposalsBatch method to fetch remaining tokens and lazy load proposal list
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.
tACK
This diff Closes #2016 and changes the lineitem selector for proposal token to proposal name.
Solution description
Creates a
useApprovedProposals
hook to manage approved proposals when needed. Now, invoices send abatch proposals
request to fetch proposals according to the lineitem's token.On
InvoiceForm
, when selecting the proposal token lineitem, we do atokeninventory
request to fetch all proposals tokens, and thenbatch
the approved ones to get the corresponding proposal.Use Cases
Now,
useApprovedProposals
hook can be used when fetching approved proposals is needed.Dependencies
Depends on decred/politeia#1242
UI Changes Screenshot
before:
![Screen Shot 2020-07-02 at 7 36 19 PM](https://user-images.githubusercontent.com/22639213/86414783-5f1e5e80-bc9b-11ea-9c76-7fdb13ed69e1.png)
after:
![Screen Shot 2020-07-02 at 7 33 51 PM](https://user-images.githubusercontent.com/22639213/86414785-60e82200-bc9b-11ea-99c1-66df1e0345bc.png)