From 794a6e51ab9f9128715715f75074e99bca82850b Mon Sep 17 00:00:00 2001 From: Sverre Blekastad Stensby Date: Wed, 16 Aug 2023 15:28:32 +0200 Subject: [PATCH 1/5] La til TestVersjonBanner med lenke til prod. --- .env.example | 3 ++- nais/dev-ekstern.yaml | 2 ++ public/index.html | 3 ++- src/Banner/TestVersjonBanner.module.css | 5 ++++ src/Banner/TestVersjonBanner.tsx | 33 +++++++++++++++++++++++++ src/Context/EnvironmentContext.ts | 5 ++++ src/Forside/Forside.tsx | 3 +++ 7 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/Banner/TestVersjonBanner.module.css create mode 100644 src/Banner/TestVersjonBanner.tsx diff --git a/.env.example b/.env.example index a3490741..f5b10bb6 100644 --- a/.env.example +++ b/.env.example @@ -5,4 +5,5 @@ DEKORATOR_URL=https://dekoratoren.ekstern.dev.nav.no MILJO=local MIN_SIDE_ARBEIDSGIVER_URL=https://arbeidsgiver.ekstern.dev.nav.no/min-side-arbeidsgiver FOREBYGGE_FRAVAR_URL=https://arbeidsgiver.ekstern.dev.nav.no/forebygge-fravar -GRAFANA_AGENT_COLLECTOR_URL=http://localhost:12347/collect \ No newline at end of file +GRAFANA_AGENT_COLLECTOR_URL=http://localhost:12347/collect +PROD_URL=https://arbeidsgiver.nav.no/sykefravarsstatistikk \ No newline at end of file diff --git a/nais/dev-ekstern.yaml b/nais/dev-ekstern.yaml index 9d2a34a2..3add7e6a 100644 --- a/nais/dev-ekstern.yaml +++ b/nais/dev-ekstern.yaml @@ -36,6 +36,8 @@ spec: value: https://arbeidsgiver.ekstern.dev.nav.no/min-side-arbeidsgiver - name: FOREBYGGE_FRAVAR_URL value: https://arbeidsgiver.ekstern.dev.nav.no/forebygge-fravar + - name: PROD_URL + value: https://arbeidsgiver.nav.no/sykefravarsstatistikk accessPolicy: outbound: external: diff --git a/public/index.html b/public/index.html index 5d1f2c0e..5d822148 100644 --- a/public/index.html +++ b/public/index.html @@ -10,7 +10,8 @@ { "MILJØ": "{{MILJO}}", "MIN_SIDE_ARBEIDSGIVER_URL": "{{{MIN_SIDE_ARBEIDSGIVER_URL}}}", - "GRAFANA_AGENT_COLLECTOR_URL": "{{{GRAFANA_AGENT_COLLECTOR_URL}}}" + "GRAFANA_AGENT_COLLECTOR_URL": "{{{GRAFANA_AGENT_COLLECTOR_URL}}}", + "PROD_URL": {{{PROD_URL}}}, } Sykefraværsstatistikk diff --git a/src/Banner/TestVersjonBanner.module.css b/src/Banner/TestVersjonBanner.module.css new file mode 100644 index 00000000..214d61d1 --- /dev/null +++ b/src/Banner/TestVersjonBanner.module.css @@ -0,0 +1,5 @@ +.alert { + max-width: 60rem; + width: 100%; + margin: 0 auto 1.5rem auto; +} diff --git a/src/Banner/TestVersjonBanner.tsx b/src/Banner/TestVersjonBanner.tsx new file mode 100644 index 00000000..740fce4c --- /dev/null +++ b/src/Banner/TestVersjonBanner.tsx @@ -0,0 +1,33 @@ +import { Alert, BodyShort, Heading, Link } from '@navikt/ds-react'; +import styles from './TestVersjonBanner.module.css'; +import { EnvironmentContext } from '../Context/EnvironmentContext'; +import { useContext } from 'react'; +import { MILJØ } from '../konstanter'; + +const TestVersjonBanner = () => { + const { PROD_URL, MILJØ: miljø } = useContext(EnvironmentContext); + const erPåDevEllerLocal = miljø === MILJØ.DEV_EKSTERN || miljø === MILJØ.LOCAL; + + const prodUrl = + PROD_URL?.length && !PROD_URL.startsWith('{{{') && !PROD_URL.endsWith('}}}') + ? PROD_URL + : null; + + if (!erPåDevEllerLocal) return null; + + return ( + + + Dette er en testversjon + + + Her kan du bli bedre kjent med siden Samtalestøtte for arbeidsgiver. + {prodUrl?.length ? ( + Klikk her for å gå til den vanlige siden. + ) : null} + + + ); +}; + +export default TestVersjonBanner; diff --git a/src/Context/EnvironmentContext.ts b/src/Context/EnvironmentContext.ts index 02f264e8..9847516b 100644 --- a/src/Context/EnvironmentContext.ts +++ b/src/Context/EnvironmentContext.ts @@ -5,11 +5,15 @@ import { MILJØ } from '../konstanter'; const notEmptyTemplateString = z .string() .refine((value) => !value.startsWith('{{') || !value.endsWith('}}')); +const optionalTemplateString = z.optional( + z.string().refine((value) => !value.startsWith('{{') || !value.endsWith('}}')) +); const Data = z.object({ MILJØ: notEmptyTemplateString.refine((value) => isMiljø(value)), MIN_SIDE_ARBEIDSGIVER_URL: notEmptyTemplateString, GRAFANA_AGENT_COLLECTOR_URL: notEmptyTemplateString, + PROD_URL: optionalTemplateString, }); type Data = z.infer; @@ -25,6 +29,7 @@ const fallbackData: Data = { MILJØ: MILJØ.LOCAL, MIN_SIDE_ARBEIDSGIVER_URL: '', GRAFANA_AGENT_COLLECTOR_URL: '', + PROD_URL: 'https://arbeidsgiver.nav.no/sykefravarsstatistikk', }; export const getEnvironmentContext = (): Data => { if (typeof document === 'undefined') { diff --git a/src/Forside/Forside.tsx b/src/Forside/Forside.tsx index a712d2e2..25e6395f 100644 --- a/src/Forside/Forside.tsx +++ b/src/Forside/Forside.tsx @@ -16,6 +16,7 @@ import Tabell, { hentTabellProps } from '../Historikk/Tabell/Tabell'; import { SlikHarViKommetFramTilDittResultat } from './SlikHarViKommetFramTilDittResultat/SlikHarViKommetFramTilDittResultat'; import { PeriodeForStatistikk } from './PeriodeForStatistikk'; import { PubliseringsdatoOppdateringsinfo } from './PubliseringsdatoOppdateringsinfo'; +import TestVersjonBanner from '../Banner/TestVersjonBanner'; export const Forside: FunctionComponent = (appData) => { const orgnr = useOrgnr() || ''; @@ -51,6 +52,7 @@ export const Forside: FunctionComponent = (appData) => { return (
+
@@ -115,6 +117,7 @@ export const Forside: FunctionComponent = (appData) => { return (
+
{harFeil && ( Date: Thu, 17 Aug 2023 12:39:41 +0200 Subject: [PATCH 2/5] Deploy to dev --- .github/workflows/build-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build-deploy.yaml index 1e5f1545..6e340eda 100644 --- a/.github/workflows/build-deploy.yaml +++ b/.github/workflows/build-deploy.yaml @@ -50,7 +50,7 @@ jobs: deploy-to-dev-gcp: name: Deploy to dev-gcp - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/test-versjon-banner' needs: docker-build-push runs-on: ubuntu-latest timeout-minutes: 5 From 01adb9f7851d467d9e4db082ce31bbfc270d03c6 Mon Sep 17 00:00:00 2001 From: Sverre Blekastad Stensby Date: Thu, 17 Aug 2023 12:41:36 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Endret=20tekst=20i=20testbanner=20for=20?= =?UTF-8?q?=C3=A5=20formulere=20uten=20=C3=A5=20bruke=20sidenavn=20som=20e?= =?UTF-8?q?gennavn.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Banner/TestVersjonBanner.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Banner/TestVersjonBanner.tsx b/src/Banner/TestVersjonBanner.tsx index 740fce4c..0c9fd393 100644 --- a/src/Banner/TestVersjonBanner.tsx +++ b/src/Banner/TestVersjonBanner.tsx @@ -21,7 +21,7 @@ const TestVersjonBanner = () => { Dette er en testversjon - Her kan du bli bedre kjent med siden Samtalestøtte for arbeidsgiver. + Her kan du bli bedre kjent med samtalestøtte for arbeidsgiver. {prodUrl?.length ? ( Klikk her for å gå til den vanlige siden. ) : null} From f0fa277dffdd91ef1235a6006068d2dc80e8dd50 Mon Sep 17 00:00:00 2001 From: Sverre Blekastad Stensby Date: Thu, 17 Aug 2023 13:11:35 +0200 Subject: [PATCH 4/5] Fixed an issue with produrl breaking environment variables. --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 5d822148..ab373b66 100644 --- a/public/index.html +++ b/public/index.html @@ -11,7 +11,7 @@ "MILJØ": "{{MILJO}}", "MIN_SIDE_ARBEIDSGIVER_URL": "{{{MIN_SIDE_ARBEIDSGIVER_URL}}}", "GRAFANA_AGENT_COLLECTOR_URL": "{{{GRAFANA_AGENT_COLLECTOR_URL}}}", - "PROD_URL": {{{PROD_URL}}}, + "PROD_URL": "{{{PROD_URL}}}", } Sykefraværsstatistikk From 16eb2beb3eb0878d52bdb1cc1390bf63a8af6cb3 Mon Sep 17 00:00:00 2001 From: Sverre Blekastad Stensby Date: Thu, 17 Aug 2023 13:48:05 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Pr=C3=B8ver=20=C3=A5=20fikse=20json=20med?= =?UTF-8?q?=20env-variabler.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index ab373b66..faa3854d 100644 --- a/public/index.html +++ b/public/index.html @@ -11,7 +11,7 @@ "MILJØ": "{{MILJO}}", "MIN_SIDE_ARBEIDSGIVER_URL": "{{{MIN_SIDE_ARBEIDSGIVER_URL}}}", "GRAFANA_AGENT_COLLECTOR_URL": "{{{GRAFANA_AGENT_COLLECTOR_URL}}}", - "PROD_URL": "{{{PROD_URL}}}", + "PROD_URL": "{{{PROD_URL}}}" } Sykefraværsstatistikk