Skip to content

Commit 2595bfe

Browse files
committed
adding inheritence to relationship
1 parent 24e2b7a commit 2595bfe

File tree

9 files changed

+346
-537
lines changed

9 files changed

+346
-537
lines changed

package-lock.json

Lines changed: 272 additions & 514 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/tdb-dashboard/cypress/e2e/dashboard/all.cy.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/tdb-dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@apollo/client": "^3.7.1",
4949
"@auth0/auth0-spa-js": "^1.19.3",
5050
"@codemirror/highlight": "^0.19.8",
51+
"@cypress/webpack-preprocessor": "^5.17.1",
5152
"@fortawesome/fontawesome-free": "^6.3.0",
5253
"@fortawesome/fontawesome-svg-core": "^6.3.0",
5354
"@fortawesome/free-solid-svg-icons": "^6.3.0",

packages/tdb-dashboard/src/components/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const IconBarConfig = {
3030
title: "TerminusDB",
3131
key:"TerminusDB",
3232
img: <img src={logo} className="logo-img"/>,
33-
/*svg: <React.Fragment>
33+
/*svg: <React.Fragment>
3434
<svg width="48" height="48" xmlns="http://www.w3.org/2000/svg">
3535
<g fill="#00C08B">
3636
<path d="M37.97 14.853c4.118 6.47 3.236 15-2.205 20.441C32.676 38.382 28.559 40 24.147 40a17.03 17.03 0 01-8.823-2.5c-.148-.147-.442-.441-.442-.735-.147-.294 0-.736.147-1.03.147-.294.442-.44.883-.588.294-.147.735 0 1.03.147 5.44 3.53 12.646 2.647 17.058-1.912 4.412-4.558 5.294-11.764 1.912-17.058-.441-.589-.147-1.471.44-1.765.295-.147.59-.294 1.03-.147.147 0 .442.147.589.44z"/><path d="M44.147 36.912c-.294.44-.588.588-1.03.588-.293 0-.588-.147-.735-.147-.588-.441-.735-1.177-.44-1.912 5.44-8.382 4.41-19.559-2.648-26.617C32.53 2.059 21.647.735 13.412 5.588a2.323 2.323 0 01-2.353 2.353 2.323 2.323 0 01-2.353-2.353 2.323 2.323 0 012.353-2.353c.294 0 .735 0 1.03.147 9.264-5.588 21.47-4.117 29.117 3.53 7.794 7.94 9.118 20.588 2.941 30z"/><path d="M14.588 14.118c-4.559 4.558-5.294 11.764-1.912 17.058.442.589.148 1.471-.44 1.765-.148.147-.442.147-.736.147-.441 0-.882-.294-1.176-.588-3.971-6.324-3.089-14.853 2.352-20.294 5.442-5.441 14.118-6.324 20.589-2.059.588.441.735 1.177.44 1.765-.44.588-1.176.735-1.764.44-5.588-3.676-12.794-2.94-17.353 1.766z"/><path d="M24.294 19.559c-2.353 0-4.118 1.912-4.118 4.117 0 2.353 1.912 4.118 4.118 4.118 2.353 0 4.118-1.912 4.118-4.118 0-2.205-1.912-4.117-4.118-4.117zm0 5.735c-.882 0-1.618-.735-1.618-1.47 0-.883.736-1.618 1.618-1.618.882 0 1.47.735 1.47 1.618 0 .735-.735 1.47-1.47 1.47z"/><path d="M39.735 41.912a2.323 2.323 0 01-2.353 2.353c-.294 0-.588 0-.882-.147A23.852 23.852 0 0124.294 47.5c-6.323 0-12.5-2.5-16.912-6.912-7.794-7.794-9.264-20.294-3.235-29.706.294-.294.588-.44.882-.588.442 0 .736 0 1.03.294.294.147.441.441.588.736.147.294 0 .735-.147 1.029-5.441 8.235-4.118 19.412 2.794 26.323 6.765 6.765 17.5 8.089 25.735 3.236a2.323 2.323 0 012.353-2.353 2.323 2.323 0 012.353 2.353z"/></g></svg>

packages/tdb-dashboard/src/pages/ChangeRequestsPage.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import {
1616
CLOSE
1717
} from "../components/constants"
1818
import ProgressBar from 'react-bootstrap/ProgressBar'
19+
import { FiMoreHorizontal } from "react-icons/fi"
1920
import {extractID, status, iconTypes, getDays} from "../components/utils"
21+
import ButtonGroup from 'react-bootstrap/ButtonGroup';
22+
import Dropdown from 'react-bootstrap/Dropdown';
23+
import DropdownButton from 'react-bootstrap/DropdownButton';
2024
import { Layout } from "./Layout";
2125
import { CR_KEEP_EDITING, CR_READY_FOR_REVIEW, CHANGE_REQUEST_SUBMIT_REVIEW_FOR_DIFF, MERGED_CR } from "../cypress.constants"
2226

@@ -161,9 +165,26 @@ export const ChangeRequestsPage = () => {
161165
setShowUpdateChangeRequestID(id)
162166
}
163167

168+
const OtherActions = () => {
169+
return <DropdownButton
170+
as={ButtonGroup}
171+
key={"secondary"}
172+
id={`dropdown-variants-${"secondary"}`}
173+
variant={"secondary"}
174+
title={"secondary"}>
175+
<Dropdown.Item eventKey="1">Action</Dropdown.Item>
176+
<Dropdown.Item eventKey="2">Another action</Dropdown.Item>
177+
<Dropdown.Item eventKey="3" active>
178+
Active Item
179+
</Dropdown.Item>
180+
<Dropdown.Divider />
181+
<Dropdown.Item eventKey="4">Separated link</Dropdown.Item>
182+
</DropdownButton>
183+
}
184+
164185
function buttonstatus (item, actions) {
165186
const id = extractID(item["@id"])
166-
switch (item.status) {
187+
switch (item.status) {
167188
case OPEN :
168189
return <React.Fragment>
169190
<Button className='btn btn-light btn-sm text-dark mr-4'
@@ -232,6 +253,7 @@ export const ChangeRequestsPage = () => {
232253
</small>
233254
</div>
234255
{buttonstatus(item)}
256+
{/*<OtherActions/>*/}
235257
</ListGroup.Item>
236258
}
237259
})

