Skip to content

Commit

Permalink
Merge branch 'feature/fusion-apps-service-migration' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/equinor/fusion-project-portal into feature/fusion-apps-service-migration
  • Loading branch information
kjetilhau committed Oct 15, 2024
2 parents 7e0f184 + af7bb96 commit 348def9
Show file tree
Hide file tree
Showing 62 changed files with 164 additions and 165 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
"@types/react-router-dom": "^5.3.3",
"vite-plugin-static-copy": "^0.17.0"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "npx lerna run serve",
"build": "npx lerna run build",
"build:apps": "npx lerna run build:apps",
"build:appLoader": "npx lerna run build:appLoader",
"test:all": "test:coverage && build:coverage",
"test": "lerna run test",
"test:coverage": "lerna run test:coverage",
Expand All @@ -19,6 +20,7 @@
},
"private": true,
"devDependencies": {
"@equinor/fusion-framework-cli": "^10.0.0-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4",
"@hirez_io/observer-spy": "^2.2.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
Expand All @@ -28,8 +30,8 @@
"@types/jsdom": "^21.1.5",
"@types/luxon": "^3.2.0",
"@types/marked": "^4.0.1",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.0",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
Expand Down Expand Up @@ -95,8 +97,8 @@
"luxon": "^3.2.1",
"marked": "^4.2.5",
"re-resizable": "^6.9.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.0.12",
"react-hook-form": "^7.48.2",
"react-query": "^3.39.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tokens } from '@equinor/eds-tokens';
import { SkeletonSize, SkeletonVariant } from '@equinor/fusion-react-skeleton';
import { AppCardType } from '../../types/types';
import { defaultIcon } from './defaultIcon';
import { AppManifest } from '../../types/types';
import { AppManifest } from '@portal/core';

const primaryColor = tokens.colors.interactive.primary__resting.hex;

Expand Down Expand Up @@ -102,7 +102,11 @@ type AppIconProps = {

export const AppIconContainer = ({ app, display, loading }: AppIconProps): JSX.Element => {
const appCategoryIcon = app.category ? app.category.defaultIcon : defaultIcon;
const appIcon = app.icon ? (app.icon !== '' ? app.icon : appCategoryIcon) : appCategoryIcon;
const appIcon = app.visualization?.icon
? app.visualization.icon !== ''
? app.visualization.icon
: appCategoryIcon
: appCategoryIcon;

if (loading) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Icon } from '@equinor/eds-core-react';
import { star_filled, star_outlined } from '@equinor/eds-icons';
import { Skeleton, SkeletonSize, SkeletonVariant } from '@equinor/fusion-react-skeleton';

import { AppManifest } from '../../types/types';
import { AppManifest } from '@portal/core';

const pinnIconSize = 1.5;

Expand All @@ -25,7 +25,7 @@ export const Styled = {
cursor: pointer;
}
`,
PinIconOut: styled(Icon)<{ isPinned?: boolean }>`
PinIconOut: styled(Icon)<{ isPinned?: boolean | null }>`
${({ isPinned }) => {
if (isPinned) {
return css`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { tokens } from '@equinor/eds-tokens';
import { AppManifest } from '@portal/core';

export const getAppCardColor = (app: {
color?: string | null;
isDisabled?: boolean;
category?: { color?: string | null };
}) => {
export const getAppCardColor = (app: Partial<AppManifest>) => {
const appColor = app.isDisabled
? tokens.colors.interactive.disabled__text.hex
: app.category?.color || tokens.colors.interactive.primary__resting.hex;
Expand Down
8 changes: 6 additions & 2 deletions client/packages/components/src/components/app-search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ export const getGreeting = () => {
};

export const getSearchAppIcon = (app: AppManifest): string => {
const appIcon = app.icon ? (app.icon !== '' ? app.icon : app.category?.defaultIcon) : app.category?.defaultIcon;
const appColor = app.accentColor || app.category?.color || '#000000';
const appIcon = app.visualization?.icon
? app.visualization?.icon !== ''
? app.visualization?.icon
: app.category?.defaultIcon
: app.category?.defaultIcon;
const appColor = app.visualization?.color || app.category?.color || '#000000';

const searchIconStyles = {
display: 'flex',
Expand Down
45 changes: 16 additions & 29 deletions client/packages/core/src/app/hooks/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { vi } from 'vitest';

import { AppManifest, AppModuleProvider } from '@equinor/fusion-framework-module-app';
import { AppConfig, AppManifest, AppModuleProvider } from '@equinor/fusion-framework-module-app';
import { BehaviorSubject } from 'rxjs';

const config = {
const config: AppConfig = {
environment: {
env: 'test',
},
endpoints: {
home: '/',
},
endpoints: {},
};
export const getAppConfigMock = vi.fn();
export const getAppManifestMock = vi.fn();
Expand All @@ -18,33 +17,21 @@ export const getAppManifestsMock = vi.fn();
export const appProvider = new AppModuleProvider({
config: {
client: {
getAppConfig: {
client: {
fn: () => {
getAppConfigMock();
return new BehaviorSubject(config);
},
},
key: ({ appKey }) => appKey,
},
getAppManifest: {
client: {
fn: ({ appKey }) => {
getAppManifestMock();
return new BehaviorSubject({
key: appKey,
name: 'testName',
} as AppManifest);
},
},
key: () => 'getAppManifest',
[Symbol.dispose]: vi.fn(),

getAppConfig: () => {
getAppConfigMock();
return new BehaviorSubject<AppConfig<any>>(config);

Check warning on line 24 in client/packages/core/src/app/hooks/mocks.ts

View workflow job for this annotation

GitHub Actions / Open Pull Request (21.x)

Unexpected any. Specify a different type
},
getAppManifests: {
client: {
fn: getAppManifestsMock,
},
key: () => 'getAppManifests',
getAppManifest: ({ appKey }) => {
getAppManifestMock();
return new BehaviorSubject({
key: appKey,
name: 'testName',
} as AppManifest);
},

getAppManifests: getAppManifestsMock,
},
},
});
1 change: 1 addition & 0 deletions client/packages/core/src/app/hooks/use-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const useAppLoader = (appKey: string) => {
error: (err) => {
console.error('App init Error: ', error);
setError(err);
setLoading(false);
},
})
);
Expand Down
60 changes: 24 additions & 36 deletions client/packages/core/src/app/hooks/use-current-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import { act, renderHook } from '@testing-library/react';

import { useCurrentApp } from './use-current-app';

import { AppManifest, AppModuleProvider } from '@equinor/fusion-framework-module-app';
import { AppConfig, AppManifest, AppModuleProvider, IAppClient } from '@equinor/fusion-framework-module-app';
import { BehaviorSubject } from 'rxjs';

const config = {
const config: AppConfig = {
environment: {
env: 'test',
},
endpoints: {
home: '/',
},
endpoints: {},
};
export const getAppConfigMock = vi.fn();
export const getAppManifestMock = vi.fn();
Expand All @@ -22,32 +21,21 @@ export const getAppManifestsMock = vi.fn();
export const appProvider = new AppModuleProvider({
config: {
client: {
getAppConfig: {
client: {
fn: () => {
getAppConfigMock();
return new BehaviorSubject(config);
},
},
key: ({ appKey }) => appKey,
[Symbol.dispose]: vi.fn(),
getAppManifest: ({ appKey }) => {
getAppManifestMock();
return new BehaviorSubject({
appKey: appKey,
displayName: 'testName',
} as AppManifest);
},
getAppManifest: {
client: {
fn: ({ appKey }) => {
getAppManifestMock();
return new BehaviorSubject({
key: appKey,
name: 'testName',
} as AppManifest);
},
},
key: () => 'getAppManifest',
getAppManifests: () => {
getAppManifestsMock();
return new BehaviorSubject([] as AppManifest[]);
},
getAppManifests: {
client: {
fn: getAppManifestsMock,
},
key: () => 'getAppManifests',
getAppConfig: () => {
getAppConfigMock();
return new BehaviorSubject<AppConfig<any>>(config);

Check warning on line 38 in client/packages/core/src/app/hooks/use-current-app.test.ts

View workflow job for this annotation

GitHub Actions / Open Pull Request (21.x)

Unexpected any. Specify a different type
},
},
},
Expand All @@ -65,14 +53,14 @@ describe('use-current-app', () => {
});
expect(result.current?.appKey).toEqual('test');
});
test('result - loadConfig', () => {
const { result } = renderHook(() => useCurrentApp(appProvider));
act(() => {
appProvider.setCurrentApp('test');
});
result.current?.loadConfig();
expect(getAppConfigMock).toBeCalled();
});
// test('result - loadConfig', () => {
// const { result } = renderHook(() => useCurrentApp(appProvider));
// act(() => {
// appProvider.setCurrentApp('test');
// });
// result.current?.loadConfig();
// expect(getAppConfigMock).toBeCalled();
// });
test('result - loadManifest', () => {
const { result } = renderHook(() => useCurrentApp(appProvider));
act(() => {
Expand Down
32 changes: 16 additions & 16 deletions client/packages/core/src/app/utils/apps-matching-search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const appGroups: AppCategory[] = [
defaultIcon: '1',
apps: [
{
key: 'handover',
name: 'Handover',
appKey: 'handover',
displayName: 'Handover',
},
{
key: 'swcr',
name: 'SWCR',
appKey: 'swcr',
displayName: 'SWCR',
},
{
key: 'scope',
name: 'Scope Change',
appKey: 'scope',
displayName: 'Scope Change',
},
] as AppManifest[],
},
Expand All @@ -28,8 +28,8 @@ const appGroups: AppCategory[] = [
defaultIcon: '2',
apps: [
{
key: 'meetings',
name: 'Meetings',
appKey: 'meetings',
displayName: 'Meetings',
},
] as AppManifest[],
},
Expand All @@ -47,8 +47,8 @@ describe('appsMatchingSearch', () => {
color: '1',
apps: [
{
key: 'swcr',
name: 'SWCR',
appKey: 'swcr',
displayName: 'SWCR',
},
] as AppManifest[],
},
Expand All @@ -65,12 +65,12 @@ describe('appsMatchingSearch', () => {
defaultIcon: '1',
apps: [
{
key: 'handover',
name: 'Handover',
appKey: 'handover',
displayName: 'Handover',
},
{
key: 'scope',
name: 'Scope Change',
appKey: 'scope',
displayName: 'Scope Change',
},
] as AppManifest[],
},
Expand All @@ -80,8 +80,8 @@ describe('appsMatchingSearch', () => {
defaultIcon: '2',
apps: [
{
key: 'meetings',
name: 'Meetings',
appKey: 'meetings',
displayName: 'Meetings',
},
] as AppManifest[],
},
Expand Down
4 changes: 2 additions & 2 deletions client/packages/core/src/app/utils/apps-matching-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export function appsMatchingSearch(groups: AppCategory[], searchText?: string) {
...group,
apps: group.apps.filter(
(app) =>
app.key.toLowerCase().includes(searchText.toLowerCase()) ||
app.name.toLowerCase().includes(searchText.toLowerCase())
app.appKey.toLowerCase().includes(searchText.toLowerCase()) ||
app.displayName.toLowerCase().includes(searchText.toLowerCase())
),
}))
.filter((group) => group.apps.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useFavorites = () => {
const favorite$ = useMemo(
() =>
combineLatest([app?.getAllAppManifests(), menuFavoritesController.favorites$]).pipe(
map(([apps, favorites]) => apps.filter((app) => favorites.includes(app.key)))
map(([apps, favorites]) => apps.filter((app) => favorites.includes(app.appKey)))
),
[apps]
) as Observable<AppManifest[]>;
Expand Down Expand Up @@ -51,12 +51,13 @@ export const useFavorites = () => {
);

const favoritesWithDisabled =
useMemo(() => favorites.map((p) => ({ ...p, isDisabled: isDisabled(p.key) })), [favorites, isDisabled]) || [];
useMemo(() => favorites.map((p) => ({ ...p, isDisabled: isDisabled(p.appKey) })), [favorites, isDisabled]) ||
[];

const appGroupsWithPinned = useMemo(() => {
return (appCategories || []).map((group) => ({
...group,
apps: group.apps.map((app) => ({ ...app, isPinned: isPinned(app.key) })),
apps: group.apps.map((app) => ({ ...app, isPinned: isPinned(app.appKey) })),
})) as AppCategory[];
}, [isPinned, appCategories]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export type AppManifestResponse = {
};

export type AppManifest = FusionAppManifest & {
isPinned?: boolean;
isDisabled?: boolean;
url?: string;
};
Expand Down
Loading

0 comments on commit 348def9

Please sign in to comment.