Skip to content

Commit

Permalink
Merge branch 'main' into Rory-LessConfusingDesktopEnvironments
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Feb 11, 2022
2 parents 6ae2075 + 0944de1 commit 8978c94
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Lint JavaScript

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

jobs:
lint:
if: github.actor != 'OSBotify'
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
44 changes: 42 additions & 2 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,48 @@ on:
branches: [main]

jobs:
confirmPassingBuild:
runs-on: ubuntu-latest

steps:
- name: Run lint
id: lint
uses: Expensify/App/.github/actions/triggerWorkflowAndWait@main
with:
WORKFLOW: lint.yml
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Run tests
id: tests
uses: Expensify/App/.github/actions/triggerWorkflowAndWait@main
with:
WORKFLOW: test.yml
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
# the other workflows with the same change
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
if: ${{ failure() }}
with:
status: custom
fields: workflow, repo
custom_payload: |
{
channel: '#announce',
attachments: [{
color: "#DB4545",
pretext: `<!subteam^S4TJJ3PSL>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

chooseDeployActions:
runs-on: ubuntu-latest
needs: confirmPassingBuild
outputs:
mergedPullRequest: ${{ steps.getMergedPullRequest.outputs.number }}
isStagingDeployLocked: ${{ steps.isStagingDeployLocked.outputs.IS_LOCKED }}
Expand Down Expand Up @@ -167,10 +207,10 @@ jobs:
number: ${{ steps.getMergedPullRequest.outputs.number }}
body: |
@${{ steps.getMergedPullRequest.outputs.author }}, Great job getting your first Expensify/App pull request over the finish line! :tada:
I know there's a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/CONTRIBUTING.md), so here are some points to take note of :memo::
1. Now that your first PR has been merged, you can be hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one job at a time.
1. Now that your first PR has been merged, you can be hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one job at a time.
2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.
3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Jest Unit Tests

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

jobs:
test:
if: github.actor != 'OSBotify'
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001013802
versionName "1.1.38-2"
versionCode 1001013803
versionName "1.1.38-3"
}
splits {
abi {
Expand Down
1 change: 1 addition & 0 deletions config/electronBuilder/electronBuilder.local.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ module.exports = {
'./dist/**/*',
'./desktop/*.js',
'./src/libs/checkForUpdates.js',
'./src/CONST/ENVIRONMENT.js',
],
};
19 changes: 17 additions & 2 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,18 @@ const mainWindow = (() => {
/*
* The default origin of our Electron app is app://- instead of https://new.expensify.com or https://staging.new.expensify.com
* This causes CORS errors because the referer and origin headers are wrong and the API responds with an Access-Control-Allow-Origin that doesn't match app://-
* The same issue happens when using the web proxy to communicate with the staging or production API on dev.
*
* To fix this, we'll:
*
* 1. Modify headers on any outgoing requests to match the origin of our corresponding web environment.
* 1. Modify headers on any outgoing requests to match the origin of our corresponding web environment (not necessary in case of web proxy, because it already does that)
* 2. Modify the Access-Control-Allow-Origin header of the response to match the "real" origin of our Electron app.
*/
const validDestinationFilters = {urls: ['https://*.expensify.com/*']};
if (!ELECTRON_ENVIRONMENT.isDev()) {
const newDotURL = ELECTRON_ENVIRONMENT.isProd() ? 'https://new.expensify.com' : 'https://staging.new.expensify.com';

// Modify the origin and referer for requests sent to our API
const validDestinationFilters = {urls: ['https://*.expensify.com/*']};
browserWindow.webContents.session.webRequest.onBeforeSendHeaders(validDestinationFilters, (details, callback) => {
// eslint-disable-next-line no-param-reassign
details.requestHeaders.origin = newDotURL;
Expand All @@ -177,6 +178,20 @@ const mainWindow = (() => {
});
}

if (ELECTRON_ENVIRONMENT.isDev()) {
const dotenv = require('dotenv');
const path = require('path');
const devEnvConfig = dotenv.config({path: path.resolve(__dirname, '../.env')}).parsed;

if (devEnvConfig.USE_WEB_PROXY === 'true') {
browserWindow.webContents.session.webRequest.onHeadersReceived(validDestinationFilters, (details, callback) => {
// eslint-disable-next-line no-param-reassign
details.responseHeaders['access-control-allow-origin'] = ['http://localhost:8080'];
callback({responseHeaders: details.responseHeaders});
});
}
}

// Prod and staging overwrite the app name in the electron-builder config, so only update it here for dev
if (ELECTRON_ENVIRONMENT.isDev()) {
browserWindow.setTitle('New Expensify');
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.38.2</string>
<string>1.1.38.3</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.38.2</string>
<string>1.1.38.3</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.38-2",
"version": "1.1.38-3",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
31 changes: 25 additions & 6 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import themeColors from '../../styles/themes/default';
import styles from '../../styles/styles';
import Icon from '../Icon';
import * as Expensicons from '../Icon/Expensicons';
import InlineErrorText from '../InlineErrorText';
import Text from '../Text';
import * as styleConst from './styleConst';
import TextInputWithName from '../TextInputWithName';
import Text from '../Text';
import * as StyleUtils from '../../styles/StyleUtils';

class BaseTextInput extends Component {
Expand Down Expand Up @@ -180,6 +179,9 @@ class BaseTextInput extends Component {
// eslint-disable-next-line react/forbid-foreign-prop-types
const inputProps = _.omit(this.props, _.keys(baseTextInputPropTypes.propTypes));
const hasLabel = Boolean(this.props.label.length);
const inputHelpText = this.props.errorText || this.props.hint;
const formHelpStyles = this.props.errorText ? styles.formError : styles.formHelp;

return (
<>
<View>
Expand Down Expand Up @@ -232,6 +234,7 @@ class BaseTextInput extends Component {
this.props.secureTextEntry && styles.pr2,
]}
multiline={this.props.multiline}
maxLength={this.props.maxLength}
onFocus={this.onFocus}
onBlur={this.onBlur}
onChangeText={this.setValue}
Expand All @@ -256,10 +259,26 @@ class BaseTextInput extends Component {
</View>
</TouchableWithoutFeedback>
</View>
{!_.isEmpty(this.props.errorText) && (
<InlineErrorText>
{this.props.errorText}
</InlineErrorText>
{(!_.isEmpty(inputHelpText) || !_.isNull(this.props.maxLength)) && (
<View
style={[
styles.mt1,
styles.flexRow,
styles.justifyContentBetween,
styles.ph3,
]}
>
{!_.isEmpty(inputHelpText) && (
<Text style={[formHelpStyles]}>{inputHelpText}</Text>
)}
{!_.isNull(this.props.maxLength) && (
<Text style={[formHelpStyles, styles.flex1, styles.textAlignRight]}>
{this.value.length}
/
{this.props.maxLength}
</Text>
)}
</View>
)}
</View>
{/*
Expand Down
8 changes: 8 additions & 0 deletions src/components/TextInput/baseTextInputPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const propTypes = {

/** Saves a draft of the input value when used in a form */
shouldSaveDraft: PropTypes.bool,

/** Maximum characters allowed */
maxLength: PropTypes.number,

/** Hint text to display below the TextInput */
hint: PropTypes.string,
};

const defaultProps = {
Expand All @@ -86,6 +92,8 @@ const defaultProps = {
hideFocusedState: false,
innerRef: () => {},
shouldSaveDraft: false,
maxLength: null,
hint: '',
};

export {propTypes, defaultProps};
6 changes: 3 additions & 3 deletions src/libs/PaymentUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ function formatPaymentMethods(bankAccountList, cardList, payPalMeUsername = '',
}

/**
* @param {Number} currentBalance
* @param {Number} currentBalance, in cents
* @param {String} methodType
* @returns {Number}
* @returns {Number} the fee, in cents
*/
function calculateWalletTransferBalanceFee(currentBalance, methodType) {
const transferMethodTypeFeeStructure = methodType === CONST.WALLET.TRANSFER_METHOD_TYPE.INSTANT
? CONST.WALLET.TRANSFER_METHOD_TYPE_FEE.INSTANT
: CONST.WALLET.TRANSFER_METHOD_TYPE_FEE.ACH;
const calculateFee = (currentBalance * transferMethodTypeFeeStructure.RATE) / 100;
const calculateFee = Math.ceil(currentBalance * (transferMethodTypeFeeStructure.RATE / 100));
return Math.max(calculateFee, transferMethodTypeFeeStructure.MINIMUM_FEE);
}

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/PaymentUtilsTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import CONST from '../../src/CONST';

const paymentUtils = require('../../src/libs/PaymentUtils');

describe('PaymentUtils', () => {
it('Test rounding wallet transfer instant fee', () => {
expect(paymentUtils.calculateWalletTransferBalanceFee(2100, CONST.WALLET.TRANSFER_METHOD_TYPE.INSTANT)).toBe(32);
});
});

0 comments on commit 8978c94

Please sign in to comment.