From ba792b9289e114af18e3785382ab4ba10bb75a46 Mon Sep 17 00:00:00 2001 From: Michael Puehringer Date: Wed, 16 Aug 2023 14:36:38 +0200 Subject: [PATCH 1/6] Add context to visyn view components --- src/views/visyn/demo/VisynDemoView.tsx | 5 +++++ src/views/visyn/interfaces.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/views/visyn/demo/VisynDemoView.tsx b/src/views/visyn/demo/VisynDemoView.tsx index 11011cfda..ffe7cbe24 100644 --- a/src/views/visyn/demo/VisynDemoView.tsx +++ b/src/views/visyn/demo/VisynDemoView.tsx @@ -150,6 +150,10 @@ export function VisynDemoViewHeader({ parameters, selection, onParametersChanged ); } +export function VisynDemoViewContext({ children }: DemoVisynViewPluginType['props']) { + return children; +} + export function createVisynDemoView(): DemoVisynViewPluginType['definition'] { return { viewType: 'simple', @@ -161,5 +165,6 @@ export function createVisynDemoView(): DemoVisynViewPluginType['definition'] { view: VisynDemoView, header: VisynDemoViewHeader, tab: VisynDemoViewSidebar, + context: VisynDemoViewContext, }; } diff --git a/src/views/visyn/interfaces.ts b/src/views/visyn/interfaces.ts index 48d8dd713..7cf581cf4 100644 --- a/src/views/visyn/interfaces.ts +++ b/src/views/visyn/interfaces.ts @@ -27,6 +27,10 @@ type VisynViewProps> = { * @param parameters New parameters. */ onParametersChanged(parameters: React.SetStateAction): void; + /** + * Children of this visyn view. This is used to pass the actual view component to the context component. + */ + children?: React.ReactNode; }; /** @@ -45,6 +49,10 @@ type VisynViewComponents = { * Optional side-tab component of this visyn view plugin. */ tab?: React.LazyExoticComponent> | React.ComponentType; + /** + * Optional context component of this visyn view plugin. This component wraps all of the above and allows to provide context values (i.e. via React.createContext). + */ + context?: React.LazyExoticComponent> | React.ComponentType; }; type BaseVisynViewDesc> = IBaseViewPluginDesc & { @@ -117,7 +125,7 @@ export interface DefineVisynViewPlugin< /** * Definition to be used as return value of the loader function of the module. */ - definition: Pick, 'viewType' | 'defaultParameters' | 'header' | 'view' | 'tab'>; + definition: Pick, 'viewType' | 'defaultParameters' | 'header' | 'view' | 'tab' | 'context'>; /** * Full plugin representing the loaded visyn view. */ From d8c77c5a4bf7d3199db07c4a277a13547c7213ee Mon Sep 17 00:00:00 2001 From: Michael Puehringer Date: Thu, 17 Aug 2023 13:00:00 +0200 Subject: [PATCH 2/6] Switch to latest typescript version --- package.json | 3 ++- src/views/visyn/interfaces.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cc0f7477c..e7f1993fd 100644 --- a/package.json +++ b/package.json @@ -187,7 +187,8 @@ "@types/react": "~18.2.0", "@types/react-dom": "~18.2.0", "react": "~18.2.0", - "react-dom": "~18.2.0" + "react-dom": "~18.2.0", + "visyn_scripts": "git+ssh://git@github.com/datavisyn/visyn_scripts#mp/upgrade_ts_5_1_6" }, "visyn": { "entries": { diff --git a/src/views/visyn/interfaces.ts b/src/views/visyn/interfaces.ts index 7cf581cf4..1df6a4955 100644 --- a/src/views/visyn/interfaces.ts +++ b/src/views/visyn/interfaces.ts @@ -52,7 +52,7 @@ type VisynViewComponents = { /** * Optional context component of this visyn view plugin. This component wraps all of the above and allows to provide context values (i.e. via React.createContext). */ - context?: React.LazyExoticComponent> | React.ComponentType; + context?: React.LazyExoticComponent> | React.ComponentType; }; type BaseVisynViewDesc> = IBaseViewPluginDesc & { From 8635b7c13cc104490cb85e4f76f41ea5a1667d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=BChringer?= <51900829+puehringer@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:18:14 +0200 Subject: [PATCH 3/6] Remove resolution to visyn_scripts --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index e7f1993fd..3d2fae127 100644 --- a/package.json +++ b/package.json @@ -160,8 +160,7 @@ "react-dom": "^18.2.0", "react-highlight-words": "^0.17.0", "react-plotly.js": "^2.5.1", - "use-deep-compare-effect": "^1.8.0", - "visyn_scripts": "git+ssh://git@github.com/datavisyn/visyn_scripts#develop" + "use-deep-compare-effect": "^1.8.0" }, "devDependencies": { "@babel/core": "^7.17.7", From 7a73ee5fcc6f1d5fc52f0b8d0323c7616872fa81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=BChringer?= <51900829+puehringer@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:18:43 +0200 Subject: [PATCH 4/6] Remove resolutions --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3d2fae127..cc0f7477c 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,8 @@ "react-dom": "^18.2.0", "react-highlight-words": "^0.17.0", "react-plotly.js": "^2.5.1", - "use-deep-compare-effect": "^1.8.0" + "use-deep-compare-effect": "^1.8.0", + "visyn_scripts": "git+ssh://git@github.com/datavisyn/visyn_scripts#develop" }, "devDependencies": { "@babel/core": "^7.17.7", @@ -186,8 +187,7 @@ "@types/react": "~18.2.0", "@types/react-dom": "~18.2.0", "react": "~18.2.0", - "react-dom": "~18.2.0", - "visyn_scripts": "git+ssh://git@github.com/datavisyn/visyn_scripts#mp/upgrade_ts_5_1_6" + "react-dom": "~18.2.0" }, "visyn": { "entries": { From 3f4c15e9b9e636663dbe68114ff01b7cdd3852b7 Mon Sep 17 00:00:00 2001 From: Michael Puehringer Date: Thu, 17 Aug 2023 13:21:33 +0200 Subject: [PATCH 5/6] Add ts-ignore to context view --- src/views/visyn/demo/VisynDemoView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/visyn/demo/VisynDemoView.tsx b/src/views/visyn/demo/VisynDemoView.tsx index ffe7cbe24..102730f59 100644 --- a/src/views/visyn/demo/VisynDemoView.tsx +++ b/src/views/visyn/demo/VisynDemoView.tsx @@ -165,6 +165,7 @@ export function createVisynDemoView(): DemoVisynViewPluginType['definition'] { view: VisynDemoView, header: VisynDemoViewHeader, tab: VisynDemoViewSidebar, + // @ts-ignore: Fixed in Typescript ~5.1: https://github.com/datavisyn/visyn_scripts/pull/38 context: VisynDemoViewContext, }; } From 5f39741acee48e5eefc8257a9f26e0412bb920b0 Mon Sep 17 00:00:00 2001 From: Holger Stitz Date: Tue, 26 Sep 2023 09:41:09 +0200 Subject: [PATCH 6/6] fix: remove ts-ignore The related PR https://github.com/datavisyn/visyn_scripts/pull/38 was merged --- src/views/visyn/demo/VisynDemoView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/visyn/demo/VisynDemoView.tsx b/src/views/visyn/demo/VisynDemoView.tsx index 102730f59..ffe7cbe24 100644 --- a/src/views/visyn/demo/VisynDemoView.tsx +++ b/src/views/visyn/demo/VisynDemoView.tsx @@ -165,7 +165,6 @@ export function createVisynDemoView(): DemoVisynViewPluginType['definition'] { view: VisynDemoView, header: VisynDemoViewHeader, tab: VisynDemoViewSidebar, - // @ts-ignore: Fixed in Typescript ~5.1: https://github.com/datavisyn/visyn_scripts/pull/38 context: VisynDemoViewContext, }; }