Skip to content

Commit

Permalink
add adhoc badge
Browse files Browse the repository at this point in the history
  • Loading branch information
staszekscp committed Apr 11, 2023
1 parent 0cd62c7 commit 70e74ca
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 19 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/testBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }}

- name: Add PULL_REQUEST_NUMBER to .env.staging file
run: echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.staging
- name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it
run: |
cp .env.staging .env.adhoc
sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc
echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc
- uses: Expensify/App/.github/actions/composite/setupNode@main

Expand Down Expand Up @@ -124,8 +127,11 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }}

- name: Add PULL_REQUEST_NUMBER to .env.staging file
run: echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.staging
- name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it
run: |
cp .env.staging .env.adhoc
sed -i '' 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc
echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc
- uses: Expensify/App/.github/actions/composite/setupNode@main

Expand Down Expand Up @@ -184,8 +190,11 @@ jobs:
ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }}
fetch-depth: 0

- name: Add PULL_REQUEST_NUMBER to .env.staging file
run: echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.staging
- name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it
run: |
cp .env.staging .env.adhoc
sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc
echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc
- uses: Expensify/App/.github/actions/composite/setupNode@main

Expand Down Expand Up @@ -223,8 +232,11 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }}

- name: Add PULL_REQUEST_NUMBER to .env.staging file
run: echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.staging
- name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it
run: |
cp .env.staging .env.adhoc
sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc
echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc
- uses: Expensify/App/.github/actions/composite/setupNode@main

