Skip to content

Commit

Permalink
Feature toggle for contextholder-next
Browse files Browse the repository at this point in the history
  • Loading branch information
LudvigHz committed Sep 25, 2024
1 parent 8e60dc8 commit 1e7bb96
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
<script env-vars prefix="PUBLIC_">
</script>

<script unleash toggles="modiapersonoversikt.enable-faro">
<script unleash
toggles="modiapersonoversikt.enable-faro,modiapersonoversikt.bruk-contextholder-next">
const applicationFeatureToggles = {
enableFaro: unleash && unleash["modiapersonoversikt_enable-faro"]
enableFaro: unleash && unleash["modiapersonoversikt_enable-faro"],
contextholderNext: unleash && unleash["modiapersonoversikt_bruk_contextholder_next"],
};
window.applicationFeatureToggles = applicationFeatureToggles;
</script>
Expand Down
1 change: 1 addition & 0 deletions src/app/internarbeidsflatedecorator/decoratorprops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ export interface DecoratorPropsV3 {
onEnhetChanged: (enhet?: string | null, enhetValue?: Enhet) => void;
onLinkClick?: (link: { text: string; url: string }) => void;
onFnrChanged: (fnr?: string | null) => void;
websocketUrl?: string | undefined;
}
12 changes: 7 additions & 5 deletions src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useGjeldendeBruker } from '../../redux/gjeldendeBruker/types';
import { getDomainFromHost, getEnvFromHost } from '../../utils/environment';
import { useRouteMatch } from 'react-router';
import config from '../../config';
import { getWindowFeature } from '../../utils/featureToggles';

export function useDecoratorConfig() {
const valgtEnhet = useValgtenhet();
Expand Down Expand Up @@ -79,6 +80,8 @@ function lagConfigV3(

const urlFormat = getDomainFromHost();

const brukNyContext = getWindowFeature('contextholderNext');

return {
appName: 'Modia personoversikt',
fnr: onsketFnr ?? undefined,
Expand All @@ -103,14 +106,13 @@ function lagConfigV3(
},
hotkeys: getHotkeys(),
enableHotkeys: true,
// modiacontextholder kjører på samme domene som modiapersonoversikt.
// Som default brukes app.adeo.no, så her tvinger vi dekoratøren over på nytt domene
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
proxy: import.meta.env.PROD
? `https://${window.location.host}${import.meta.env.BASE_URL}proxy/modiacontextholder`
: (import.meta.env.VITE_CONTEXTHOLDER_URL ?? `${import.meta.env.BASE_URL}proxy/modiacontextholder`),
: ((import.meta.env.VITE_CONTEXTHOLDER_URL as string) ??
`${import.meta.env.BASE_URL}proxy/modiacontextholder`),
environment,
urlFormat: import.meta.env.PROD ? urlFormat : 'LOCAL',
websocketUrl: brukNyContext ? 'wss://modiacontextholder-next.intern.dev.nav.no/ws/' : undefined,
showEnheter: true,
showSearchArea: true,
fetchActiveUserOnMount: true,
Expand All @@ -126,7 +128,7 @@ function getFnrFraUrl(): { sokFnr: string | null; userKey: string | null; urlFnr
const queryParams = parseQueryString<{ sokFnr?: string; userKey?: string }>(location.search);

return {
urlFnr,
urlFnr: urlFnr ?? null,
sokFnr: queryParams.sokFnr ?? null,
userKey: queryParams.userKey ?? null
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/featureToggle/toggleIDs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export enum FeatureToggles {
BrukNyDecorator = 'modiapersonoversikt.decorator-v3',
JournalforUtenSvar = 'modiapersonoversikt.meldinger-uten-svar-kan-journalfores',
VisDraftStatus = 'modiapersonoversikt.vis-draft-status',
BrukNyTiltakspenger = 'modiapersonoversikt.bruk-ny-tiltakspenger'
BrukNyTiltakspenger = 'modiapersonoversikt.bruk-ny-tiltakspenger',
BrukContextholderNext = 'modiapersonoversikt.bruk-contextholder-next'
}

0 comments on commit 1e7bb96

Please sign in to comment.