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

GH-17 Port Search component from Expert system #19

Merged
merged 8 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"lint-staged": "lint-staged"
},
"peerDependencies": {
"@agentlab/sparql-jsld-client": ">=5.0.0-rc.16",
"@agentlab/sparql-jsld-client": ">=5.0.0-rc.17",
"@ant-design/icons": ">=4.7.0",
"@rdfjs/data-model": ">=1.3.4",
"@tinymce/tinymce-react": ">=3.12.6",
"@tinymce/tinymce-react": ">=3.13.0",
"antd": ">=4.16.13",
"history": ">=5.0.1",
"lodash-es": ">=4.17.21",
Expand All @@ -70,8 +70,8 @@
"react-dom": ">=17.0.2",
"react-error-boundary": ">=3.1.3",
"react-horizontal-scrolling-menu": ">=2.4.4",
"react-router": ">=6.0.0-beta.6",
"react-router-dom": ">=6.0.0-beta.6",
"react-router": ">=6.0.0-beta.7",
"react-router-dom": ">=6.0.0-beta.7",
"react-sortable-hoc": ">=2.0.0",
"react-split-pane": ">=2.0.3",
"react-virtualized": ">=9.22.3",
Expand All @@ -81,7 +81,7 @@
"uuid62": ">=1.0.1"
},
"dependencies": {
"@agentlab/sparql-jsld-client": "^5.0.0-rc.16",
"@agentlab/sparql-jsld-client": "^5.0.0-rc.17",
"@ant-design/icons": "^4.7.0",
"@tinymce/tinymce-react": "^3.13.0",
"@types/react": "^17.0.30",
Expand All @@ -104,8 +104,8 @@
"react-horizontal-scrolling-menu": "^2.4.4",
"react-is": "^17.0.2",
"react-redux": "^7.2.5",
"react-router": "^6.0.0-beta.6",
"react-router-dom": "^6.0.0-beta.6",
"react-router": "^6.0.0-beta.7",
"react-router-dom": "^6.0.0-beta.7",
"react-sortable-hoc": "^2.0.0",
"react-split-pane": "^2.0.3",
"react-virtualized": "^9.22.3",
Expand All @@ -119,7 +119,7 @@
"@babel/core": "^7.15.8",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-typescript": "^8.2.5",
"@rollup/plugin-typescript": "^8.3.0",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-essentials": "^6.3.12",
"@storybook/addon-links": "^6.3.12",
Expand All @@ -146,7 +146,7 @@
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-flowtype": "^6.1.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.2.1",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
Expand All @@ -168,7 +168,7 @@
"sass-loader": "10.1.1",
"storybook-css-modules-preset": "^1.1.1",
"style-loader": "^2.0.0",
"ts-jest": "^27.0.6",
"ts-jest": "^27.0.7",
"tslib": "^2.3.1",
"typescript": "4.4.4",
"typescript-plugin-css-modules": "^3.4.0"
Expand Down
5 changes: 3 additions & 2 deletions src/DispatchCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { isEqual, maxBy } from 'lodash-es';
import React, { useContext } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

import { CellRendererRegistryEntry } from './renderers';
import { UnknownRenderer } from './UnknownRenderer';
import { ErrorFallback, DispatchCellProps, FormsCell, RenderCellProps } from './Form';
import { ErrorFallback, DispatchCellProps, RenderCellProps } from './Form';
import { MstContext } from './MstContext';

/**
Expand Down Expand Up @@ -47,7 +48,7 @@ export const DispatchCell: React.FC<DispatchCellProps> = React.memo(
</td>
);
} else {
const Render: React.FC<RenderCellProps> = (renderer as FormsCell).cell;
const Render: React.FC<RenderCellProps> = (renderer as CellRendererRegistryEntry).cell;
return (
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={() => {}}>
<Render
Expand Down
10 changes: 1 addition & 9 deletions src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
import { Spin } from 'antd';
import { observer } from 'mobx-react-lite';
import { getSnapshot } from 'mobx-state-tree';
import { JsObject } from '@agentlab/sparql-jsld-client';

import { JsonSchema7 } from './models/jsonSchema7';
//import ModalAntd from './antd/util/AntdModal';
import { MstContext } from './MstContext';
import { UnknownRenderer } from './UnknownRenderer';
import { RankedTester } from './testers';
import { IViewDescr, IViewDescrElement, IViewKind, IViewKindElement } from './models/uischema';
import { JsObject } from '@agentlab/sparql-jsld-client';

export interface ControlComponent {
data: any;
Expand All @@ -45,14 +45,6 @@ export interface ControlComponent {
formData?: any;
}

export interface FormsRenderer {
tester: RankedTester;
renderer: React.FC<any>;
}
export interface FormsCell {
tester: RankedTester;
cell: React.FC<any>;
}
export interface FormsInitStateProps {
viewDescrCollId: string;
viewDescrId: string;
Expand Down
23 changes: 19 additions & 4 deletions src/MstContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
* SPDX-License-Identifier: GPL-3.0-only
********************************************************************************/
import React, { createContext, PropsWithChildren } from 'react';
import { FormsCell, FormsRenderer } from './Form';
import { CellRendererRegistryEntry, RendererRegistryEntry } from './renderers';
import { registerMstViewKindSchema } from './models/MstViewDescr';

export interface MstContextProps {
store: any;
renderers: FormsRenderer[];
cells: FormsCell[];
renderers: RendererRegistryEntry[];
cells: CellRendererRegistryEntry[];
}

export const MstContext = createContext<MstContextProps>({
Expand All @@ -22,6 +23,20 @@ export const MstContext = createContext<MstContextProps>({
cells: [],
});

export const MstContextProvider = ({ store, renderers, cells = [], children }: PropsWithChildren<any>): JSX.Element => {
export const MstContextProvider = ({
store,
renderers,
cells = [],
children,
}: PropsWithChildren<{
store: any;
renderers: RendererRegistryEntry[];
cells?: CellRendererRegistryEntry[];
}>): JSX.Element => {
renderers.forEach((r) => {
if ((r as any).mstVkeType) {
registerMstViewKindSchema((r as any).mstVkeType);
}
});
return <MstContext.Provider value={{ store, renderers, cells }}>{children}</MstContext.Provider>;
};
3 changes: 3 additions & 0 deletions src/controls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { antdSliderControlTester, AntdSliderControlWithStore } from './AntdSlide
import { antdTextControlTester, AntdTextControlWithStore } from './AntdTextControl';
import { tinyMCEControlTester, TinyMCEControlWithStore } from './TinyMCEControl';
import { antdImageControlTester, AntdImageControlWithStore } from './AntdImageControl';
import { antdQueryTester, AntQueryWithStore } from './query/Query';

export const antdControlRenderers: RendererRegistryEntry[] = [
{ tester: antdBooleanControlTester, renderer: AntdBooleanControlWithStore },
Expand All @@ -37,6 +38,7 @@ export const antdControlRenderers: RendererRegistryEntry[] = [
{ tester: antdTextControlTester, renderer: AntdTextControlWithStore },

{ tester: tinyMCEControlTester, renderer: TinyMCEControlWithStore },
{ tester: antdQueryTester, renderer: AntQueryWithStore },
];

export * from './AntdBooleanControl';
Expand All @@ -50,3 +52,4 @@ export * from './AntdSliderControl';
export * from './AntdTextControl';
export * from './TinyMCEControl';
export * from './AntdImageControl';
export * from './query/Query';
Loading