Skip to content

Commit

Permalink
#3994 - Non-Prod Environment Banners (#4252)
Browse files Browse the repository at this point in the history
**Acceptance Criteria:**
- [x] Add permanent banner at top of page for DEV, TEST and STG
environments
- [x] Copy: "Non-Production [environment] Environment"; bold and centred
- [x] Banner Color: #e3a82b (BC Gold)

**Technical**
- [x] Create a different banner/ribbon to be displayed above the top
navigation menu similar to the screenshot in the ACs.
- [x] Should be created on the main pages of the apps. If needed, create
a component to share it.
- [x] Create a new env variable to be added to GitHub `APP_ENV` or
similar to be used as a condition to display the banner.

Sample URL of height 18px top
https://logontest7.gov.bc.ca/clp-cgi/error.cgi

**DEMO**
1. APP_ENV=production

![image](https://github.com/user-attachments/assets/d1740285-bfa4-4fdd-8e38-d5f98f0ff8b5)
2. APP_ENV=dev/test/staging

![image](https://github.com/user-attachments/assets/ff5dab4f-ff6f-4677-bd22-d1937801d2c6)
bidyashish authored Jan 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent cdf5913 commit 7e018ba
Showing 18 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/release-deploy-all.yml
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ env:
MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER: ${{ vars.MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER }}
MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION: ${{ vars.MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION }}
MAXIMUM_IDLE_TIME_FOR_WARNING_AEST: ${{ vars.MAXIMUM_IDLE_TIME_FOR_WARNING_AEST }}
APP_ENV: ${{ vars.APP_ENV }}
TLS_CERTIFICATE: ${{ secrets.TLS_CERTIFICATE }}
TLS_KEY: ${{ secrets.TLS_KEY }}
TLS_CA_CERTIFICATE: ${{ secrets.TLS_CA_CERTIFICATE }}
3 changes: 3 additions & 0 deletions configs/env-example
Original file line number Diff line number Diff line change
@@ -170,3 +170,6 @@ MAXIMUM_IDLE_TIME_FOR_WARNING_AEST =

# Allow beta users only to access the system if true.
ALLOW_BETA_USERS_ONLY=

# App Environment
APP_ENV=
1 change: 1 addition & 0 deletions devops/Makefile
Original file line number Diff line number Diff line change
@@ -366,6 +366,7 @@ deploy-api:
-p MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER=$(MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER) \
-p MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION=$(MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION) \
-p MAXIMUM_IDLE_TIME_FOR_WARNING_AEST=$(MAXIMUM_IDLE_TIME_FOR_WARNING_AEST) \
-p APP_ENV=$(APP_ENV) \
-p TLS_CERTIFICATE=$(TLS_CERTIFICATE) \
-p TLS_KEY=$(TLS_KEY) \
-p TLS_CA_CERTIFICATE=$(TLS_CA_CERTIFICATE) \
4 changes: 4 additions & 0 deletions devops/openshift/api-deploy.yml
Original file line number Diff line number Diff line change
@@ -59,6 +59,8 @@ objects:
value: "${MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION}"
- name: MAXIMUM_IDLE_TIME_FOR_WARNING_AEST
value: "${MAXIMUM_IDLE_TIME_FOR_WARNING_AEST}"
- name: APP_ENV
value: "${APP_ENV}"
- name: ALLOW_BETA_USERS_ONLY
value: "${ALLOW_BETA_USERS_ONLY}"
- name: POSTGRES_HOST
@@ -527,6 +529,8 @@ parameters:
required: true
- name: MAXIMUM_IDLE_TIME_FOR_WARNING_AEST
required: true
- name: APP_ENV
required: true
- name: TLS_CERTIFICATE
required: true
- name: TLS_KEY
3 changes: 3 additions & 0 deletions sources/Makefile
Original file line number Diff line number Diff line change
@@ -86,6 +86,9 @@ export MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER := $(or $(MAXIMUM_IDLE_TIM
export MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION := $(or $(MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION), 3600)
export MAXIMUM_IDLE_TIME_FOR_WARNING_AEST := $(or $(MAXIMUM_IDLE_TIME_FOR_WARNING_AEST), 3600)

# App Environment
export APP_ENV := $(or $(APP_ENV), local)

# Allow beta users only to access the system if true.
export ALLOW_BETA_USERS_ONLY := $(or $(ALLOW_BETA_USERS_ONLY), false)

1 change: 1 addition & 0 deletions sources/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ services:
- MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER=${MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER}
- MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION=${MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION}
- MAXIMUM_IDLE_TIME_FOR_WARNING_AEST=${MAXIMUM_IDLE_TIME_FOR_WARNING_AEST}
- APP_ENV=${APP_ENV}
- ALLOW_BETA_USERS_ONLY=${ALLOW_BETA_USERS_ONLY}
ports:
- ${API_PORT}:${API_PORT}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ describe("ConfigController(e2e)-getConfig", () => {
MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER: "270",
MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION: "3600",
MAXIMUM_IDLE_TIME_FOR_WARNING_AEST: "3600",
APP_ENV: "production",
};

beforeAll(async () => {
@@ -65,6 +66,7 @@ describe("ConfigController(e2e)-getConfig", () => {
+fakeEnvVariables.MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION,
maximumIdleTimeForWarningAEST:
+fakeEnvVariables.MAXIMUM_IDLE_TIME_FOR_WARNING_AEST,
appEnv: fakeEnvVariables.APP_ENV,
});
});

Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ export class ConfigController extends BaseController {
this.configService.maximumIdleTimeForWarningInstitution,
maximumIdleTimeForWarningAEST:
this.configService.maximumIdleTimeForWarningAEST,
appEnv: this.configService.appEnv,
};
}
}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ export class ConfigAPIOutDTO {
maximumIdleTimeForWarningSupportingUser: number;
maximumIdleTimeForWarningInstitution: number;
maximumIdleTimeForWarningAEST: number;
appEnv: string;
}

export class AuthConfigAPIOutDTO {
Original file line number Diff line number Diff line change
@@ -155,6 +155,14 @@ export class ConfigService {
);
}

/**
* App environment.
* @returns app environment.
*/
get appEnv(): string {
return this.getCachedConfig("appEnvConfig", process.env.APP_ENV);
}

/**
* Maximum idle time for warning student Configuration.
* @returns maximum idle time for warning student number.
7 changes: 6 additions & 1 deletion sources/packages/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<v-app>
<environment-banner />
<snack-bar :snackBarOptions="snackBarOptions" />
<router-view></router-view>
</v-app>
@@ -9,9 +10,13 @@ import SnackBar from "@/components/generic/SnackBar.vue";
import { SnackBarOptions } from "@/types";
import { ref, defineComponent } from "vue";
import useEmitter from "@/composables/useEmitter";
import EnvironmentBanner from "@/components/common/EnvironmentBanner.vue";
export default defineComponent({
components: { SnackBar },
components: {
SnackBar,
EnvironmentBanner,
},
setup() {
const emitter = useEmitter();
const snackBarOptions = ref({} as SnackBarOptions);
9 changes: 9 additions & 0 deletions sources/packages/web/src/assets/css/base.scss
Original file line number Diff line number Diff line change
@@ -408,3 +408,12 @@ ul.no-bullets {
div.v-field__field input[type="date"] {
padding: 1rem;
}

.environment-banner {
text-align: center;
box-shadow: none !important;
.v-app-bar-title {
font-size: 16px;
@extend .font-bold;
}
}
35 changes: 35 additions & 0 deletions sources/packages/web/src/components/common/EnvironmentBanner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<v-app-bar
v-if="environment !== 'production'"
height="20"
color="#e3a82b"
class="environment-banner"
>
<v-app-bar-title>{{ bannerText }}</v-app-bar-title>
</v-app-bar>
</template>

<script lang="ts">
import { AppConfigService } from "@/services/AppConfigService";
import { defineComponent, computed, ref, onMounted } from "vue";
export default defineComponent({
setup() {
const environment = ref("");
onMounted(async () => {
// Get environment from env variable APP_ENV | dev, test, staging, production
const { appEnv } = await AppConfigService.shared.config();
environment.value = appEnv;
});
const bannerText = computed(() => {
return `Non-Production ${environment.value} Environment`;
});
return {
bannerText,
environment,
};
},
});
</script>
1 change: 1 addition & 0 deletions sources/packages/web/src/services/AppConfigService.ts
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ export class AppConfigService {
maximumIdleTimeForWarningInstitution:
config.maximumIdleTimeForWarningInstitution,
maximumIdleTimeForWarningAEST: config.maximumIdleTimeForWarningAEST,
appEnv: config.appEnv,
};
return appConfig;
}
1 change: 1 addition & 0 deletions sources/packages/web/src/services/http/dto/Config.dto.ts
Original file line number Diff line number Diff line change
@@ -15,4 +15,5 @@ export interface ConfigAPIOutDTO {
maximumIdleTimeForWarningSupportingUser: number;
maximumIdleTimeForWarningInstitution: number;
maximumIdleTimeForWarningAEST: number;
appEnv: string;
}
1 change: 1 addition & 0 deletions sources/packages/web/src/types/contracts/ConfigContract.ts
Original file line number Diff line number Diff line change
@@ -23,4 +23,5 @@ export interface AppConfig {
maximumIdleTimeForWarningSupportingUser: number;
maximumIdleTimeForWarningInstitution: number;
maximumIdleTimeForWarningAEST: number;
appEnv: string;
}
3 changes: 3 additions & 0 deletions sources/tests/Makefile
Original file line number Diff line number Diff line change
@@ -14,6 +14,9 @@ export MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER := $(or $(MAXIMUM_IDLE_TIME
export MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION :=$(or $(MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION), 3600)
export MAXIMUM_IDLE_TIME_FOR_WARNING_AEST := $(or $(MAXIMUM_IDLE_TIME_FOR_WARNING_AEST), 3600)

# App Environment
export APP_ENV := $(or $(APP_ENV), local)

export ALLOW_BETA_USERS_ONLY :=$(or $(ALLOW_BETA_USERS_ONLY), false)

backend-unit-tests:
1 change: 1 addition & 0 deletions sources/tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ services:
- MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER=${MAXIMUM_IDLE_TIME_FOR_WARNING_SUPPORTING_USER}
- MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION=${MAXIMUM_IDLE_TIME_FOR_WARNING_INSTITUTION}
- MAXIMUM_IDLE_TIME_FOR_WARNING_AEST=${MAXIMUM_IDLE_TIME_FOR_WARNING_AEST}
- APP_ENV=${APP_ENV}
- ALLOW_BETA_USERS_ONLY=${ALLOW_BETA_USERS_ONLY}
networks:
- local-network-tests

0 comments on commit 7e018ba

Please sign in to comment.