Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into dependencies-cleanup
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/client/package.json
  • Loading branch information
anders-nom committed May 16, 2024
2 parents c2303e1 + dcc455f commit d9bde1b
Show file tree
Hide file tree
Showing 14 changed files with 380 additions and 91 deletions.
8 changes: 0 additions & 8 deletions .nais/vars/dev-beta-navno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ env:
value: https://arbeidsgiver.intern.dev.nav.no/min-side-arbeidsgiver
- name: PERSONOPPLYSNINGER_URL
value: https://www.intern.dev.nav.no/person/personopplysninger
- name: CASETYPE_ID
value: "66D660EF-6F14-44B4-8ADE-A70A127202D0"
- name: NAV_GROUP_ID
value: "A034081B-6B73-46B7-BE27-23B8E9CE3079"
- name: OPPORTUNITY_ID
value: "615FF5E7-37B7-4697-A35F-72598B0DC53B"
- name: SOLUTION_ID
value: "5EB316A1-11E2-460A-B4E3-F82DBD13E21D"
- name: BOOST_ENVIRONMENT
value: "navtest"
replicas:
Expand Down
8 changes: 0 additions & 8 deletions .nais/vars/dev-beta-tms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ env:
value: https://arbeidsgiver.intern.dev.nav.no/min-side-arbeidsgiver
- name: PERSONOPPLYSNINGER_URL
value: https://www.intern.dev.nav.no/person/personopplysninger
- name: CASETYPE_ID
value: "66D660EF-6F14-44B4-8ADE-A70A127202D0"
- name: NAV_GROUP_ID
value: "A034081B-6B73-46B7-BE27-23B8E9CE3079"
- name: OPPORTUNITY_ID
value: "615FF5E7-37B7-4697-A35F-72598B0DC53B"
- name: SOLUTION_ID
value: "5EB316A1-11E2-460A-B4E3-F82DBD13E21D"
- name: BOOST_ENVIRONMENT
value: "navtest"
replicas:
Expand Down
8 changes: 0 additions & 8 deletions .nais/vars/dev-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ env:
value: https://arbeidsgiver.intern.dev.nav.no/min-side-arbeidsgiver
- name: PERSONOPPLYSNINGER_URL
value: https://www.intern.dev.nav.no/person/personopplysninger
- name: CASETYPE_ID
value: "66D660EF-6F14-44B4-8ADE-A70A127202D0"
- name: NAV_GROUP_ID
value: "A034081B-6B73-46B7-BE27-23B8E9CE3079"
- name: OPPORTUNITY_ID
value: "615FF5E7-37B7-4697-A35F-72598B0DC53B"
- name: SOLUTION_ID
value: "5EB316A1-11E2-460A-B4E3-F82DBD13E21D"
- name: BOOST_ENVIRONMENT
value: "navtest"
replicas:
Expand Down
8 changes: 0 additions & 8 deletions .nais/vars/dev-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ env:
value: https://arbeidsgiver.intern.dev.nav.no/min-side-arbeidsgiver
- name: PERSONOPPLYSNINGER_URL
value: https://www.intern.dev.nav.no/person/personopplysninger
- name: CASETYPE_ID
value: "66D660EF-6F14-44B4-8ADE-A70A127202D0"
- name: NAV_GROUP_ID
value: "A034081B-6B73-46B7-BE27-23B8E9CE3079"
- name: OPPORTUNITY_ID
value: "615FF5E7-37B7-4697-A35F-72598B0DC53B"
- name: SOLUTION_ID
value: "5EB316A1-11E2-460A-B4E3-F82DBD13E21D"
- name: BOOST_ENVIRONMENT
value: "navtest"
replicas:
Expand Down
8 changes: 0 additions & 8 deletions .nais/vars/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ env:
value: https://arbeidsgiver.nav.no/min-side-arbeidsgiver/
- name: PERSONOPPLYSNINGER_URL
value: https://www.nav.no/person/personopplysninger
- name: CASETYPE_ID
value: 66D660EF-6F14-44B4-8ADE-A70A127202D0
- name: NAV_GROUP_ID
value: A034081B-6B73-46B7-BE27-23B8E9CE3079
- name: OPPORTUNITY_ID
value: 615FF5E7-37B7-4697-A35F-72598B0DC53B
- name: SOLUTION_ID
value: 5EB316A1-11E2-460A-B4E3-F82DBD13E21D
- name: BOOST_ENVIRONMENT
value: "nav"
replicas:
Expand Down
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/lodash.debounce": "4.0.9",
"autoprefixer": "10.4.14",
"jsdom": "24.0.0",
"msw": "^2.3.0",
"postcss": "8.4.27",
"postcss-prefix-selector": "1.16.0",
"rollup-plugin-minify-html-literals-v3": "1.3.3",
Expand Down
25 changes: 18 additions & 7 deletions packages/client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,8 @@ export const CONTEXTS = [
"samarbeidspartner",
] as const;

const texts = window.__DECORATOR_DATA__.texts;

updateDecoratorParams({});

if (hasParam("logoutWarning")) {
logoutWarningController(param("logoutWarning"), texts);
}

