This repository has been archived by the owner on Oct 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add domain model for react nodes
- Loading branch information
1 parent
bf31693
commit 0922089
Showing
20 changed files
with
282 additions
and
234 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { ApplicationNodeData, InternalProps } from '../../types'; | ||
|
||
type ApplicationProps = ApplicationNodeData & InternalProps; | ||
|
||
/** | ||
* The Application component is a single instance of grouped outgoing and incoming channels. | ||
* | ||
* What you define as an instance can be application, grouped or single server less function, etc. | ||
*/ | ||
export const Application: React.FunctionComponent<ApplicationProps> = props => { | ||
const nodeData = { | ||
...props, | ||
}; | ||
delete nodeData.children; | ||
delete nodeData.internal; | ||
const applicationNodeData: ApplicationNodeData = nodeData; | ||
|
||
props.internal?.addApplicationCallback(applicationNodeData); | ||
|
||
const childrenWithProps = React.Children.map(props.children, child => { | ||
if (React.isValidElement(child)) { | ||
return React.cloneElement(child, { | ||
forApplication: applicationNodeData.id, | ||
internal: props.internal, | ||
}); | ||
} | ||
return child; | ||
}); | ||
|
||
return <div key={applicationNodeData.id}>{childrenWithProps}</div>; | ||
}; |
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
File renamed without changes.
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,13 @@ | ||
import React from 'react'; | ||
import { IncomingNodeData, InternalProps } from '../../types'; | ||
|
||
type IncomingProps = IncomingNodeData & InternalProps; | ||
export const Incoming: React.FunctionComponent<IncomingProps> = props => { | ||
const nodeData = { ...props }; | ||
delete nodeData.children; | ||
delete nodeData.internal; | ||
const incomingNodeData: IncomingNodeData = nodeData; | ||
|
||
props.internal?.addIncomingCallback(incomingNodeData); | ||
return null; | ||
}; |
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,12 @@ | ||
import React from 'react'; | ||
import { InternalProps, OutgoingNodeData } from '../../types'; | ||
|
||
type OutgoingProps = OutgoingNodeData & InternalProps; | ||
export const Outgoing: React.FunctionComponent<OutgoingProps> = props => { | ||
const nodeData = { ...props }; | ||
delete nodeData.children; | ||
delete nodeData.internal; | ||
const outgoingNodeData: OutgoingNodeData = nodeData; | ||
props.internal?.addOutgoingCallback(outgoingNodeData); | ||
return null; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,11 +1,4 @@ | ||
import OutgoingNode from './OutgoingNode'; | ||
import IncomingNode from './IncomingNode'; | ||
import ApplicationNode from './ApplicationNode'; | ||
|
||
const nodeTypes = { | ||
outgoingNode: OutgoingNode, | ||
incomingNode: IncomingNode, | ||
applicationNode: ApplicationNode, | ||
}; | ||
|
||
export default nodeTypes; | ||
export * from './AsyncAPIApplication'; | ||
export * from './Application'; | ||
export * from './Incoming'; | ||
export * from './Outgoing'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
library/src/components/react-flow-renderer-nodes/index.tsx
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,11 @@ | ||
import OutgoingNode from './OutgoingNode'; | ||
import IncomingNode from './IncomingNode'; | ||
import ApplicationNode from './ApplicationNode'; | ||
|
||
const nodeTypes = { | ||
outgoingNode: OutgoingNode, | ||
incomingNode: IncomingNode, | ||
applicationNode: ApplicationNode, | ||
}; | ||
|
||
export default nodeTypes; |
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,7 +1,7 @@ | ||
export * from './visualiser/ApplicationView'; | ||
export * from './visualiser/SystemView'; | ||
export * from './components/nodes/factories/Application'; | ||
export * from './components/nodes/factories/Incoming'; | ||
export * from './components/nodes/factories/Outgoing'; | ||
export * from './components/nodes/factories/AsyncAPIApplication'; | ||
export * from './visualiser/react-flow-renderer/ApplicationView'; | ||
export * from './visualiser/react-flow-renderer/SystemView'; | ||
export * from './components/nodes/Application'; | ||
export * from './components/nodes/Incoming'; | ||
export * from './components/nodes/Outgoing'; | ||
export * from './components/nodes/AsyncAPIApplication'; | ||
export * from './components/layouts'; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.