diff --git a/stories/AntdCardCell.stories.tsx b/stories/AntdCardCell.stories.tsx index 341c2e7..6a8c2da 100644 --- a/stories/AntdCardCell.stories.tsx +++ b/stories/AntdCardCell.stories.tsx @@ -9,7 +9,7 @@ ********************************************************************************/ import moment from 'moment'; import React from 'react'; -import { Story, Meta } from '@storybook/react/types-6-0'; +import { Story, Meta } from '@storybook/react'; import { Provider } from 'react-redux'; import { asReduxStore, connectReduxDevtools } from 'mst-middlewares'; @@ -293,15 +293,6 @@ const additionalColls: CollState[] = [ }, ]; -registerMstViewKindSchema('aldkg:VerticalLayout', MstVerticalLayout); - -const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); -const rootStore = createUiModelFromState('mktp', client, rootModelInitialState, additionalColls); -console.log('rootStore', rootStore); -const store: any = asReduxStore(rootStore); -// eslint-disable-next-line @typescript-eslint/no-var-requires -connectReduxDevtools(require('remotedev'), rootStore); - export default { title: 'Several Controls/TreeAndForm Cards', component: Form, @@ -310,19 +301,29 @@ export default { }, } as Meta; -export const Empty: Story<{}> = () => ( - - -
-
-
-
-
-); +export const Empty: Story<{}> = () => { + registerMstViewKindSchema('aldkg:VerticalLayout', MstVerticalLayout); + + const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); + const rootStore = createUiModelFromState('mktp', client, rootModelInitialState, additionalColls); + console.log('rootStore', rootStore); + const store: any = asReduxStore(rootStore); + // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); + return ( + + +
+ +
+
+
+ ); +}; diff --git a/stories/Form.stories.tsx b/stories/Form.stories.tsx index 57bd827..2a129e1 100644 --- a/stories/Form.stories.tsx +++ b/stories/Form.stories.tsx @@ -124,12 +124,6 @@ const additionalColls: CollState[] = [ }, ]; -const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); -const rootStore = createUiModelFromState('reqs2', client, rootModelInitialState, additionalColls); -const store: any = asReduxStore(rootStore); -// eslint-disable-next-line @typescript-eslint/no-var-requires -connectReduxDevtools(require('remotedev'), rootStore); - export default { title: 'Form/ArtifactForm', component: Form, @@ -138,15 +132,22 @@ export default { }, } as Meta; -const Template: Story = (args: any) => ( - - -
- -
-
-
-); +const Template: Story = (args: any) => { + const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); + const rootStore = createUiModelFromState('reqs2', client, rootModelInitialState, additionalColls); + const store: any = asReduxStore(rootStore); + // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); + return ( + + +
+ +
+
+
+ ); +}; export const RemoteData = Template.bind({}); RemoteData.args = {}; diff --git a/stories/FormOverride.stories.tsx b/stories/FormOverride.stories.tsx index 04d4fac..6640fe5 100644 --- a/stories/FormOverride.stories.tsx +++ b/stories/FormOverride.stories.tsx @@ -142,12 +142,6 @@ const additionalColls: CollState[] = [ }, ]; -const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); -const rootStore = createUiModelFromState('reqs2', client, rootModelInitialState, additionalColls); -const store: any = asReduxStore(rootStore); -// eslint-disable-next-line @typescript-eslint/no-var-requires -connectReduxDevtools(require('remotedev'), rootStore); - export default { title: 'Form/ArtifactFormOverride', component: Form, @@ -156,15 +150,22 @@ export default { }, } as Meta; -const Template: Story = (args: any) => ( - - -
- -
-
-
-); +const Template: Story = (args: any) => { + const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); + const rootStore = createUiModelFromState('reqs2', client, rootModelInitialState, additionalColls); + const store: any = asReduxStore(rootStore); + // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); + return ( + + +
+ +
+
+
+ ); +}; export const RemoteData = Template.bind({}); RemoteData.args = {}; diff --git a/stories/TreeAndForm.stories.tsx b/stories/TreeAndForm.stories.tsx index d728fef..541567c 100644 --- a/stories/TreeAndForm.stories.tsx +++ b/stories/TreeAndForm.stories.tsx @@ -9,11 +9,18 @@ ********************************************************************************/ import moment from 'moment'; import React from 'react'; -import { Story, Meta } from '@storybook/react/types-6-0'; +import { Story, Meta } from '@storybook/react'; import { Provider } from 'react-redux'; import { asReduxStore, connectReduxDevtools } from 'mst-middlewares'; -import { SparqlClientImpl, rootModelInitialState, CollState } from '@agentlab/sparql-jsld-client'; +import { + CollState, + JsStrObj, + Results, + rootModelInitialState, + sendGet, + SparqlClientImpl, +} from '@agentlab/sparql-jsld-client'; import { antdCells, @@ -357,12 +364,6 @@ const additionalColls: CollState[] = [ }, ]; -const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); -const rootStore = createUiModelFromState('mktp', client, rootModelInitialState, additionalColls); -const store: any = asReduxStore(rootStore); -// eslint-disable-next-line @typescript-eslint/no-var-requires -connectReduxDevtools(require('remotedev'), rootStore); - export default { title: 'Several Controls/TreeAndForm Mktp', component: Form, @@ -371,12 +372,44 @@ export default { }, } as Meta; -export const Empty: Story<{}> = () => ( - - -
- -
-
-
-); +class SparqlClientImpl2 extends SparqlClientImpl { + async loadNs() { + const url = 'https://rdf4j.agentlab.ru/rdf4j-server/repositories/mktp/namespaces'; + const response = await sendGet(url); + if (response.status < 200 && response.status > 204) return Promise.reject('Cannot get namespaces'); + const ns: JsStrObj = {}; + //console.debug('response.data', response.data); + if (response.data && response.data.results) { + let results: Results = { bindings: [] }; + results = response.data.results; + if (results) { + results.bindings.forEach((b) => { + if (b.prefix && b.namespace && b.prefix.value && b.namespace.value) { + ns[b.prefix.value] = b.namespace.value; + } + }); + } + } + ns['sesame'] = 'http://www.openrdf.org/schema/sesame#'; + return ns; + } +} + +export const Empty: Story<{}> = () => { + //const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); + //const rootStore = createUiModelFromState('mktp', client, rootModelInitialState, additionalColls); + const client = new SparqlClientImpl2('https://rdf4j.agentlab.ru/rdf4j-server'); + const rootStore = createUiModelFromState('mktp-fed', client, rootModelInitialState, additionalColls); + const store: any = asReduxStore(rootStore); + // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); + return ( + + +
+ +
+
+
+ ); +}; diff --git a/stories/TreeAndFormArtifact.stories.tsx b/stories/TreeAndFormArtifact.stories.tsx index ac98d14..3a97445 100644 --- a/stories/TreeAndFormArtifact.stories.tsx +++ b/stories/TreeAndFormArtifact.stories.tsx @@ -9,11 +9,11 @@ ********************************************************************************/ import moment from 'moment'; import React from 'react'; -import { Story, Meta } from '@storybook/react/types-6-0'; +import { Story, Meta } from '@storybook/react'; import { Provider } from 'react-redux'; import { asReduxStore, connectReduxDevtools } from 'mst-middlewares'; -import { SparqlClientImpl, rootModelInitialState, CollState } from '@agentlab/sparql-jsld-client'; +import { CollState, rootModelInitialState, SparqlClientImpl } from '@agentlab/sparql-jsld-client'; import { antdCells, @@ -166,12 +166,6 @@ const additionalColls: CollState[] = [ }, ]; -const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); -const rootStore = createUiModelFromState('reqs2', client, rootModelInitialState, additionalColls); -const store: any = asReduxStore(rootStore); -// eslint-disable-next-line @typescript-eslint/no-var-requires -connectReduxDevtools(require('remotedev'), rootStore); - export default { title: 'Several Controls/TreeAndForm Artifacts', component: Form, @@ -180,12 +174,19 @@ export default { }, } as Meta; -export const Empty: Story<{}> = () => ( - - -
- -
-
-
-); +export const Empty: Story<{}> = () => { + const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); + const rootStore = createUiModelFromState('reqs2', client, rootModelInitialState, additionalColls); + const store: any = asReduxStore(rootStore); + // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); + return ( + + +
+ +
+
+
+ ); +}; diff --git a/stories/TreeAndFormColumns.stories.tsx b/stories/TreeAndFormColumns.stories.tsx index 05b067a..739f536 100644 --- a/stories/TreeAndFormColumns.stories.tsx +++ b/stories/TreeAndFormColumns.stories.tsx @@ -9,11 +9,11 @@ ********************************************************************************/ import moment from 'moment'; import React from 'react'; -import { Story, Meta } from '@storybook/react/types-6-0'; +import { Story, Meta } from '@storybook/react'; import { Provider } from 'react-redux'; import { asReduxStore, connectReduxDevtools } from 'mst-middlewares'; -import { SparqlClientImpl, rootModelInitialState, CollState } from '@agentlab/sparql-jsld-client'; +import { CollState, rootModelInitialState, SparqlClientImpl } from '@agentlab/sparql-jsld-client'; import { antdCells, @@ -288,12 +288,6 @@ const additionalColls: CollState[] = [ }, ]; -const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); -const rootStore = createUiModelFromState('mktp', client, rootModelInitialState, additionalColls); -const store: any = asReduxStore(rootStore); -// eslint-disable-next-line @typescript-eslint/no-var-requires -connectReduxDevtools(require('remotedev'), rootStore); - export default { title: 'Several Controls/Tree And Form with Columns', component: Form, @@ -302,12 +296,19 @@ export default { }, } as Meta; -export const Empty: Story<{}> = () => ( - - -
- -
-
-
-); +export const Empty: Story<{}> = () => { + const client = new SparqlClientImpl('https://rdf4j.agentlab.ru/rdf4j-server'); + const rootStore = createUiModelFromState('mktp', client, rootModelInitialState, additionalColls); + const store: any = asReduxStore(rootStore); + // eslint-disable-next-line @typescript-eslint/no-var-requires + connectReduxDevtools(require('remotedev'), rootStore); + return ( + + +
+ +
+
+
+ ); +};