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

Add indicators to let the user know if they are on staging or dev #2506

Merged
merged 14 commits into from
Apr 27, 2021
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=PRODUCTION
1 change: 1 addition & 0 deletions .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=STAGING
8 changes: 8 additions & 0 deletions assets/images/expensify-cash-dev.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/images/expensify-cash-stg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion config/electron.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
},
mac: {
category: 'public.app-category.finance',
icon: './desktop/icon.png',
icon: process.env.SHOULD_DEPLOY_PRODUCTION === 'true' ? './desktop/icon.png' : './desktop/icon-stg.png',
hardenedRuntime: true,
entitlements: 'desktop/entitlements.mac.plist',
entitlementsInherit: 'desktop/entitlements.mac.plist',
Expand Down
Binary file added desktop/icon-dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/icon-stg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ const mainWindow = (() => {
? win => win.loadURL(`http://localhost:${port}`)
: serve({directory: `${__dirname}/../dist`});

// Prod and staging set the icon in the electron-builder config, so only update it here for dev
if (isDev) {
app.dock.setIcon(`${__dirname}/icon-dev.png`);
app.setName('Expensify.cash');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On dev, Electron is still shown in the dock and in the OS menu bar. https://www.electronjs.org/docs/tutorial/application-distribution had some examples on how to make this display properly on mac but I wasn't able to sort it out. Open to suggestions to fix that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think that this is fine to leave on dev.

}

return app.whenReady()
.then(() => {
const browserWindow = new BrowserWindow({
Expand All @@ -130,6 +136,11 @@ const mainWindow = (() => {
titleBarStyle: 'hidden',
});

// Prod and staging overwrite the app name in the electron-builder config, so only update it here for dev
if (isDev) {
browserWindow.setTitle('Expensify.cash');
}

// List the Expensify Chat instance under the Window menu, even when it's hidden
const systemMenu = Menu.getApplicationMenu();
systemMenu.insert(4, new MenuItem({
Expand Down
1 change: 1 addition & 0 deletions src/CONFIG.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
PARTNER_NAME: lodashGet(Config, 'EXPENSIFY_PARTNER_NAME', 'chat-expensify-com'),
PARTNER_PASSWORD: lodashGet(Config, 'EXPENSIFY_PARTNER_PASSWORD', 'e21965746fd75f82bb66'),
EXPENSIFY_CASH_REFERER: 'ecash',
ENVIRONMENT: lodashGet(Config, 'ENVIRONMENT', 'DEV'),
Jag96 marked this conversation as resolved.
Show resolved Hide resolved
},
// eslint-disable-next-line no-undef
IS_IN_PRODUCTION: Platform.OS === 'web' ? process.env.NODE_ENV === 'production' : !__DEV__,
Expand Down
6 changes: 6 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ const CONST = {
},

EMOJI_PICKER_SIZE: 360,

ENVIRONMENT: {
DEV: 'DEV',
STAGING: 'STAGING',
PRODUCTION: 'PRODUCTION',
},
};

export default CONST;
37 changes: 37 additions & 0 deletions src/components/EnvironmentBadge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import {Text, View} from 'react-native';
import styles from '../styles/styles';
import borders from '../styles/utilities/borders';
import CONFIG from '../CONFIG';
import CONST from '../CONST';

const EnvironmentBadge = () => {
// If we are on production, don't show any badge
if (CONFIG.EXPENSIFY.ENVIRONMENT === CONST.ENVIRONMENT.PRODUCTION) {
return null;
}

let badgeText = 'DEV';
Jag96 marked this conversation as resolved.
Show resolved Hide resolved
let style = styles.badgeDanger;
Jag96 marked this conversation as resolved.
Show resolved Hide resolved

if (CONFIG.EXPENSIFY.ENVIRONMENT === CONST.ENVIRONMENT.STAGING) {
badgeText = 'STG';
Jag96 marked this conversation as resolved.
Show resolved Hide resolved
style = styles.badgeSuccess;
}

return (
<View
style={[styles.badge, borders.brSmall, style, styles.ml2]}
>
<Text
style={styles.badgeText}
numberOfLines={1}
Jag96 marked this conversation as resolved.
Show resolved Hide resolved
>
{badgeText}
</Text>
</View>
);
};

EnvironmentBadge.displayName = 'EnvironmentBadge';
export default EnvironmentBadge;
29 changes: 29 additions & 0 deletions src/components/ExpensifyCashLogo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import ProductionLogo from '../../assets/images/expensify-cash.svg';
import DevLogo from '../../assets/images/expensify-cash-dev.svg';
import StagingLogo from '../../assets/images/expensify-cash-stg.svg';
import CONFIG from '../CONFIG';
import CONST from '../CONST';

const propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
};

const ExpensifyCashLogo = (props) => {
if (CONFIG.EXPENSIFY.ENVIRONMENT === CONST.ENVIRONMENT.PRODUCTION) {
Jag96 marked this conversation as resolved.
Show resolved Hide resolved
return <ProductionLogo width={props.width} height={props.height} />;
}

if (CONFIG.EXPENSIFY.ENVIRONMENT === CONST.ENVIRONMENT.STAGING) {
return <StagingLogo width={props.width} height={props.height} />;
}

return <DevLogo width={props.width} height={props.height} />;
};

ExpensifyCashLogo.propTypes = propTypes;
ExpensifyCashLogo.displayName = 'ExpensifyCashLogo';

export default ExpensifyCashLogo;
4 changes: 3 additions & 1 deletion src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import Text from './Text';
import EnvironmentBadge from './EnvironmentBadge';

const propTypes = {
/** Title of the Header */
Expand All @@ -16,10 +17,11 @@ const defaultProps = {
textSize: 'default',
};
const Header = props => (
<View style={[styles.flex1]}>
<View style={[styles.flex1, styles.flexRow]}>
<Text numberOfLines={2} style={[styles.headerText, props.textSize === 'large' && styles.textLarge]}>
{props.title}
</Text>
<EnvironmentBadge />
</View>
);

Expand Down
3 changes: 2 additions & 1 deletion src/components/IOUBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {withOnyx} from 'react-native-onyx';
import Num from 'expensify-common/lib/Num';
import ONYXKEYS from '../ONYXKEYS';
import styles from '../styles/styles';
import borders from '../styles/utilities/borders';

const propTypes = {
// IOU Report data object
Expand All @@ -22,7 +23,7 @@ const defaultProps = {

const IOUBadge = props => (
<View
style={[styles.badge, styles.badgeSuccess, styles.ml2]}
style={[styles.badge, borders.brLarge, styles.badgeSuccess, styles.ml2]}
>
<Text
style={styles.badgeText}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SetPasswordPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import _ from 'underscore';
import lodashGet from 'lodash/get';
import validateLinkPropTypes from './validateLinkPropTypes';
import styles from '../styles/styles';
import ExpensifyCashLogo from '../../assets/images/expensify-cash.svg';
import ExpensifyCashLogo from '../components/ExpensifyCashLogo';
import {setPassword} from '../libs/actions/Session';
import ONYXKEYS from '../ONYXKEYS';
import variables from '../styles/variables';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import PropTypes from 'prop-types';
import styles from '../../../styles/styles';
import variables from '../../../styles/variables';
import ExpensifyCashLogo from '../../../../assets/images/expensify-cash.svg';
import ExpensifyCashLogo from '../../../components/ExpensifyCashLogo';
import welcomeScreenshot from '../../../../assets/images/welcome-screenshot.png';
import TermsAndLicenses from '../TermsAndLicenses';
import WelcomeText from '../../../components/WelcomeText';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../../styles/styles';
import ExpensifyCashLogo from '../../../../assets/images/expensify-cash.svg';
import ExpensifyCashLogo from '../../../components/ExpensifyCashLogo';
import welcomeScreenshot from '../../../../assets/images/welcome-screenshot-wide.png';
import variables from '../../../styles/variables';
import TermsAndLicenses from '../TermsAndLicenses';
Expand Down
5 changes: 4 additions & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ const styles = {

badge: {
backgroundColor: themeColors.badgeDefaultBG,
borderRadius: 14,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the IOUbadge, this border-radius is now set to 12 instead of 14 since I wanted to keep the increments of small/medium/large as multiples of 4 like we do for the spacing file. @shawnborton let me know if this should be set back to 14 and I can update the value in the new borders.js file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for badges, we want them to look like rounded pills and not rounded rectangles because buttons look like rounded rectangles. So maybe go the other way and jack this up to 16 or 20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what 16 and 20 look like, I can update to either

16 20
image image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I am not seeing a difference. Just to make sure we're on the same page, I think the style we are using for the $2.00 in your mockup is the general style we have for badges, and we should just reuse that style for the Chats header too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok sounds good, I'll revert the styles then so both badges have the old border-radius that the IOUBadge had

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the pill doesn't look perfectly rounded, but maybe my eyes are playing tricks on me. Can you double check that the "DEV" pill is only 20px tall? if that's the case, a border radius of > 10px should make it perfectly round.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the box model and element style for the DEV div
image image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just me, or is the text in the pill (both DEV and $2.00) not completely centered?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we see w/ borderRadius: 14?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is with 14
image

height: variables.iconSizeNormal,
flexDirection: 'row',
paddingHorizontal: 7,
Expand All @@ -242,6 +241,10 @@ const styles = {
backgroundColor: themeColors.badgeSuccessBG,
},

badgeDanger: {
backgroundColor: themeColors.badgeDangerBG,
},

badgeText: {
color: themeColors.textReversed,
fontSize: variables.fontSizeSmall,
Expand Down
1 change: 1 addition & 0 deletions src/styles/themes/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
sidebarButtonBG: 'rgba(198, 201, 202, 0.25)',
modalBackdrop: colors.gray3,
modalBackground: colors.gray2,
badgeDangerBG: colors.red,
badgeDefaultBG: colors.gray2,
badgeSuccessBG: colors.green,
buttonDisabledBG: colors.gray2,
Expand Down
20 changes: 20 additions & 0 deletions src/styles/utilities/borders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import variables from '../variables';

/**
* Spacing utility styles with Bootstrap inspired naming.
*
* https://getbootstrap.com/docs/5.0/utilities/borders
*/
export default {
brSmall: {
borderRadius: variables.componentBorderRadiusSmall,
},

brNormal: {
borderRadius: variables.componentBorderRadiusNormal,
},

brLarge: {
borderRadius: variables.componentBorderRadiusLarge,
},
};
1 change: 1 addition & 0 deletions src/styles/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
componentBorderRadius: 8,
componentBorderRadiusSmall: 4,
componentBorderRadiusNormal: 8,
componentBorderRadiusLarge: 12,
avatarSizeNormal: 40,
avatarSizeSmall: 28,
fontSizeSmall: 11,
Expand Down