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

chore(Bonus Pagamenti Digitali): [#175329922] Add Bpd Test Overlay #2303

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f'
GCM_SENDER_ID='260468725946'
BONUS_VACANZE_ENABLED=NO
MYPORTAL_ENABLED=NO
BPD_ENABLED=NO
# enable playgrounds inside developer section
PLAYGROUNDS_ENABLED=NO
# endpoint BPD API
# BPD configuration
BPD_ENABLED=NO
BPD_TEST_OVERLAY=NO
# BPD endpoint
BPD_API_URL_PREFIX=https://bpd-dev.azure-api.net
BPD_API_SIT='https://bpd-dev.azure-api.net'
BPD_API_UAT='https://test.cstar.pagopa.it'



6 changes: 5 additions & 1 deletion .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ INSTABUG_TOKEN='5c2d0f12fa12f9afc535585e5b7a9e79'
MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f'
GCM_SENDER_ID='260468725946'
BONUS_VACANZE_ENABLED=YES
BPD_ENABLED=NO
MYPORTAL_ENABLED=NO
# enable playgrounds inside developer section
PLAYGROUNDS_ENABLED=NO
# BPD configuration
BPD_ENABLED=NO
BPD_TEST_OVERLAY=NO
# endpoint BPD API
BPD_API_URL_PREFIX='http://127.0.0.1:3000/bonus'
BPD_API_SIT='https://bpd-dev.azure-api.net'
BPD_API_UAT='https://test.cstar.pagopa.it'


6 changes: 5 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f'
GCM_SENDER_ID='260468725946'
BONUS_VACANZE_ENABLED=YES
MYPORTAL_ENABLED=NO
BPD_ENABLED=NO
# enable playgrounds inside developer section
PLAYGROUNDS_ENABLED=NO
# BPD configuration
BPD_ENABLED=NO
BPD_TEST_OVERLAY=NO
# endpoint BPD API
BPD_API_URL_PREFIX=https://bpd-dev.azure-api.net
BPD_API_SIT='https://bpd-dev.azure-api.net'
BPD_API_UAT='https://test.cstar.pagopa.it'
4 changes: 3 additions & 1 deletion ts/RootContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import configurePushNotifications from "./boot/configurePushNotification";
import FlagSecureComponent from "./components/FlagSecure";
import { LightModalRoot } from "./components/ui/LightModal";
import VersionInfoOverlay from "./components/VersionInfoOverlay";
import { shouldDisplayVersionInfoOverlay } from "./config";
import { bpdTestOverlay, shouldDisplayVersionInfoOverlay } from "./config";
import { BpdTestOverlay } from "./features/bonus/bpd/components/BpdTestOverlay";
import Navigation from "./navigation";
import {
applicationChangeState,
Expand Down Expand Up @@ -139,6 +140,7 @@ class RootContainer extends React.PureComponent<Props> {
{Platform.OS === "android" && <FlagSecureComponent />}
<Navigation />
{shouldDisplayVersionInfoOverlay && <VersionInfoOverlay />}
{bpdTestOverlay && <BpdTestOverlay />}
<RootModal />
<LightModalRoot />
</Root>
Expand Down
4 changes: 4 additions & 0 deletions ts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ export const bonusVacanzeEnabled: boolean =
export const myPortalEnabled: boolean = Config.MYPORTAL_ENABLED === "YES";

export const bpdEnabled: boolean = Config.BPD_ENABLED === "YES";
export const bpdTestOverlay: boolean = Config.BPD_TEST_OVERLAY === "YES";

export const bpdApiUrlPrefix: string = Config.BPD_API_URL_PREFIX;

export const bpdApiSitUrlPrefix: string = Config.BPD_API_SIT;
export const bpdApiUatUrlPrefix: string = Config.BPD_API_UAT;

export const isPlaygroundsEnabled: boolean =
Config.PLAYGROUNDS_ENABLED === "YES";

Expand Down
73 changes: 73 additions & 0 deletions ts/features/bonus/bpd/components/BpdTestOverlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { View } from "native-base";
import { useState } from "react";
import * as React from "react";
import { Platform, StyleSheet } from "react-native";

import { getStatusBarHeight, isIphoneX } from "react-native-iphone-x-helper";
import { Body } from "../../../../components/core/typography/Body";
import { Label } from "../../../../components/core/typography/Label";
import {
bpdApiSitUrlPrefix,
bpdApiUatUrlPrefix,
bpdApiUrlPrefix,
bpdEnabled,
pagoPaApiUrlPrefix,
pagoPaApiUrlPrefixTest
} from "../../../../config";

const styles = StyleSheet.create({
versionContainer: {
position: "absolute",
top: Platform.select({
ios: 20 + (isIphoneX() ? getStatusBarHeight() : 0),
android: 0
}),
left: 0,
right: 0,
bottom: 0,
justifyContent: "flex-start",
alignItems: "center",
zIndex: 1000
},
versionText: {
padding: 2,
backgroundColor: "#ffffffaa"
}
});

/**
* Temp overlay created to avoid ambiguity when test bpd versions are released.
* TODO: remove after the release of bpd
* @constructor
*/
export const BpdTestOverlay: React.FunctionComponent = () => {
const [enabled, setEnabled] = useState(true);
const bpdEndpointStr =
bpdApiUrlPrefix === bpdApiSitUrlPrefix
? "SIT"
: bpdApiUrlPrefix === bpdApiUatUrlPrefix
? "UAT"
: "PROD";

const pmEndpointStr =
pagoPaApiUrlPrefix === pagoPaApiUrlPrefixTest ? "UAT" : "PROD";

return (
<View style={styles.versionContainer} pointerEvents="box-none">
{enabled ? (
<>
<Label
style={styles.versionText}
onPress={() => setEnabled(!enabled)}
>{`🛠️BPD TEST VERSION🛠️`}</Label>
<Body
style={styles.versionText}
onPress={() => setEnabled(!enabled)}
>{`${
bpdEnabled ? "active" : "not active"
} - bpd: ${bpdEndpointStr} - PM: ${pmEndpointStr}`}</Body>
</>
) : null}
</View>
);
};