-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[No QA] [TS migration] Migrate 'Permissions.js' lib to TypeScript #26861
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
Merged
Gonals
merged 10 commits into
Expensify:main
from
software-mansion-labs:ts-migration/permissions-lib
Sep 21, 2023
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cbbfdad
[TS migration] Migrate 'Permissions.js' lib to TypeScript
BartoszGrajdek 5c310db
Merge remote-tracking branch 'origin/main' into ts-migration/permissi…
BartoszGrajdek 53bd99c
Migrate __mocks__ to typescript
BartoszGrajdek db6f066
Convert type string[] to OnyxTypes.Beta[]
BartoszGrajdek a847a31
Change mocks types
BartoszGrajdek 21f9083
Resolve conflicts
BartoszGrajdek 28c07c3
Migrate Log.js
BartoszGrajdek a6f3498
Small changes
blazejkustra d237efa
Remove console.logs
blazejkustra 934a366
Fix tests
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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,70 @@ | ||
import CONST from '../CONST'; | ||
import * as OnyxTypes from '../types/onyx'; | ||
|
||
function canUseAllBetas(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.ALL); | ||
} | ||
|
||
function canUseChronos(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.CHRONOS_IN_CASH) || canUseAllBetas(betas); | ||
} | ||
|
||
function canUsePayWithExpensify(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.PAY_WITH_EXPENSIFY) || canUseAllBetas(betas); | ||
} | ||
|
||
function canUseDefaultRooms(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas); | ||
} | ||
|
||
/** | ||
* IOU Send feature is temporarily disabled. | ||
*/ | ||
function canUseIOUSend(): boolean { | ||
return false; | ||
} | ||
|
||
function canUseWallet(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.BETA_EXPENSIFY_WALLET) || canUseAllBetas(betas); | ||
} | ||
|
||
function canUseCommentLinking(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.BETA_COMMENT_LINKING) || canUseAllBetas(betas); | ||
} | ||
|
||
/** | ||
* We're requiring you to be added to the policy rooms beta on dev, | ||
* since contributors have been reporting a number of false issues related to the feature being under development. | ||
* See https://expensify.slack.com/archives/C01GTK53T8Q/p1641921996319400?thread_ts=1641598356.166900&cid=C01GTK53T8Q | ||
*/ | ||
function canUsePolicyRooms(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.POLICY_ROOMS) || canUseAllBetas(betas); | ||
} | ||
|
||
function canUseTasks(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.TASKS) || canUseAllBetas(betas); | ||
} | ||
|
||
function canUseCustomStatus(betas: OnyxTypes.Beta[]): boolean { | ||
return betas.includes(CONST.BETAS.CUSTOM_STATUS) || canUseAllBetas(betas); | ||
} | ||
|
||
/** | ||
* Link previews are temporarily disabled. | ||
*/ | ||
function canUseLinkPreviews(): boolean { | ||
return false; | ||
} | ||
|
||
export default { | ||
canUseChronos, | ||
canUsePayWithExpensify, | ||
canUseDefaultRooms, | ||
canUseIOUSend, | ||
canUseWallet, | ||
canUseCommentLinking, | ||
canUsePolicyRooms, | ||
canUseTasks, | ||
canUseCustomStatus, | ||
canUseLinkPreviews, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,9 @@ | ||
// Set up manual mocks for any Logging methods that are supposed hit the 'server', | ||
// this is needed because before, the Logging queue would get flushed while tests were running, | ||
// causing unexpected calls to HttpUtils.xhr() which would cause mock mismatches and flaky tests. | ||
export default { | ||
info: (message: string) => console.debug(`[info] ${message} (mocked)`), | ||
alert: (message: string) => console.debug(`[alert] ${message} (mocked)`), | ||
warn: (message: string) => console.debug(`[warn] ${message} (mocked)`), | ||
hmmm: (message: string) => console.debug(`[hmmm] ${message} (mocked)`), | ||
}; |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.