Expand Down
50 changes: 50 additions & 0 deletions assets/images/new-expensify-adhoc.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/electronBuilder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const s3Path = {
const macIcon = {
production: './desktop/icon.png',
staging: './desktop/icon-stg.png',
internal: './desktop/icon-stg.png',
internal: './desktop/icon-adhoc.png',
};

const isCorrectElectronEnv = ['production', 'staging', 'internal'].includes(
Expand Down
1 change: 1 addition & 0 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const envToLogoSuffixMap = {
production: '',
staging: '-stg',
dev: '-dev',
adhoc: '-adhoc',
};

function mapEnvToLogoSuffix(envFile) {
Expand Down
Binary file added desktop/icon-adhoc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ platform :android do

desc "Build app for testing"
lane :build_internal do
ENV["ENVFILE"]=".env.staging"
ENV["ENVFILE"]=".env.adhoc"

gradle(
project_dir: './android',
Expand Down Expand Up @@ -118,7 +118,7 @@ platform :ios do
desc "Build app for testing"
lane :build_internal do
require 'securerandom'
ENV["ENVFILE"]=".env.staging"
ENV["ENVFILE"]=".env.adhoc"

keychain_password = SecureRandom.uuid

Expand Down
2 changes: 1 addition & 1 deletion scripts/build-desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export ELECTRON_ENV=${1:-development}
if [[ "$ELECTRON_ENV" == "staging" ]]; then
ENV_FILE=".env.staging"
elif [[ "$ELECTRON_ENV" == "internal" ]]; then
ENV_FILE=".env.staging"
ENV_FILE=".env.adhoc"
elif [[ "$ELECTRON_ENV" == "production" ]]; then
ENV_FILE=".env.production"
else
Expand Down
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ const CONST = {
DEV: 'development',
STAGING: 'staging',
PRODUCTION: 'production',
ADHOC: 'adhoc',
},

// Used to delay the initial fetching of reportActions when the app first inits or reconnects (e.g. returning
Expand Down
5 changes: 3 additions & 2 deletions src/components/EnvironmentBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ENVIRONMENT_SHORT_FORM = {
[CONST.ENVIRONMENT.DEV]: 'DEV',
[CONST.ENVIRONMENT.STAGING]: 'STG',
[CONST.ENVIRONMENT.PRODUCTION]: 'PROD',
[CONST.ENVIRONMENT.ADHOC]: 'ADHOC',
};

const EnvironmentBadge = (props) => {
Expand All @@ -22,8 +23,8 @@ const EnvironmentBadge = (props) => {

return (
<Badge
success={props.environment === CONST.ENVIRONMENT.STAGING}
error={props.environment !== CONST.ENVIRONMENT.STAGING}
success={props.environment === CONST.ENVIRONMENT.STAGING || props.environment === CONST.ENVIRONMENT.ADHOC}
error={props.environment !== CONST.ENVIRONMENT.STAGING && props.environment !== CONST.ENVIRONMENT.ADHOC}
text={text}
badgeStyles={[styles.alignSelfCenter]}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/ExpensifyCashLogo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import ProductionLogo from '../../assets/images/new-expensify.svg';
import DevLogo from '../../assets/images/new-expensify-dev.svg';
import StagingLogo from '../../assets/images/new-expensify-stg.svg';
import AdhocLogo from '../../assets/images/new-expensify-adhoc.svg';
import CONST from '../CONST';
import withEnvironment, {environmentPropTypes} from './withEnvironment';

Expand All @@ -20,6 +21,7 @@ const logoComponents = {
[CONST.ENVIRONMENT.DEV]: DevLogo,
[CONST.ENVIRONMENT.STAGING]: StagingLogo,
[CONST.ENVIRONMENT.PRODUCTION]: ProductionLogo,
[CONST.ENVIRONMENT.ADHOC]: AdhocLogo,
};

const ExpensifyCashLogo = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ApiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Environment.getEnvironment()
return;
}

const defaultToggleState = ENV_NAME === CONST.ENVIRONMENT.STAGING;
const defaultToggleState = ENV_NAME === CONST.ENVIRONMENT.STAGING || ENV_NAME === CONST.ENVIRONMENT.ADHOC;
shouldUseStagingServer = lodashGet(val, 'shouldUseStagingServer', defaultToggleState);
},
});
Expand Down
4 changes: 3 additions & 1 deletion src/libs/Environment/Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const ENVIRONMENT_URLS = {
[CONST.ENVIRONMENT.DEV]: CONST.DEV_NEW_EXPENSIFY_URL + CONFIG.DEV_PORT,
[CONST.ENVIRONMENT.STAGING]: CONST.STAGING_NEW_EXPENSIFY_URL,
[CONST.ENVIRONMENT.PRODUCTION]: CONST.NEW_EXPENSIFY_URL,
[CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_NEW_EXPENSIFY_URL,
};

const OLDDOT_ENVIRONMENT_URLS = {
[CONST.ENVIRONMENT.DEV]: CONST.INTERNAL_DEV_EXPENSIFY_URL,
[CONST.ENVIRONMENT.STAGING]: CONST.STAGING_EXPENSIFY_URL,
[CONST.ENVIRONMENT.PRODUCTION]: CONST.EXPENSIFY_URL,
[CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_EXPENSIFY_URL,
};

/**
Expand All @@ -31,7 +33,7 @@ function isDevelopment() {
* @return {boolean}
*/
function isInternalTestBuild() {
return lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.STAGING && lodashGet(Config, 'PULL_REQUEST_NUMBER', '');
return lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.ADHOC && lodashGet(Config, 'PULL_REQUEST_NUMBER', '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Environment/getEnvironment/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getEnvironment() {
// If we haven't set the environment yet and we aren't on dev, check to see if this is a beta build
betaChecker.isBetaBuild()
.then((isBeta) => {
environment = isBeta || CONST.PULL_REQUEST_NUMBER ? CONST.ENVIRONMENT.STAGING : CONST.ENVIRONMENT.PRODUCTION;
environment = isBeta || CONST.PULL_REQUEST_NUMBER ? CONST.ENVIRONMENT.ADHOC : CONST.ENVIRONMENT.PRODUCTION;
resolve(environment);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Preferences/PreferencesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const PreferencesPage = (props) => {
const languages = props.translate('languagePage.languages');

// Enable additional test features in the staging or dev environments
const shouldShowTestToolMenu = _.contains([CONST.ENVIRONMENT.STAGING, CONST.ENVIRONMENT.DEV], props.environment);
const shouldShowTestToolMenu = _.contains([CONST.ENVIRONMENT.STAGING, CONST.ENVIRONMENT.ADHOC, CONST.ENVIRONMENT.DEV], props.environment);

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
Expand Down
6 changes: 5 additions & 1 deletion src/styles/StyleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@ function getBackgroundColorWithOpacityStyle(backgroundColor, opacity) {
* @param {Boolean} success
* @param {Boolean} error
* @param {boolean} [isPressed=false]
* @param {boolean} [isAdHoc=false]
* @return {Object}
*/
function getBadgeColorStyle(success, error, isPressed = false) {
function getBadgeColorStyle(success, error, isPressed = false, isAdHoc = false) {
if (success) {
if (isAdHoc) {
return isPressed ? styles.badgeSuccessPressed : styles.badgeSuccess;
}
return isPressed ? styles.badgeSuccessPressed : styles.badgeSuccess;
}
if (error) {
Expand Down
1 change: 1 addition & 0 deletions src/styles/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default {

pink200: '#FBCCFF',
pink400: '#F68DFE',
pink600: '#CF4CD9',
pink700: '#712A76',
pink800: '#49225B',

Expand Down
8 changes: 8 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,14 @@ const styles = {
backgroundColor: themeColors.successHover,
},

badgeAdHocSuccess: {
backgroundColor: themeColors.badgeAdHoc,
},

badgeAdHocSuccessPressed: {
backgroundColor: themeColors.badgeAdHocHover,
},

badgeDanger: {
backgroundColor: themeColors.danger,
},
Expand Down
2 changes: 2 additions & 0 deletions src/styles/themes/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const darkTheme = {
imageCropBackgroundColor: colors.greenIcons,
fallbackIconColor: colors.green700,
reactionActive: '#003C73',
badgeAdHoc: colors.pink600,
badgeAdHocHover: colors.pink700,
};

const oldTheme = {
Expand Down

0 comments on commit 70e74ca

Please sign in to comment.