Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/dependencies/portal #992

Merged
merged 11 commits into from
Nov 3, 2023
2 changes: 1 addition & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '18'
registry-url: https://registry.npmjs.org

- name: Install Node Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- uses: actions/checkout@v2

Expand Down
20,593 changes: 13,453 additions & 7,140 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@equinor/fusion-cli",
"description": "A cli for creating, starting, building, deploying and publishing Fusion apps and tiles",
"version": "3.1.0",
"version": "3.1.1-beta.3",
"author": "Fusion Core",
"bin": {
"fusion": "bin/run"
Expand All @@ -16,11 +16,12 @@
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@babel/runtime": "^7.15.4",
"@equinor/fusion-framework-legacy-interopt": "^4.0.9",
"@equinor/fusion-react-context-selector": "^0.4.3",
"@equinor/fusion-react-person": "^0.2.1",
"@equinor/fusion-react-progress-indicator": "0.1.6",
"@equinor/fusion-react-styles": "^0.5.6",
"@equinor/fusion-framework-legacy-interopt": "^7.0.2",
"@equinor/fusion-framework-react-components-people-provider": "^1.1.2",
"@equinor/fusion-react-context-selector": "^0.5.1",
"@equinor/fusion-react-person": "^0.6.0",
"@equinor/fusion-react-progress-indicator": "0.2.0",
"@equinor/fusion-react-styles": "^0.6.0",
"@equinor/fusion-react-tooltip": "^1.1.5",
"@hot-loader/react-dom": "^17.0.1",
"@oclif/command": "^1.8.0",
Expand Down Expand Up @@ -65,8 +66,8 @@
},
"peerDependencies": {
"@equinor/eslint-config-fusion": "^0.0.0 || ^2.0.0",
"@equinor/fusion": "^3.3.19",
"@equinor/fusion-components": "^2.5.28",
"@equinor/fusion": "^3.4.11",
"@equinor/fusion-components": "^2.12.1",
"@equinor/fusion-framework-react": ">=4",
"@types/react": "^17.0.0 || ^18.0.0",
"@types/react-dom": "^17.0.0 || ^18.0.0",
Expand Down Expand Up @@ -112,15 +113,15 @@
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.16.0",
"@equinor/eslint-config-fusion": "^2.0.0",
"@equinor/fusion": "^3.4.10",
"@equinor/fusion-components": "^2.10.8",
"@equinor/fusion-framework-app": "^7.0.13",
"@equinor/fusion-framework-module-app": "^5.1.1",
"@equinor/fusion-framework-module-navigation": "^2.1.1",
"@equinor/fusion-framework-react": "^5.1.2",
"@equinor/fusion-framework-react-app": "^4.0.14",
"@equinor/fusion-observable": "^8.0.1",
"@equinor/eslint-config-fusion": "^2.1.5",
"@equinor/fusion": "^3.4.11",
"@equinor/fusion-components": "^2.12.1",
"@equinor/fusion-framework-app": "^7.1.8",
"@equinor/fusion-framework-module-app": "^5.2.8",
"@equinor/fusion-framework-module-navigation": "^3.1.2",
"@equinor/fusion-framework-react": "^5.3.3",
"@equinor/fusion-framework-react-app": "^4.1.13",
"@equinor/fusion-observable": "^8.1.2",
"@oclif/dev-cli": "^1.26.0",
"@oclif/test": "^1.2.8",
"@types/archiver": "^5.1.1",
Expand All @@ -144,7 +145,7 @@
"history": "^4.10.1",
"mocha": "^9.1.1",
"nyc": "^15.1.0",
"prettier": "^2.4.0",
"prettier": "^3.0.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-loader": "^4.13.0",
Expand Down
6 changes: 3 additions & 3 deletions src/start-app/AppLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useState, useEffect, useMemo, useCallback, Suspense } from 'react';
import { useFusionContext, AppManifest, Context } from '@equinor/fusion';

import { ErrorMessage, ErrorBoundary } from '@equinor/fusion-components';
import { ErrorBoundary } from '@equinor/fusion-components';
import { Loader } from './Loader';

