Feat: Add Billable Toggle UI#27172
Conversation
|
@0xmiroslav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Just have one stupid question, do I need to send "defaultBillable" or another name? |
|
@waterim Do you mean when sending to the API? Let's use Edit: also just to clarify, the API hasn't been updated yet to accept the param, so you won't be able to test end-to-end |
|
@amyevans Okay, will change it, thank you |
|
@waterim looks like you're missing screenshots/videos. |
|
Does this require any permission for testing? |
I see this in linked issue |
|
We should put it under the tags beta since we're trying to work incrementally so it's not a complete feature yet (and thus we don't want contributors reporting "bugs"). @waterim can you adjust your PR to check for the tags beta before displaying any UI? |
|
@amyevans Sorry, thats because of the conflicts resolve, will change today evening |
|
@waterim just to make sure we're on the same page. You'll want to add the If the user has the permission, then we'll want to show the billable toggle. |
|
@puneetlath ready for review Updated screenshots, added beta for tags and changed defaultBillable to billable for an API |
|
@0xmiroslav done |
| disabled={didConfirm || props.isReadOnly} | ||
| /> | ||
| )} | ||
| {canUseTags && !lodashGet(props.policy, 'disabledFields.defaultBillable', true) && ( |
There was a problem hiding this comment.
To confirm: billable toggle is only for expense request (workspace) right? Not applicable to IOU request (DM, group)?
There was a problem hiding this comment.
As I understand yes
@amyevans to be sure
There was a problem hiding this comment.
Yes, correct. An IOU request doesn't have an associated policy ID so the field is never going to show for one, which is intended.
There was a problem hiding this comment.
Whoops I was too slow. Thanks Puneet 😄
There was a problem hiding this comment.
Also to confirm that this uses same newDotTags beta permission?
|
toggle setting doesn't persist after app refresh, while works on other fields Screen.Recording.2023-09-14.at.2.52.42.PM.mov |
|
@0xmiroslav Updated my solution, removed state, now after refresh it takes data from onyx(as all other fields), but after reset(for example go out from the request) it will be updated with default data from policy as it should be. |
| if (policyExpenseChat) { | ||
| Policy.openDraftWorkspaceRequest(policyExpenseChat.policyID); | ||
| } | ||
| if (typeof props.iou.defaultBillable !== 'boolean') IOU.setMoneyRequestDefaultBillable(lodashGet(props.policy, 'defaultBillable', false)); |
There was a problem hiding this comment.
| if (typeof props.iou.defaultBillable !== 'boolean') IOU.setMoneyRequestDefaultBillable(lodashGet(props.policy, 'defaultBillable', false)); | |
| if (typeof props.iou.defaultBillable !== 'boolean') { | |
| IOU.setMoneyRequestDefaultBillable(lodashGet(props.policy, 'defaultBillable', false)); | |
| } |
There was a problem hiding this comment.
+1 to the code style request, and also please add a comment explaining why we're doing this
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
0xmiroslav
left a comment
There was a problem hiding this comment.
LGTM!
Left minor feedback but NAB
amyevans
left a comment
There was a problem hiding this comment.
A few small comments! Also, the Tests section and QA section need updating. For QA, let's say "None" because we're still behind a beta and don't want deploy blockers created for any failures. For tests:
- Login to the app
- Click "+" dropdown
- Click on "Request money"
- Type any number
- Click "Next"
- Select any
emailworkspace - Click "Show more"
- Look at the toggler
- Please describe what default state the toggle should have based on a policy's settings set in OldDot
- Please describe what should happen if you refresh the page
| if (policyExpenseChat) { | ||
| Policy.openDraftWorkspaceRequest(policyExpenseChat.policyID); | ||
| } | ||
| if (typeof props.iou.defaultBillable !== 'boolean') IOU.setMoneyRequestDefaultBillable(lodashGet(props.policy, 'defaultBillable', false)); |
There was a problem hiding this comment.
+1 to the code style request, and also please add a comment explaining why we're doing this
|
Resolved @amyevans |
amyevans
left a comment
There was a problem hiding this comment.
Just 1 super minor update, then we can ![]()
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/amyevans in version: 1.3.72-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.72-11 🚀
|
| withOnyx({ | ||
| policy: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, | ||
| }, | ||
| }), |
There was a problem hiding this comment.
This caused a regression #28182. The report object may be undefined and accessing the policyID on an undefined crashes the app.
| <Switch | ||
| accessibilityLabel={translate('common.billable')} | ||
| isOn={props.iouIsBillable} | ||
| onToggle={props.onToggleBillable} |
There was a problem hiding this comment.
It appears this was never added to the propType definitions. Can you please add it?
| <Switch | ||
| accessibilityLabel={translate('common.billable')} | ||
| isOn={props.iouIsBillable} | ||
| onToggle={props.onToggleBillable} |
There was a problem hiding this comment.
Here we missed to disable switch its readonly, caused #43756
Details
This PR is about to add Billable toggle to money request.
To test please insert this to App.js with your policyID you are testing:
Fixed Issues
$ #26128
PROPOSAL: #26128 (comment)
Tests
Offline tests
Same as tests
QA Steps
None
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android