-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 'ContextMenu' and 'ShowContextMenuContext' components to TypeScript #33715
Merged
francoisl
merged 32 commits into
Expensify:main
from
software-mansion-labs:ts/ContextMenu
Jan 16, 2024
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4081242
[TS migration] Migrate 'ShowContextMenuContext.js' component to TypeS…
blazejkustra 7b67f02
Change ContextMenu extenstions
blazejkustra 09c957d
Merge branch 'main' into ts/ContextMenu
blazejkustra 44abb62
Migrate MiniReportActionContextMenu
blazejkustra 84e77cd
Migrate ContextMenuActions
blazejkustra d36fb5b
Fix ContextMenuActions type errors
blazejkustra e395228
Improve ContextMenu types
blazejkustra 460e7ef
Merge branch 'main' into ts/ContextMenu
blazejkustra 7ae56a3
Fix almost all type errors
blazejkustra 4e30106
Merge branch 'main' into ts/ContextMenu
blazejkustra 795c387
Fix all typerrors
blazejkustra 4ea9f87
Make childReportID default value string
blazejkustra b5421c5
Fix type imports
blazejkustra dd66071
Merge branch 'main' into ts/ContextMenu
blazejkustra e6dd4fc
Fix prettier
blazejkustra 149eda4
Merge branch 'main' into ts/ContextMenu
blazejkustra 92ea0ed
Adjust code after review
blazejkustra c410cb2
Adjust code after code review
blazejkustra a61bf91
Merge branch 'main' into ts/ContextMenu
blazejkustra ef6122a
Fix ts errors
blazejkustra 6d8ef3b
Split ContextMenuAction into two
blazejkustra b887754
Merge branch 'main' into ts/ContextMenu
blazejkustra 816ec3c
Merge branch 'main' into ts/ContextMenu
blazejkustra 6d677fb
Fix typecheck
blazejkustra 03eed43
Merge branch 'main' into ts/ContextMenu
blazejkustra 945912c
Fix typecheck
blazejkustra 67d7d73
Merge branch 'main' into ts/ContextMenu
blazejkustra db17b54
Add getPageCoords util
blazejkustra c4c560e
Rename function to extractPointerEvent
blazejkustra 68a28c9
Merge branch 'main' into ts/ContextMenu
blazejkustra c5bb9be
Fix typecheck on main
blazejkustra 0247630
Fix lint
blazejkustra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {createContext} from 'react'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import type {GestureResponderEvent, Text as RNText} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import * as DeviceCapabilities from '@libs/DeviceCapabilities'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu'; | ||
import CONST from '@src/CONST'; | ||
import type {Report, ReportAction} from '@src/types/onyx'; | ||
|
||
type ShowContextMenuContextProps = { | ||
anchor: RNText | null; | ||
report: OnyxEntry<Report>; | ||
action: OnyxEntry<ReportAction>; | ||
checkIfContextMenuActive: () => void; | ||
}; | ||
|
||
const ShowContextMenuContext = createContext<ShowContextMenuContextProps>({ | ||
anchor: null, | ||
report: null, | ||
action: null, | ||
checkIfContextMenuActive: () => {}, | ||
}); | ||
|
||
ShowContextMenuContext.displayName = 'ShowContextMenuContext'; | ||
|
||
/** | ||
* Show the report action context menu. | ||
* | ||
* @param event - Press event object | ||
* @param anchor - Context menu anchor | ||
* @param reportID - Active Report ID | ||
* @param action - ReportAction for ContextMenu | ||
* @param checkIfContextMenuActive Callback to update context menu active state | ||
* @param isArchivedRoom - Is the report an archived room | ||
*/ | ||
function showContextMenuForReport( | ||
event: GestureResponderEvent | MouseEvent, | ||
anchor: RNText | null, | ||
reportID: string, | ||
action: OnyxEntry<ReportAction>, | ||
checkIfContextMenuActive: () => void, | ||
isArchivedRoom = false, | ||
) { | ||
if (!DeviceCapabilities.canUseTouchScreen()) { | ||
return; | ||
} | ||
|
||
ReportActionContextMenu.showContextMenu( | ||
CONST.CONTEXT_MENU_TYPES.REPORT_ACTION, | ||
event, | ||
'', | ||
anchor, | ||
reportID, | ||
action?.reportActionID, | ||
ReportUtils.getOriginalReportID(reportID, action), | ||
undefined, | ||
checkIfContextMenuActive, | ||
checkIfContextMenuActive, | ||
isArchivedRoom, | ||
); | ||
} | ||
|
||
export {ShowContextMenuContext, showContextMenuForReport}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this typing-related?
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.
onClose
is of type() => void
: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 assume that the previous code was outdated or written in mistake? Another option would be that the typing is wrong.