Skip to content
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

[No QA] [TS migration] Migrate 'Permissions.js' lib to TypeScript #26861

Merged
108 changes: 0 additions & 108 deletions src/libs/Permissions.js

This file was deleted.

69 changes: 69 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import CONST from '../CONST';

function canUseAllBetas(betas: string[]): boolean {
BartoszGrajdek marked this conversation as resolved.
Show resolved Hide resolved
return betas.includes(CONST.BETAS.ALL);
}

function canUseChronos(betas: string[]): boolean {
return betas.includes(CONST.BETAS.CHRONOS_IN_CASH) || canUseAllBetas(betas);
}

function canUsePayWithExpensify(betas: string[]): boolean {
return betas.includes(CONST.BETAS.PAY_WITH_EXPENSIFY) || canUseAllBetas(betas);
}

function canUseDefaultRooms(betas: string[]): boolean {
return betas.includes(CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas);
}

/**
* IOU Send feature is temporarily disabled.
*/
function canUseIOUSend(): boolean {
return false;
}

function canUseWallet(betas: string[]): boolean {
return betas.includes(CONST.BETAS.BETA_EXPENSIFY_WALLET) || canUseAllBetas(betas);
}

function canUseCommentLinking(betas: string[]): 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: string[]): boolean {
return betas.includes(CONST.BETAS.POLICY_ROOMS) || canUseAllBetas(betas);
}

function canUseTasks(betas: string[]): boolean {
return betas.includes(CONST.BETAS.TASKS) || canUseAllBetas(betas);
}

function canUseCustomStatus(betas: string[]): 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,
};
Loading