-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[TS migration] Migrate 'Policy.js' lib to TypeScript #33691
[TS migration] Migrate 'Policy.js' lib to TypeScript #33691
Conversation
@cdOut Conflicts 😅 Let us know once it's ready for re-review |
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.
minor comments, rest looks good 👍
@alitoshmatov 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] |
Reviewer Checklist
Screenshots/VideosAndroid: Nativepolicy-android.movAndroid: mWeb Chromepolicy-mweb.moviOS: Nativepolicy-ios.mp4iOS: mWeb Safaripolicy-safari.mp4MacOS: Chrome / Safaripolicy-web.movMacOS: Desktoppolicy-desktop.mov |
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.
Try to re-review this PR yourself and check for a few things:
- Use
finallyData
to DRY up any overlaps betweensuccessData
andfailureData
- Make sure any types have descriptive names that capture what they actually are
- question whether optional fields really should be optional
src/types/onyx/Policy.ts
Outdated
unit: Unit; | ||
}; | ||
|
||
type NewCustomUnit = { |
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.
We should not need separate types for CustomUnit
and NewCustomUnit
.
Furthermore, It's pretty sus that all the fields of both would be optional.
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 did check which fields should be required and updated it accordingly. I have a very limited leeway when handing types here due to how values are passed in the updateWorkspaceCustomUnitAndRate
and saveUnitAndRate
. I did manage to remove the other type, it still isn't perfect but that's the best we can achieve without changing the logic and value passed to the functions mentioned above. Please check whether current implementation is okay.
merge main into ts-migration/policy-action-lib
cc: @roryabraham I re-reviewed and applied your suggestions, please check it again. |
makeMeAdmin?: boolean; | ||
|
||
/** Pending fields for the policy */ | ||
pendingFields?: Record<string, unknown>; |
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.
We should instead use OnyxCommon.PendingFields
, ideally including only the fields that can be pending, for example like pendingFields?: OnyxCommon.PendingFields<'avatar' | 'employeeList>
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.
We should make this change here, but I also brought this topic up for further discussion here
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.
In this case to get ts passing I had to change this to:
pendingFields?: OnyxCommon.PendingFields<'addWorkspaceRoom' & 'avatar' & 'generalSettings'>
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.
@roryabraham 'addWorkspaceRoom' & 'avatar' & 'generalSettings'
type equals never
, so it's not ideal. I agree that we should define pendingFields better, moving to the slack discussion.
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.
We still could have changed this to be just OnyxCommon.PendingFields
, but I'll treat this as NAB since we have a follow-up issue in place
Also we have conflicts here |
Back to you @roryabraham! |
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 👍🏼
makeMeAdmin?: boolean; | ||
|
||
/** Pending fields for the policy */ | ||
pendingFields?: Record<string, unknown>; |
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.
We still could have changed this to be just OnyxCommon.PendingFields
, but I'll treat this as NAB since we have a follow-up issue in place
✋ 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/roryabraham in version: 1.4.27-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.27-1 🚀
|
Details
Migration of Policy.js to TypeScript.
Fixed Issues
$ #24918
Tests
Policy.js that is being migrated here is responsible for everything related to workspaces, so please click through all flows related with it as a test check.
Offline tests
QA Steps
Policy.js that is being migrated here is responsible for everything related to workspaces, so please click through all flows related with it as a test check.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
ANDROID-NATIVE.mov
Android: mWeb Chrome
ANDROID-CHROME.mov
iOS: Native
IOS-NATIVE.mov
iOS: mWeb Safari
IOS-SAFARI.mov
MacOS: Chrome / Safari
CHROME.mov
MacOS: Desktop
DESKTOP.mov