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(Carta Giovani Nazionale): [#177461712] Introduces the CGN Test overlay information #2934

Merged
merged 4 commits into from
Mar 24, 2021
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ BPD_API_SIT='https://bpd-dev.azure-api.net'
BPD_API_UAT='https://test.cstar.pagopa.it'
# CGN configuration
CGN_ENABLED=NO
CGN_TEST_OVERLAY=NO
# local services web url
LOCAL_SERVICE_WEB_URL='https://io.italia.it/app-content/enti-servizi.html'

Expand Down
1 change: 1 addition & 0 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ BPD_API_SIT='https://bpd-dev.azure-api.net'
BPD_API_UAT='https://test.cstar.pagopa.it'
# CGN configuration
CGN_ENABLED=NO
CGN_TEST_OVERLAY=NO
# local services web url
LOCAL_SERVICE_WEB_URL='http://127.0.0.1:3000/services_web_view'
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ BPD_API_SIT='https://bpd-dev.azure-api.net'
BPD_API_UAT='https://test.cstar.pagopa.it'
# CGN configuration
CGN_ENABLED=NO
CGN_TEST_OVERLAY=NO
# local services web url
LOCAL_SERVICE_WEB_URL='https://io.italia.it/app-content/enti-servizi.html'
8 changes: 7 additions & 1 deletion ts/RootContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import configurePushNotifications from "./boot/configurePushNotification";
import FlagSecureComponent from "./components/FlagSecure";
import { LightModalRoot } from "./components/ui/LightModal";
import VersionInfoOverlay from "./components/VersionInfoOverlay";
import { bpdTestOverlay, shouldDisplayVersionInfoOverlay } from "./config";
import {
bpdTestOverlay,
cgnTestOverlay,
shouldDisplayVersionInfoOverlay
} from "./config";
import { BpdTestOverlay } from "./features/bonus/bpd/components/BpdTestOverlay";
import Navigation from "./navigation";
import {
Expand All @@ -29,6 +33,7 @@ import { getNavigateActionFromDeepLink } from "./utils/deepLink";
import { setLocale } from "./i18n";
import RootModal from "./screens/modal/RootModal";
import { preferredLanguageSelector } from "./store/reducers/persistedPreferences";
import { CgnTestOverlay } from "./features/bonus/cgn/components/CgnTestOverlay";

type Props = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps;

Expand Down Expand Up @@ -141,6 +146,7 @@ class RootContainer extends React.PureComponent<Props> {
<Navigation />
{shouldDisplayVersionInfoOverlay && <VersionInfoOverlay />}
{bpdTestOverlay && <BpdTestOverlay />}
{cgnTestOverlay && <CgnTestOverlay />}
<RootModal />
<LightModalRoot />
</Root>
Expand Down
1 change: 1 addition & 0 deletions ts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const isPlaygroundsEnabled: boolean =

// CGN Feature Flag
export const cgnEnabled: boolean = Config.CGN_ENABLED === "YES";
export const cgnTestOverlay: boolean = Config.CGN_TEST_OVERLAY === "YES";

// version of ToS
export const tosVersion: NonNegativeNumber = 2.1 as NonNegativeNumber;
Expand Down
39 changes: 39 additions & 0 deletions ts/features/bonus/cgn/components/CgnTestOverlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { View } from "native-base";
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 { getAppVersion } from "../../../../utils/appVersion";

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 cgn versions are released.
* @constructor
*/
export const CgnTestOverlay: React.FunctionComponent = () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR lgtm
What do you think about a refactoring?
Since CGN e BPD use two custom components for the same scope, could it be only one instead?

something like this
<BetaTestingOverlay title="🛠️ CGN TEST VERSION 🛠️" body="some body"/>

We should always show the app version so that component should include it as a footer.
body prop could be an optional string

<View style={styles.versionContainer} pointerEvents="box-none">
    <Label style={styles.versionText}>{`TITLE`}</Label>
    <Body style={styles.versionText}>{"optional body"}</Body>
    <H5 style={styles.versionText}>{`${getAppVersion()}`}</H5>
  </View>

Schermata 2021-03-24 alle 14 54 28

cc @fabriziofff

<View style={styles.versionContainer} pointerEvents="box-none">
<Label style={styles.versionText}>{`🛠️ CGN TEST VERSION 🛠️`}</Label>
<Body style={styles.versionText}>{`${getAppVersion()}`}</Body>
</View>
);