Skip to content

Commit be1949e

Browse files
committed
diff view for one ofs
1 parent 9f32274 commit be1949e

File tree

8 files changed

+251
-195
lines changed

8 files changed

+251
-195
lines changed

packages/tdb-documents-ui/diff/src/Output.js

Lines changed: 214 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {getSelectedTypeData} from "./functions"
66
import {oldData, changedData} from "./diff.constants"
77
import '../../src/css/terminusdb__darkly.css'
88

9+
910
export const Output = () => {
1011
const {
1112
type,
@@ -27,7 +28,7 @@ export const Output = () => {
2728
useEffect(() => {
2829
async function getDiffs(tdbClient) {
2930
//console.log("doc", doc)
30-
let result_patch = await tdbClient.getJSONDiff(oldData["Test"], changedData["Test"])
31+
let result_patch = await tdbClient.getJSONDiff(oldData["Definition"], changedData["Definition"])
3132
setDiff(result_patch)
3233
}
3334
if(tdbClient) {
@@ -375,13 +376,221 @@ export const Output = () => {
375376

376377
}
377378
}
379+
380+
const CODE_FRAMES = {
381+
"@context": {
382+
"@base": "terminusdb:///documentation/data/",
383+
"@schema": "terminusdb:///documentation/schema#",
384+
"@type": "Context"
385+
},
386+
"Application": {
387+
"@inherits": [
388+
"Documented",
389+
"Named",
390+
"Summarized"
391+
],
392+
"@type": "Class",
393+
"language": {
394+
"@id": "Language",
395+
"@type": "Enum",
396+
"@values": [
397+
"Python",
398+
"Javascript"
399+
]
400+
},
401+
"license": "xsd:string",
402+
"modules": {
403+
"@class": "Module",
404+
"@type": "Set"
405+
},
406+
"name": "xsd:string",
407+
"summary": {
408+
"@class": "xsd:string",
409+
"@type": "Optional"
410+
},
411+
"version": "xsd:string"
412+
},
413+
"Class": {
414+
"@inherits": [
415+
"Documented",
416+
"Named",
417+
"Summarized"
418+
],
419+
"@type": "Class",
420+
"memberFunction": "Definition",
421+
"memberVariable": "Parameter",
422+
"name": "xsd:string",
423+
"summary": {
424+
"@class": "xsd:string",
425+
"@type": "Optional"
426+
}
427+
},
428+
"Definition": {
429+
"@inherits": [
430+
"Documented",
431+
"Named",
432+
"Summarized"
433+
],
434+
"@oneOf": [
435+
{
436+
"parameters": {
437+
"@class": "Parameter",
438+
"@dimensions": 1,
439+
"@type": "Array"
440+
},
441+
"receives": {
442+
"@class": "Parameter",
443+
"@dimensions": 1,
444+
"@type": "Array"
445+
}
446+
},
447+
{
448+
"returns": "Returns",
449+
"returns_multiple": {
450+
"@class": "Returns",
451+
"@dimensions": 1,
452+
"@type": "Array"
453+
},
454+
"void": "sys:Unit",
455+
"yields": "Returns"
456+
}
457+
],
458+
"@type": "Class",
459+
"name": "xsd:string",
460+
"summary": {
461+
"@class": "xsd:string",
462+
"@type": "Optional"
463+
}
464+
/*"examples": {
465+
"@class": "xsd:string",
466+
"@dimensions": 1,
467+
"@type": "Array"
468+
},
469+
"extendedSummary": "xsd:string",
470+
"index": {
471+
"@class": "xsd:integer",
472+
"@type": "Optional"
473+
},
474+
"notes": "xsd:string",
475+
"raises": {
476+
"@class": "Exception",
477+
"@type": "Set"
478+
},
479+
"references": "xsd:string",
480+
"section": {
481+
"@class": "xsd:string",
482+
"@type": "Optional"
483+
},
484+
"seeAlso": {
485+
"@class": "Definition",
486+
"@type": "Set"
487+
},
488+
"signature": "xsd:string",
489+
}*/
490+
},
491+
"Documented": {
492+
"@abstract": [],
493+
"@inherits": [
494+
"Named",
495+
"Summarized"
496+
],
497+
"@type": "Class",
498+
"name": "xsd:string",
499+
"summary": {
500+
"@class": "xsd:string",
501+
"@type": "Optional"
502+
}
503+
},
504+
"Exception": {
505+
"@inherits": [
506+
"Documented",
507+
"Named",
508+
"Summarized"
509+
],
510+
"@type": "Class",
511+
"name": "xsd:string",
512+
"paramters": {
513+
"@class": "xsd:string",
514+
"@dimensions": 1,
515+
"@type": "Array"
516+
},
517+
"summary": {
518+
"@class": "xsd:string",
519+
"@type": "Optional"
520+
}
521+
},
522+
"Language": {
523+
"@type": "Enum",
524+
"@values": [
525+
"Python",
526+
"Javascript"
527+
]
528+
},
529+
"Module": {
530+
"@inherits": [
531+
"Documented",
532+
"Named",
533+
"Summarized"
534+
],
535+
"@type": "Class",
536+
"classes": {
537+
"@class": "Class",
538+
"@type": "Set"
539+
},
540+
"definitions": {
541+
"@class": "Definition",
542+
"@type": "Set"
543+
},
544+
"name": "xsd:string",
545+
"summary": {
546+
"@class": "xsd:string",
547+
"@type": "Optional"
548+
}
549+
},
550+
"Named": {
551+
"@abstract": [],
552+
"@type": "Class",
553+
"name": "xsd:string"
554+
},
555+
"Parameter": {
556+
"@inherits": [
557+
"Documented",
558+
"Named",
559+
"Summarized"
560+
],
561+
"@type": "Class",
562+
"default": "xsd:string",
563+
"name": "xsd:string",
564+
"summary": {
565+
"@class": "xsd:string",
566+
"@type": "Optional"
567+
},
568+
"type": "xsd:string"
569+
},
570+
"Returns": {
571+
"@type": "Class",
572+
"name": {
573+
"@class": "xsd:string",
574+
"@type": "Optional"
575+
},
576+
"type": "xsd:string"
577+
},
578+
"Summarized": {
579+
"@abstract": [],
580+
"@type": "Class",
581+
"summary": {
582+
"@class": "xsd:string",
583+
"@type": "Optional"
584+
}
585+
}
586+
}
378587

379588
return <div className="w-100">
380589
<DiffViewer
381-
oldValue={oldData["Test"]}
382-
newValue={changedData["Test"]}
383-
frame={testFrames}
384-
type={"Test"}
590+
oldValue={oldData["Definition"]}
591+
newValue={changedData["Definition"]}
592+
frame={CODE_FRAMES}
593+
type={"Definition"}
385594
onTraverse={handleTraverse}
386595
diffPatch={diff}/>
387596
</div>

packages/tdb-documents-ui/diff/src/diff.constants.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ export const oldData = {
169169
}
170170
}
171171
},
172+
},
173+
"Definition": {
174+
"@id": "Definition/031b8d459e60df9ea656b686ec656928177d788d595051312f872fb8bd9b1df5",
175+
"@type": "Definition",
176+
"name": "ok",
177+
"parameters": [
178+
"P/13",
179+
"P/23",
180+
"P/3"
181+
],
182+
"returns": "Returns/NEW6091821362531aed8af24944c8dffe5a9ceeea1e572e2fb27c84029a49b6e732",
183+
"summary": "NEW Check whether the TerminusDB server is still OK.\n Status is not OK when this function returns false\n or throws an exception (mostly ConnectTimeout)"
172184
}
173185
}
174186

@@ -329,6 +341,17 @@ export const changedData = {
329341
/*}
330342
}
331343
},*/
344+
},
345+
"Definition": {
346+
"@id": "Definition/031b8d459e60df9ea656b686ec656928177d788d595051312f872fb8bd9b1df5",
347+
"@type": "Definition",
348+
"name": "ok",
349+
"parameters": [
350+
"P/1",
351+
"P/2"
352+
],
353+
"returns": "Returns/6091821362531aed8af24944c8dffe5a9ceeea1e572e2fb27c84029a49b6e732",
354+
"summary": "Check whether the TerminusDB server is still OK.\n Status is not OK when this function returns false\n or throws an exception (mostly ConnectTimeout)"
332355
}
333356
}
334357

