Skip to content

Commit

Permalink
Merge pull request #6025 from Expensify/update-staging-from-main
Browse files Browse the repository at this point in the history
  • Loading branch information
OSBotify authored Oct 23, 2021
2 parents 5ac117d + 7661e12 commit 3b055f7
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 49 deletions.
9 changes: 7 additions & 2 deletions STORYBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Here's an example story:
import React from 'react';
import Button from '../components/Button';

export default {
const story = {
// Title field will determine how the story displays in the sidebar
title: 'Components/Button',
component: Button,
Expand All @@ -48,11 +48,16 @@ export default {
const Template = args => <Button {...args} />;

// Each story must be exported with a named export
export const Default = Template.bind({});
const Default = Template.bind({});
Default.args = {
text: 'Save & Continue',
success: true,
};

export default story;
export {
Default,
};
```

That will give us an interactive playground to test out various component attributes with the defaults we passed.
Expand Down
18 changes: 17 additions & 1 deletion STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,23 @@ ES6 provides two ways to export a module from a file: `named export` and `defaul
- Files with multiple exports should always use named exports
- Files with a single method or variable export are OK to use named exports
- Mixing default and named exports in a single file is OK (e.g. in a self contained module), but should rarely be used
- All exports should be declared at the bottom of the file
- All exports (both default and named) should happen at the bottom of the file
- Do **not** export individual features inline.

```javascript
// Bad
export const something = 'nope';
export const somethingElse = 'stop';

// Good
const something = 'yep';
const somethingElse = 'go';

export {
something,
somethingElse,
};
```

## Classes and constructors

Expand Down
33 changes: 23 additions & 10 deletions __mocks__/react-native-permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const {RESULTS} = require('react-native-permissions/dist/commonjs/results');

export {PERMISSIONS, RESULTS};

export const openLimitedPhotoLibraryPicker = jest.fn((() => {}));
export const openSettings = jest.fn(() => {});
export const check = jest.fn(() => RESULTS.GRANTED);
export const request = jest.fn(() => RESULTS.GRANTED);
export const checkLocationAccuracy = jest.fn(() => 'full');
export const requestLocationAccuracy = jest.fn(() => 'full');
const openLimitedPhotoLibraryPicker = jest.fn((() => {}));
const openSettings = jest.fn(() => {});
const check = jest.fn(() => RESULTS.GRANTED);
const request = jest.fn(() => RESULTS.GRANTED);
const checkLocationAccuracy = jest.fn(() => 'full');
const requestLocationAccuracy = jest.fn(() => 'full');

const notificationOptions = ['alert', 'badge', 'sound', 'carPlay', 'criticalAlert', 'provisional'];

Expand All @@ -23,12 +23,12 @@ const notificationSettings = {
notificationCenter: true,
};

export const checkNotifications = jest.fn(() => ({
const checkNotifications = jest.fn(() => ({
status: RESULTS.GRANTED,
settings: notificationSettings,
}));

export const requestNotifications = jest.fn(options => ({
const requestNotifications = jest.fn(options => ({
status: RESULTS.GRANTED,
settings: options
.filter(option => notificationOptions.includes(option))
Expand All @@ -38,12 +38,12 @@ export const requestNotifications = jest.fn(options => ({
}),
}));

export const checkMultiple = jest.fn(permissions => permissions.reduce((acc, permission) => ({
const checkMultiple = jest.fn(permissions => permissions.reduce((acc, permission) => ({
...acc,
[permission]: RESULTS.GRANTED,
})));

export const requestMultiple = jest.fn(permissions => permissions.reduce((acc, permission) => ({
const requestMultiple = jest.fn(permissions => permissions.reduce((acc, permission) => ({
...acc,
[permission]: RESULTS.GRANTED,
})));
Expand All @@ -63,3 +63,16 @@ export default {
requestMultiple,
requestNotifications,
};

export {
openLimitedPhotoLibraryPicker,
openSettings,
check,
request,
checkLocationAccuracy,
requestLocationAccuracy,
checkNotifications,
requestNotifications,
checkMultiple,
requestMultiple,
};
8 changes: 4 additions & 4 deletions __mocks__/urbanairship-react-native.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export default {
setUserNotificationsEnabled: jest.fn(),
};

const EventType = {
NotificationResponse: 'notificationResponse',
PushReceived: 'pushReceived',
};

export default {
setUserNotificationsEnabled: jest.fn(),
};

export {
EventType,
};
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001010813
versionName "1.1.8-13"
versionCode 1001010814
versionName "1.1.8-14"
}
splits {
abi {
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.8.13</string>
<string>1.1.8.14</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.8.13</string>
<string>1.1.8.14</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.8-13",
"version": "1.1.8-14",
"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
6 changes: 5 additions & 1 deletion src/components/withDrawerState.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import {useDrawerStatus} from '@react-navigation/drawer';
import getComponentDisplayName from '../libs/getComponentDisplayName';

export const withDrawerPropTypes = {
const withDrawerPropTypes = {
isDrawerOpen: PropTypes.bool.isRequired,
};

Expand Down Expand Up @@ -36,3 +36,7 @@ export default function withDrawerState(WrappedComponent) {
<WithDrawerState {...props} forwardedRef={ref} />
));
}

export {
withDrawerPropTypes,
};
6 changes: 5 additions & 1 deletion src/libs/Growl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import CONST from '../CONST';

export const growlRef = React.createRef();
const growlRef = React.createRef();

/**
* Show the growl notification
Expand Down Expand Up @@ -39,3 +39,7 @@ export default {
error,
success,
};

export {
growlRef,
};
6 changes: 5 additions & 1 deletion src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Onyx.connect({
callback: val => isLoggedIn = Boolean(val && val.authToken),
});

export const navigationRef = createNavigationContainerRef();
const navigationRef = createNavigationContainerRef();

// This flag indicates that we're trying to deeplink to a report when react-navigation is not fully loaded yet.
// If true, this flag will cause the drawer to start in a closed state (which is not the default for small screens)
Expand Down Expand Up @@ -204,3 +204,7 @@ export default {
getDefaultDrawerState,
setDidTapNotification,
};

export {
navigationRef,
};
9 changes: 7 additions & 2 deletions src/libs/canCaptureMetrics/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import CONFIG from '../../CONFIG';

// We don't capture performance metrics on web as there are enough tools available
export const canCapturePerformanceMetrics = () => false;
const canCapturePerformanceMetrics = () => false;

export const canCaptureOnyxMetrics = () => Boolean(CONFIG.ONYX_METRICS);
const canCaptureOnyxMetrics = () => Boolean(CONFIG.ONYX_METRICS);

export {
canCapturePerformanceMetrics,
canCaptureOnyxMetrics,
};
9 changes: 7 additions & 2 deletions src/libs/canCaptureMetrics/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ import CONFIG from '../../CONFIG';
*
* @returns {Boolean}
*/
export const canCapturePerformanceMetrics = () => CONFIG.CAPTURE_METRICS;
const canCapturePerformanceMetrics = () => CONFIG.CAPTURE_METRICS;

/**
* Is capturing Onyx stats enabled.
*
* @returns {Boolean}
*/
export const canCaptureOnyxMetrics = () => CONFIG.ONYX_METRICS;
const canCaptureOnyxMetrics = () => CONFIG.ONYX_METRICS;

export {
canCapturePerformanceMetrics,
canCaptureOnyxMetrics,
};
6 changes: 5 additions & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getActionText(reportAction) {
return lodashGet(message, 'html', '');
}

export const CONTEXT_MENU_TYPES = {
const CONTEXT_MENU_TYPES = {
LINK: 'LINK',
REPORT_ACTION: 'REPORT_ACTION',
};
Expand Down Expand Up @@ -132,3 +132,7 @@ export default [
},
},
];

export {
CONTEXT_MENU_TYPES,
};
12 changes: 9 additions & 3 deletions src/stories/Button.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from '../components/Button';
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
export default {
const story = {
title: 'Components/Button',
component: Button,
};
Expand All @@ -16,8 +16,8 @@ const Template = args => <Button {...args} />;

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
export const Default = Template.bind({});
export const Loading = Template.bind({});
const Default = Template.bind({});
const Loading = Template.bind({});
Default.args = {
text: 'Save & Continue',
success: true,
Expand All @@ -27,3 +27,9 @@ Loading.args = {
isLoading: true,
success: true,
};

export default story;
export {
Default,
Loading,
};
9 changes: 7 additions & 2 deletions src/stories/ButtonWithDropdown.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ButtonWithDropdown from '../components/ButtonWithDropdown';
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
export default {
const story = {
title: 'Components/ButtonWithDropdown',
component: ButtonWithDropdown,
};
Expand All @@ -16,7 +16,12 @@ const Template = args => <ButtonWithDropdown {...args} />;

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
export const Default = Template.bind({});
const Default = Template.bind({});
Default.args = {
buttonText: 'Pay with Venmo',
};

export default story;
export {
Default,
};
6 changes: 5 additions & 1 deletion src/stories/Checkbox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ const Template = args => <Checkbox {...args} />;

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
export const Default = Template.bind({});
const Default = Template.bind({});
Default.args = {
onPress: () => {},
isChecked: true,
};

export {
Default,
};
15 changes: 11 additions & 4 deletions src/stories/CheckboxWithLabel.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import styles from '../styles/styles';
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
export default {
const story = {
title: 'Components/CheckboxWithLabel',
component: CheckboxWithLabel,
};
Expand All @@ -18,9 +18,9 @@ const Template = args => <CheckboxWithLabel {...args} />;

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
export const Default = Template.bind({});
export const WithLabelComponent = Template.bind({});
export const WithErrors = Template.bind({});
const Default = Template.bind({});
const WithLabelComponent = Template.bind({});
const WithErrors = Template.bind({});
Default.args = {
isChecked: true,
label: 'Plain text label',
Expand All @@ -46,3 +46,10 @@ WithErrors.args = {
onPress: () => {},
label: 'I accept the Terms & Conditions',
};

export default story;
export {
Default,
WithLabelComponent,
WithErrors,
};
9 changes: 7 additions & 2 deletions src/stories/Datepicker.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const Template = args => <DatePicker {...args} />;

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
export const Default = Template.bind({});
export const PreFilled = Template.bind({});
const Default = Template.bind({});
const PreFilled = Template.bind({});
Default.args = {
label: 'Select Date',
};
Expand All @@ -36,3 +36,8 @@ PreFilled.args = {
label: 'Select Date',
value: new Date(2018, 7, 21),
};

export {
Default,
PreFilled,
};
Loading

0 comments on commit 3b055f7

Please sign in to comment.