-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from axonivy/XIVY-12288/display-data-class-data
XIVY-12288 display data class data as string
- Loading branch information
Showing
17 changed files
with
745 additions
and
805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
import { ClientContextProvider, ClientJsonRpc, DataClassEditor, QueryProvider, initQueryClient } from '@axonivy/dataclass-editor'; | ||
import { ReadonlyProvider, ThemeProvider } from '@axonivy/ui-components'; | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom/client'; | ||
import { DataClassEditor } from '../../../packages/dataclass-editor/src'; | ||
import './index.css'; | ||
import { URLParams } from './url-helper'; | ||
|
||
export async function start(): Promise<void> { | ||
const root = ReactDOM.createRoot(document.getElementById('root')!); | ||
root.render(<DataClassEditor />); | ||
const server = URLParams.webSocketBase(); | ||
const app = URLParams.app(); | ||
const pmv = URLParams.pmv(); | ||
const file = URLParams.file(); | ||
const theme = URLParams.theme(); | ||
const readonly = URLParams.readonly(); | ||
|
||
const client = await ClientJsonRpc.startWebSocketClient(server); | ||
const queryClient = initQueryClient(); | ||
|
||
root.render( | ||
<React.StrictMode> | ||
<ThemeProvider defaultTheme={theme}> | ||
<ClientContextProvider client={client}> | ||
<QueryProvider client={queryClient}> | ||
<ReadonlyProvider readonly={readonly}> | ||
<DataClassEditor context={{ app, pmv, file: file }} /> | ||
</ReadonlyProvider> | ||
</QueryProvider> | ||
</ClientContextProvider> | ||
</ThemeProvider> | ||
</React.StrictMode> | ||
); | ||
} | ||
|
||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
import { ClientContextProvider, DataClassEditor, initQueryClient, QueryProvider } from '@axonivy/dataclass-editor'; | ||
import { ThemeProvider } from '@axonivy/ui-components'; | ||
import React from 'react'; | ||
import * as ReactDOM from 'react-dom/client'; | ||
import { DataClassEditor } from '../../../packages/dataclass-editor/src'; | ||
import './index.css'; | ||
import { DataClassClientMock } from './mock/dataclass-client-mock'; | ||
|
||
export async function start(): Promise<void> { | ||
const root = ReactDOM.createRoot(document.getElementById('root')!); | ||
root.render(<DataClassEditor />); | ||
} | ||
const root = ReactDOM.createRoot(document.getElementById('root')!); | ||
const client = new DataClassClientMock(); | ||
const queryClient = initQueryClient(); | ||
|
||
start(); | ||
root.render( | ||
<React.StrictMode> | ||
<ThemeProvider defaultTheme={'light'}> | ||
<ClientContextProvider client={client}> | ||
<QueryProvider client={queryClient}> | ||
<DataClassEditor context={{ app: '', pmv: '', file: '' }} /> | ||
</QueryProvider> | ||
</ClientContextProvider> | ||
</ThemeProvider> | ||
</React.StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Client, Data, Event } from '@axonivy/dataclass-editor/src/protocol/types'; | ||
|
||
export class DataClassClientMock implements Client { | ||
private dataClassData: Data = { | ||
context: { app: '', pmv: '', file: '' }, | ||
data: `{ | ||
"$schema" : "https://json-schema.axonivy.com/data-class/11.4.0/data-class.json", | ||
"simpleName" : "Data", | ||
"namespace" : "mock", | ||
"isBusinessCaseData" : false | ||
}` | ||
}; | ||
|
||
data(): Promise<Data> { | ||
return Promise.resolve(this.dataClassData); | ||
} | ||
|
||
saveData(saveData: Data): Promise<String> { | ||
this.dataClassData.data = saveData.data; | ||
return Promise.resolve(''); | ||
} | ||
|
||
onDataChanged: Event<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
export namespace URLParams { | ||
export function parameter(key: string): string | undefined { | ||
const param = new URLSearchParams(window.location.search).get(key); | ||
return param !== null ? decodeURIComponent(param) : undefined; | ||
} | ||
|
||
export function app(): string { | ||
return parameter('app') ?? ''; | ||
} | ||
|
||
export function pmv(): string { | ||
return parameter('pmv') ?? ''; | ||
} | ||
|
||
export function file(): string { | ||
return parameter('file') ?? ''; | ||
} | ||
|
||
export function theme(): 'dark' | 'light' { | ||
const theme = parameter('theme'); | ||
if (theme === 'dark') { | ||
return theme; | ||
} | ||
return 'light'; | ||
} | ||
|
||
export function readonly(): boolean { | ||
const readonly = parameter('readonly'); | ||
if (readonly === 'true') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export function webSocketBase(): string { | ||
return `${isSecureConnection() ? 'wss' : 'ws'}://${server()}`; | ||
} | ||
|
||
const isSecureConnection = () => { | ||
const secureParam = parameter('secure'); | ||
if (secureParam === 'true') { | ||
return true; | ||
} | ||
if (secureParam === 'false') { | ||
return false; | ||
} | ||
return window.location.protocol === 'https:'; | ||
}; | ||
|
||
const server = () => { | ||
return parameter('server') ?? basePath(); | ||
}; | ||
|
||
const basePath = () => { | ||
return 'localhost:8081'; | ||
}; | ||
} |
Oops, something went wrong.