packages/tdb-documents-ui/src/arrayHelpers/nestedArrayTemplates.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import * as util from "../utils"
1010
import { TDBLabel } from "../components/LabelComponent"
1111
import { getDisplay } from "../helpers/fieldDisplay"
1212
import { getPlaceholder } from "../helpers/placeholderHelper"
13-
import { GetFieldDisplay } from "./templates"
14-
13+
import { GetFieldDisplay, DisplayExtraElements } from "./templates"
1514

1615

1716

@@ -100,7 +99,7 @@ export const ArrayFieldTemplate = ({ args, props, property, items, handleAdd, ha
10099
</Button>}
101100
</Stack>
102101
})}
103-
102+
{mode === CONST.VIEW && <DisplayExtraElements args={args} property={props.title} props={props}/>}
104103
{props.canAdd && (
105104
<div>
106105
<Button data-cy={`add_${label}`}

packages/tdb-documents-ui/src/arrayHelpers/templates.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export const GetFieldDisplay = ({ args, props, element, id, property, setUpdate,
4949
return <span>
5050
{fieldDisplay()}
5151
</span>
52-
}
52+
}
5353

54-
const DisplayExtraElements = ({ args, props, property }) => {
54+
export const DisplayExtraElements = ({ args, props, property }) => {
5555
if(args.uiFrame && args.uiFrame.hasOwnProperty(property)) {
5656
// no extra elements available from DiffViewer at this point
5757
if(props.items.length === args.uiFrame[property].length) return <React.Fragment/>

0 commit comments

Comments
 (0)