Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 39cabf5

Browse files
committed
fix(shared): added metadata logger box to extension
1 parent 98fc193 commit 39cabf5

File tree

19 files changed

+898
-45
lines changed

19 files changed

+898
-45
lines changed

packages/shared/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"react": "^17.0.2",
3030
"react-dom": "^17.0.2",
3131
"react-i18next": "^11.18.0",
32+
"react-json-view": "^1.21.3",
3233
"ts-endpoint": "^2.0.0",
3334
"ts-endpoint-express": "^2.0.0",
3435
"ts-io-error": "^2.0.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { getArbitrary } from 'fast-check-io-ts';
2+
import {
3+
ADVContributionEvent,
4+
ContributionEvent,
5+
VideoContributionEvent,
6+
} from '../../models/ContributionEvent';
7+
import * as t from 'io-ts';
8+
import fc from 'fast-check';
9+
10+
const { ...videoContributionEventProps } = VideoContributionEvent.type.props;
11+
export const VideoContributionEventArb = getArbitrary(
12+
t.strict({
13+
...videoContributionEventProps,
14+
})
15+
).map((cc): any => ({
16+
...cc,
17+
clientTime: new Date(),
18+
}));
19+
20+
const { ...advContributionEventProps } = ADVContributionEvent.type.props;
21+
export const ADVContributionEventArb = getArbitrary(
22+
t.strict({
23+
...advContributionEventProps,
24+
})
25+
).map((cc) => ({
26+
...cc,
27+
}));
28+
29+
export const ContributionEventArb: fc.Arbitrary<ContributionEvent> = fc.oneof(
30+
VideoContributionEventArb,
31+
ADVContributionEventArb
32+
);

packages/shared/src/extension/app.ts

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import _ from 'lodash';
2+
import { ParserConfiguration, ParserFn } from '../providers/parser.provider';
23
import { HandshakeResponse } from '../models/HandshakeBody';
34
import { clearCache } from '../providers/dataDonation.provider';
45
import { FIXED_USER_NAME, initializeKey } from './background/account';
@@ -16,6 +17,7 @@ import log from './logger';
1617
import HubEvent from './models/HubEvent';
1718
import { ServerLookup } from './models/Message';
1819
import UserSettings from './models/UserSettings';
20+
import { renderUI, RenderUIProps } from './ui';
1921
import { bo } from './utils/browser.utils';
2022

2123
// instantiate a proper logger
@@ -67,7 +69,12 @@ interface SetupObserverOpts {
6769
onLocationChange: (oldLocation: string, newLocation: string) => void;
6870
}
6971

70-
export interface BootOpts {
72+
export interface BootOpts<
73+
S = any,
74+
M = any,
75+
C extends ParserConfiguration = ParserConfiguration,
76+
PP extends Record<string, ParserFn<S, any, C>> = any
77+
> {
7178
payload: ServerLookup['payload'];
7279
mapLocalConfig: (
7380
c: UserSettings,
@@ -79,6 +86,7 @@ export interface BootOpts {
7986
onRegister: (h: Hub<HubEvent>, config: UserSettings) => void;
8087
};
8188
onAuthenticated: (res: any) => void;
89+
ui?: Omit<RenderUIProps<S, M, C, PP>, 'hub'>;
8290
}
8391

8492
/**
@@ -232,7 +240,12 @@ const serverHandshakeP = (
232240

233241
let loading = false;
234242
let app: App | undefined;
235-
export async function boot(opts: BootOpts): Promise<App> {
243+
export async function boot<
244+
S = any,
245+
M = any,
246+
C extends ParserConfiguration = ParserConfiguration,
247+
PP extends Record<string, ParserFn<S, any, C>> = any
248+
>(opts: BootOpts<S, M, C, PP>): Promise<App> {
236249
if (app) {
237250
appLog.debug('App already booted!');
238251
return app;
@@ -321,12 +334,12 @@ export async function boot(opts: BootOpts): Promise<App> {
321334
// register platform specific event handlers
322335
opts.hub.onRegister(opts.hub.hub, config);
323336

324-
// emergency button should be used when a supported with
325-
// UX hack in place didn't see any UX change, so they
326-
// can report the problem and we can handle it.
327-
// initializeEmergencyButton();
337+
// render shared ui if configuration is given
338+
if (opts.ui) {
339+
renderUI({ hub: opts.hub.hub, ...opts.ui });
340+
}
328341

329-
// because the URL has been for sure reloaded, be sure to also
342+
// because the URL has been for sure reloaded, be sure to also clear cache
330343
clearCache();
331344

332345
// send the configuration to the server to register the extension

packages/shared/src/extension/tooltip/index.tsx

-23
This file was deleted.

0 commit comments

Comments
 (0)