packages/tdb-react-components/src/treeGraphComponent/ReactFlowComponents/RelationshipGUI.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const nodeTypes = {
5151
};
5252

5353
const RelationshipGUI = (props) => {
54-
const {
54+
const {
5555
changeCurrentNode,
5656
selectedNodeObject,
5757
objPropsRelatedToClass,
@@ -63,7 +63,7 @@ const RelationshipGUI = (props) => {
6363

6464
let { initialNodes, initialEdges } = createNodesAndEdges(selectedNodeObject, objPropsRelatedToClass, propertyList, mainGraphObj);
6565
const [nodes, , onNodesChange] = useNodesState(initialNodes);
66-
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
66+
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
6767

6868
const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), []);
6969

packages/tdb-react-components/src/treeGraphComponent/ReactFlowComponents/utils.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import React from "react"
22
import { CLASS_TYPE_NAME, PROPERTY_TYPE_NAME } from '../utils/elementsName'
33
import { Position } from 'reactflow';
44
import * as style from "./styles"
5+
import { getInheritedProperties } from "../detailsComponent/PropertiesComponent"
56

67

7-
8+
89
export function createNodesAndEdges(selectedNodeObject, objPropsRelatedToClass, propertyList, mainGraphObj) {
910

1011
const initialNodes = [], sourceList = [], targetList = [];
1112
const initialEdges = [];
1213
const center = { x: window.innerWidth / 2, y: window.innerHeight / 2 };
14+
const inheritedProperties= getInheritedProperties();
1315

1416
initialNodes.push({
1517
id: selectedNodeObject.id,
@@ -38,6 +40,18 @@ export function createNodesAndEdges(selectedNodeObject, objPropsRelatedToClass,
3840
}
3941
})
4042

43+
inheritedProperties.map((inheritedProperty) => {
44+
const property = mainGraphObj.getObjectProperty(inheritedProperty.isInherited.inheritedFrom, inheritedProperty.name)
45+
if(property){
46+
sourceList.push({
47+
id: inheritedProperty.isInherited.inheritedFrom,
48+
label: inheritedProperty.isInherited.inheritedFrom,
49+
propertyName: inheritedProperty.name,
50+
linkedToType: selectedNodeObject.type
51+
})
52+
}
53+
})
54+
4155
/*
4256
* get all the relationship where the select node is a source
4357
* current node properties
@@ -121,7 +135,7 @@ export function createNodesAndEdges(selectedNodeObject, objPropsRelatedToClass,
121135
if(targetList[i].linkedToType) {
122136
tNodeTemp.data["style"] = getNodeStyle(targetList[i].linkedToType)
123137
}
124-
initialNodes.push(tNodeTemp)
138+
initialNodes.push(tNodeTemp)
125139
initialEdges.push({
126140
id: `edge-${selectedNodeObject.id}->${targetList[i].id}->${targetList[i].propertyName}`,
127141
//target: targetList[i].id,

packages/tdb-react-components/src/treeGraphComponent/detailsComponent/PropertiesComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const getPropertiesPanels=(propertyList, view)=>{
127127
}
128128

129129
// gather current documents properties along with inheritted properties
130-
const getInheritedProperties = () => {
130+
export const getInheritedProperties = () => {
131131
let inheritedProperties = []
132132
const {
133133
mainGraphObj,
@@ -140,12 +140,12 @@ const getInheritedProperties = () => {
140140
properties.map((propertyItem) => {
141141
propertyItem["isInherited"]={ inheritedFrom: par }
142142
inheritedProperties.push(propertyItem)
143-
})
143+
})
144144
})
145145
return inheritedProperties
146146
}
147147

148-
export const PropertiesComponent = (props)=> {
148+
export const PropertiesComponent = (props)=> {
149149

150150
const {
151151
nodePropertiesList,

packages/tdb-react-components/src/treeGraphComponent/relationshipView/RelationshipView.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,48 @@ import React from 'react'
22
import {RelationshipBox} from './RelationshipBox'
33
import {GraphContextObj} from '../hook/graphObjectContext'
44
import {PROPERTY_TYPE_NAME} from '../utils/elementsName'
5+
import { getInheritedProperties } from "../detailsComponent/PropertiesComponent"
56

67
export const RelationshipView = (props)=>{
7-
const {changeCurrentNode,
8+
const {changeCurrentNode,
89
selectedNodeObject,
910
objPropsRelatedToClass,
1011
mainGraphObj,nodePropertiesList} = GraphContextObj();
1112

1213
const propertyList = nodePropertiesList || {}
14+
const inheritedProperties= getInheritedProperties();
1315
let domainToProp = [], relObjArr = []
1416
/*
1517
* get all the relationship where the select node is a target
1618
*/
1719
objPropsRelatedToClass.map((complexPropertyObj,index)=>{
18-
const propertyDomainName=mainGraphObj.getElement(complexPropertyObj.nodeName,false) || {};
20+
const propertyDomainName=mainGraphObj.getElement(complexPropertyObj.nodeName,false) || {};
1921

20-
const property = mainGraphObj.getObjectProperty(complexPropertyObj.nodeName,complexPropertyObj.propName)
21-
if(property){
22-
const label = property.id || ''
22+
const property = mainGraphObj.getObjectProperty(complexPropertyObj.nodeName,complexPropertyObj.propName)
23+
if(property){
24+
const label = property.id || ''
2325

24-
relObjArr.push(<RelationshipBox source={propertyDomainName}
25-
sourceAction={changeCurrentNode}
26-
target={selectedNodeObject}
27-
propId={label}
28-
key={'rel__'+index}/>)
29-
}
26+
relObjArr.push(<RelationshipBox source={propertyDomainName}
27+
sourceAction={changeCurrentNode}
28+
target={selectedNodeObject}
29+
propId={label}
30+
key={'rel__'+index}/>)
31+
}
32+
})
33+
34+
inheritedProperties.map((inheritedProperty, index) => {
35+
const propertyDomainName=mainGraphObj.getElement(inheritedProperty.isInherited.inheritedFrom, false) || {};
36+
37+
const property = mainGraphObj.getObjectProperty(inheritedProperty.isInherited.inheritedFrom, inheritedProperty.name)
38+
if(property){
39+
const label = property.id || ''
40+
41+
relObjArr.push(<RelationshipBox source={propertyDomainName}
42+
sourceAction={changeCurrentNode}
43+
target={selectedNodeObject}
44+
propId={label}
45+
key={'inherited__'+index}/>)
46+
}
3047
})
3148

3249
/*

0 commit comments

Comments
 (0)