window.addEventListener("paramsupdated", (e) => {
if (e.detail.params.language) {
Promise.all(
Expand Down Expand Up @@ -130,6 +124,23 @@ const init = async () => {
initAuth().then((auth) => {
initAnalytics(auth);
});

if (hasParam("logoutWarning")) {
logoutWarningController(
param("logoutWarning"),
window.__DECORATOR_DATA__.texts,
);
}
};

init();
async function enableMocking() {
if (process.env.NODE_ENV !== "development") {
return;
}

const { worker } = await import("./mocks");

return worker.start({ onUnhandledRequest: "bypass" });
}

enableMocking().then(() => init());
57 changes: 57 additions & 0 deletions packages/client/src/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { http, HttpResponse } from "msw";
import { setupWorker } from "msw/browser";

const now = () => new Date().toISOString();
const oneHourFromNow = () => {
const date = new Date();
date.setHours(date.getHours() + 1);
return date.toISOString();
};
const sixHoursFromNow = () => {
const date = new Date();
date.setHours(date.getHours() + 6);
return date.toISOString();
};

export const worker = setupWorker(
http.get("http://localhost:8089/api/oauth2/session", () =>
HttpResponse.json({
session: {
created_at: now(),
ends_at: sixHoursFromNow(),
timeout_at: oneHourFromNow(),
ends_in_seconds: 21600,
active: true,
timeout_in_seconds: 3600,
},
tokens: {
expire_at: oneHourFromNow(),
refreshed_at: now(),
expire_in_seconds: 3600,
next_auto_refresh_in_seconds: -1,
refresh_cooldown: true,
refresh_cooldown_seconds: 31,
},
}),
),
http.get("http://localhost:8089/api/oauth2/session/refresh", () =>
HttpResponse.json({
session: {
created_at: now(),
ends_at: sixHoursFromNow(),
timeout_at: oneHourFromNow(),
ends_in_seconds: 21600,
active: true,
timeout_in_seconds: 3600,
},
tokens: {
expire_at: oneHourFromNow(),
refreshed_at: now(),
expire_in_seconds: 3600,
next_auto_refresh_in_seconds: -1,
refresh_cooldown: true,
refresh_cooldown_seconds: 31,
},
}),
),
);
40 changes: 11 additions & 29 deletions packages/client/src/screensharing.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { Environment } from "decorator-shared/params";
import { loadExternalScript } from "./utils";

export const VNGAGE_ID = "83BD7664-B38B-4EEE-8D99-200669A32551" as const;

export const vendorScripts = {
skjermdeling: `https://account.psplugin.com/${VNGAGE_ID}/ps.js`,
} as const;

export type VngageStates = "InDialog" | "Ready";

export type VngageUserState = {
user: {
state: VngageStates; // probably more states but couldn't find documentation.
};
poi: unknown;
};
const loadScript = () =>
loadExternalScript(
"https://account.psplugin.com/83BD7664-B38B-4EEE-8D99-200669A32551/ps.js",
);

// @TODO: Use promise instead of callback?
let hasBeenOpened = false;
Expand All @@ -34,30 +23,23 @@ export function lazyLoadScreensharing(cb: () => void) {
hasBeenOpened = true;
};

loadExternalScript(vendorScripts.skjermdeling);
loadScript();
}

export function useLoadIfActiveSession({
userState,
}: {
userState: string | undefined;
}) {
export function useLoadIfActiveSession({ userState }: { userState?: string }) {
if (userState && userState !== "Ready") {
loadExternalScript(vendorScripts.skjermdeling);
loadScript();
}
}

const getEnvVar = (key: keyof Environment) =>
window.__DECORATOR_DATA__.env[key];

export function startCall(code: string) {
window.vngage.join("queue", {
opportunityId: getEnvVar("OPPORTUNITY_ID"),
solutionId: getEnvVar("SOLUTION_ID"),
caseTypeId: getEnvVar("CASETYPE_ID"),
opportunityId: "615FF5E7-37B7-4697-A35F-72598B0DC53B",
solutionId: "5EB316A1-11E2-460A-B4E3-F82DBD13E21D",
caseTypeId: "66D660EF-6F14-44B4-8ADE-A70A127202D0",
category: "Phone2Web",
message: "Phone2Web",
groupId: getEnvVar("NAV_GROUP_ID"),
groupId: "A034081B-6B73-46B7-BE27-23B8E9CE3079",
startCode: code,
});
}
4 changes: 0 additions & 4 deletions packages/server/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ DECORATOR_API_URL=http://localhost:8089/api
UNLEASH_SERVER_API_URL=http://localhost:8095/unleash
UNLEASH_SERVER_API_TOKEN=dummy_token

CASETYPE_ID=66D660EF-6F14-44B4-8ADE-A70A127202D0
NAV_GROUP_ID=A034081B-6B73-46B7-BE27-23B8E9CE3079
OPPORTUNITY_ID=615FF5E7-37B7-4697-A35F-72598B0DC53B
SOLUTION_ID=5EB316A1-11E2-460A-B4E3-F82DBD13E21D
BOOST_ENVIRONMENT=navtest
Loading

0 comments on commit d9bde1b

Please sign in to comment.