import { useFramework } from '@equinor/fusion-framework-react';
Expand Down Expand Up @@ -56,6 +56,7 @@ export const AppLoader = (): JSX.Element => {
* in the future there should be a semver of the modules and do check by satisfaction
*/
const navigation = new NavigationProvider({
version: '0.0.1',
config: {
basename: '/',
history: modules.navigation.navigator
Expand Down Expand Up @@ -165,8 +166,7 @@ export const AppLoader = (): JSX.Element => {
const render =
appManifest.render ??
createLegacyRender(
appManifest.key,
(appManifest.AppComponent as unknown) as React.FunctionComponent,
appManifest,
fusionLegacyContext
);
// @ts-ignore
Expand Down
7 changes: 4 additions & 3 deletions src/start-app/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import { FusionHeader, FusionContent } from '@equinor/fusion-components';

import { AppLoader } from './AppLoader';
import { ContextSelector } from './components/ContextSelector';
import { PersonResolver } from './components/PersonResolver/PersonResolver';
import { Loader } from './Loader';

import { PeopleResolverProvider } from '@equinor/fusion-framework-react-components-people-provider';

export const Portal = (): JSX.Element => {
const framework = useFramework<[AppModule, NavigationModule]>();
return (
<ThemeProvider theme={theme}>
<PersonResolver>
<PeopleResolverProvider>
<LegacyFusionWrapper
framework={framework}
loader={<Loader />}
Expand All @@ -33,7 +34,7 @@ export const Portal = (): JSX.Element => {
<AppLoader />
</FusionContent>
</LegacyFusionWrapper>
</PersonResolver>
</PeopleResolverProvider>
</ThemeProvider>
);
};
Expand Down
55 changes: 23 additions & 32 deletions src/start-app/components/PersonResolver/usePersonResolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,40 @@ const createPersonClient = (client: IHttpClient) => {
// TODO - good cache amount? 3min?
const expire = 3 * 60 * 1000;
const queryDetails = new Query({
expire,
queueOperator: 'merge',
key: (azureId) => azureId,
client: {
fn: async (azureId: string) => {
const user = await client.json<PersonDetails>(`/persons/${azureId}?api-version=4.0&$expand=positions,manager`);

try {
const image = await client.json<string>(`/persons/${azureId}/photo?api-version=1.0`);
asbjornhaland marked this conversation as resolved.
Show resolved Hide resolved
user.pictureSrc = image;
} catch (error) {
// for default image (user.pictureSrc = '/images/profiles/');
console.error(error);
}

return user;
expire,
queueOperator: 'merge',
key: (azureId) => azureId,
client: {
fn: (azureId: string) => {
return client.json<PersonDetails>(`/persons/${azureId}?api-version=4.0`);
asbjornhaland marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
});

const queryPresence = new Query({
expire,
queueOperator: 'merge',
key: (azureId) => azureId,
client: {
fn: (azureId: string) => client.json<PersonPresence>(`/persons/${azureId}/presence?api-version=1.0`),
},
expire,
queueOperator: 'merge',
key: (azureId) => azureId,
client: {
fn: (azureId: string) =>
client.json<PersonPresence>(`/persons/${azureId}/presence?api-version=1.0`),
},
});

return {
getDetails: (azureId: string) => queryDetails.queryAsync(azureId).then((x) => x.value),
getPresence: (azureId: string) => queryPresence.queryAsync(azureId).then((x) => x.value),
getDetails: (azureId: string) => queryDetails.queryAsync(azureId).then((x) => x.value),
getPresence: (azureId: string) => queryPresence.queryAsync(azureId).then((x) => x.value),
};
};

export const usePersonResolver = (): PersonResolver => {
const [resolver, setResolver] = useState<PersonResolver | undefined>(undefined);
export const usePersonResolver = () => {
const [resolver, setResolver] = useState<any | undefined>(undefined);
const framework = useFramework();
useMemo(() => {
framework.modules.serviceDiscovery
.createClient('people')
.then((httpClient) => createPersonClient(httpClient))
.then(setResolver);
framework.modules.serviceDiscovery
.createClient('people')
.then((httpClient) => createPersonClient(httpClient))
.then(setResolver);
}, [framework]);
return resolver as PersonResolver;
return resolver;
};
Loading