Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-canvas relationship creation is done by sending message only #41

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/modules/ROOT/pages/operations/on-canvas-operations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ image:modifying-node-properties-example.png[width=600]
Similary, we can modify node label:

image:modifying-node-label-example.png[width=600]

== Creating On-Canvas Relationships

Alt-clicking one node, release the alk key, and alt-clicking another node will create a relationship between the two

30 changes: 30 additions & 0 deletions e2e_tests/integration/viz.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,34 @@ describe('Viz rendering', () => {

cy.executeCommand('MATCH (n) DETACH DELETE n')
})

it('can create a new relationship by alt-clicking two nodes in sequence', () => {
cy.executeCommand(':clear')
cy.executeCommand('MATCH (n) DETACH DELETE n')
cy.executeCommand(`CREATE (s:SourceNode {name: 'sourceNode'}) RETURN s`, {
parseSpecialCharSequences: false
})
.executeCommand(`CREATE (t:TargetNode {name: 'targetNode'}) RETURN t`, {
parseSpecialCharSequences: false
})
.executeCommand(`MATCH (n) RETURN n`, {
parseSpecialCharSequences: false
})

cy.wait(3000)

cy.get(`[aria-label^="graph-node"]`)
.each($el => {
cy.wrap($el).rightclick({
altKey: true,
metaKey: true,
shiftKey: true,
ctrlKey: true,
multiple: true,
force: true
})
})
.get('.relationships')
.should('exist')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ LIMIT ${maxNewNeighbours}`
}
}
)

const cmd = 'MATCH (n) RETURN n;'
const action = executeCommand(cmd, { source: commandSources.rerunFrame })
this.props.bus.send(action.type, action)
}

if (event == NODE_ON_CANVAS_CREATE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,28 +276,8 @@ export class GraphEventHandlerModel {
) {
this.altCreatedRelTargetNode = node

const transientId: string =
'transient-' + Math.random().toString(36).slice(2)

const altCreatedRel: RelationshipModel = new RelationshipModel(
transientId,
this.altCreatedRelSourceNode,
this.altCreatedRelTargetNode,
transientId,
{ name: 'new link' },
{ name: 'string' },
transientId
)

this.graph.addRelationships([altCreatedRel])
this.visualization.update({
updateNodes: true,
updateRelationships: true
})
this.graphModelChanged()

this.onGraphInteraction(REL_ON_CANVAS_CREATE, {
type: transientId,
type: Math.random().toString(36).slice(2),
sourceNodeId: this.altCreatedRelSourceNode.id,
targetNodeId: this.altCreatedRelTargetNode.id
})
Expand Down
2 changes: 1 addition & 1 deletion src/neo4j-arc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neo4j-devtools-arc",
"version": "0.0.69",
"version": "0.0.70",
"main": "dist/neo4j-arc.js",
"author": "Neo4j Inc.",
"license": "GPL-3.0",
Expand Down