Skip to content

Commit

Permalink
Merge pull request #2182 from navikt/draft-gcp
Browse files Browse the repository at this point in the history
Bruk ny draft i gcp i prod
  • Loading branch information
LudvigHz authored Jun 5, 2024
2 parents 6f187f6 + 7b8dcab commit dd67fe7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions proxy-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
{
"prefix": "proxy/modia-draft",
"url": "http://modiapersonoversikt-draft.personoversikt.svc.nais.local/modiapersonoversikt-draft",
"rewriteDirectives": ["SET_ON_BEHALF_OF_TOKEN prod-fss personoversikt modiapersonoversikt-draft"]
"url": "https://modiapersonoversikt-draft.intern.nav.no",
"rewriteDirectives": ["SET_ON_BEHALF_OF_TOKEN prod-gcp personoversikt modiapersonoversikt-draft"]
},
{
"prefix": "proxy/modia-innstillinger",
Expand Down
16 changes: 1 addition & 15 deletions src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { trackNavigation, updateUserEnhet } from '../../utils/amplitude';
import { useCallback } from 'react';
import { DecoratorPropsV3, Hotkey } from './decoratorprops';
import { useGjeldendeBruker } from '../../redux/gjeldendeBruker/types';
import { getEnvFromHost } from '../../utils/environment';

export function useDecoratorConfig() {
const valgtEnhet = useValgtenhet();
Expand Down Expand Up @@ -72,21 +73,6 @@ function lagConfigV3(
const { sokFnr, userKey } = getFnrFraUrl();
const fnr = useGjeldendeBruker();
const onsketFnr = sokFnr ?? fnr;
const getEnvFromHost = () => {
switch (window.location.host) {
case 'app.adeo.no':
case 'modiapersonoversikt.intern.nav.no':
return 'prod';
case 'app-q1.adeo.no':
return 'q1';
case 'app-q0.adeo.no':
return 'q0';
case 'modiapersonoversikt.intern.dev.nav.no':
return 'q2';
}
return 'mock';
};

const environment = import.meta.env.PROD ? getEnvFromHost() : 'mock';

return {
Expand Down
14 changes: 12 additions & 2 deletions src/app/personside/dialogpanel/use-draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import debounce from 'lodash.debounce';
import { loggError, loggInfo } from '../../../utils/logger/frontendLogger';
import WebSocketImpl, { Status } from '../../../utils/websocket-impl';
import { FetchError } from '../../../api/api';
import { getEnvFromHost } from '../../../utils/environment';

export interface DraftContext {
[key: string]: string;
Expand All @@ -28,6 +29,16 @@ interface WsEvent {

const okCloseCodes = Object.values(WebSocketImpl.Codes);

const getWsUrl = () => {
const env = getEnvFromHost();
switch (env) {
case 'prod':
return 'modiapersonoversikt-draft.intern.nav.no';
default:
return 'modiapersonoversikt-draft.intern.dev.nav.no';
}
};

function useDraft(context: DraftContext, ifPresent: (draft: Draft) => void = () => {}): DraftSystem {
const wsRef = useRef<WebSocketImpl>();
useEffect(() => {
Expand All @@ -38,8 +49,7 @@ function useDraft(context: DraftContext, ifPresent: (draft: Draft) => void = ()
return '\u0000';
} else {
const uuid: string = await response.json();
const loc = window.location;
return `wss://${loc.host}/modiapersonoversikt-draft/api/draft/ws/${uuid}`;
return `wss://${getWsUrl()}/api/draft/ws/${uuid}`;
}
};
wsRef.current = new WebSocketImpl(urlProvider, {
Expand Down
15 changes: 15 additions & 0 deletions src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ export function isTest(): boolean {
export function isDevelopment(): boolean {
return environment === 'development';
}

export const getEnvFromHost = () => {
switch (window.location.host) {
case 'app.adeo.no':
case 'modiapersonoversikt.intern.nav.no':
return 'prod';
case 'app-q1.adeo.no':
return 'q1';
case 'app-q0.adeo.no':
return 'q0';
case 'modiapersonoversikt.intern.dev.nav.no':
return 'q2';
}
return 'mock';
};

0 comments on commit dd67fe7

Please sign in to comment.