Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Testversjonbanner #476

Merged
merged 5 commits into from
Aug 18, 2023
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
GRAFANA_AGENT_COLLECTOR_URL=http://localhost:12347/collect
PROD_URL=https://arbeidsgiver.nav.no/sykefravarsstatistikk
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions nais/dev-ekstern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}"
}
</script>
<title>Sykefraværsstatistikk</title>
Expand Down
5 changes: 5 additions & 0 deletions src/Banner/TestVersjonBanner.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.alert {
max-width: 60rem;
width: 100%;
margin: 0 auto 1.5rem auto;
}
33 changes: 33 additions & 0 deletions src/Banner/TestVersjonBanner.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Alert variant="warning" size="medium" className={styles.alert}>
<Heading spacing level="2" size="small">
Dette er en testversjon
</Heading>
<BodyShort>
Her kan du bli bedre kjent med samtalestøtte for arbeidsgiver.
{prodUrl?.length ? (
<Link href={prodUrl}>Klikk her for å gå til den vanlige siden.</Link>
) : null}
</BodyShort>
</Alert>
);
};

export default TestVersjonBanner;
5 changes: 5 additions & 0 deletions src/Context/EnvironmentContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof Data>;
Expand All @@ -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') {
Expand Down
3 changes: 3 additions & 0 deletions src/Forside/Forside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<SykefraværAppData> = (appData) => {
const orgnr = useOrgnr() || '';
Expand Down Expand Up @@ -51,6 +52,7 @@ export const Forside: FunctionComponent<SykefraværAppData> = (appData) => {
return (
<div className="forside__wrapper">
<div className="forside">
<TestVersjonBanner />
<div className="forside__innhold">
<div className="forside__innhold__header">
<BodyShort className="forside__innhold__href">
Expand Down Expand Up @@ -115,6 +117,7 @@ export const Forside: FunctionComponent<SykefraværAppData> = (appData) => {
return (
<div className="forside__wrapper">
<div className="forside">
<TestVersjonBanner />
<div className="forside__innhold" ref={innholdRef}>
{harFeil && (
<Alert
Expand Down