Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
d488c0bc
Commit
d488c0bc
authored
2 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Makes connect on drag optional and implementes proper labels for checkboxes
parent
51a86d0c
No related branches found
No related tags found
1 merge request
!2
Implemented editor in the react framework
Pipeline
#56799
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/editor/js/components/editor.tsx
+37
-2
37 additions, 2 deletions
src/editor/js/components/editor.tsx
with
37 additions
and
2 deletions
src/editor/js/components/editor.tsx
+
37
−
2
View file @
d488c0bc
...
@@ -15,6 +15,7 @@ type propTypes = any;
...
@@ -15,6 +15,7 @@ type propTypes = any;
type
stateTypes
=
{
type
stateTypes
=
{
graph
:
Graph
;
graph
:
Graph
;
visibleLabels
:
boolean
;
visibleLabels
:
boolean
;
connectOnDrag
:
boolean
;
selectedNode
:
Node
;
selectedNode
:
Node
;
keys
:
{
[
name
:
string
]:
boolean
};
keys
:
{
[
name
:
string
]:
boolean
};
};
};
...
@@ -60,6 +61,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -60,6 +61,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
this
.
state
=
{
this
.
state
=
{
graph
:
undefined
,
graph
:
undefined
,
visibleLabels
:
true
,
visibleLabels
:
true
,
connectOnDrag
:
true
,
selectedNode
:
undefined
,
selectedNode
:
undefined
,
keys
:
{},
keys
:
{},
};
};
...
@@ -338,6 +340,11 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -338,6 +340,11 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
private
handleNodeDrag
(
node
:
Node
,
translate
:
positionTranslate
)
{
private
handleNodeDrag
(
node
:
Node
,
translate
:
positionTranslate
)
{
this
.
selectNode
(
node
);
this
.
selectNode
(
node
);
// Should run connect logic?
if
(
!
this
.
state
.
connectOnDrag
)
{
return
;
}
const
closest
=
this
.
state
.
graph
.
getClosestOtherNode
(
node
);
const
closest
=
this
.
state
.
graph
.
getClosestOtherNode
(
node
);
// Is close enough for new link?
// Is close enough for new link?
...
@@ -396,7 +403,13 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -396,7 +403,13 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
<
li
>
CTRL+Click node to delete
</
li
>
<
li
>
CTRL+Click node to delete
</
li
>
<
li
>
Click link to delete
</
li
>
<
li
>
Click link to delete
</
li
>
<
li
>
SHIFT+Click a second node to connect
</
li
>
<
li
>
SHIFT+Click a second node to connect
</
li
>
<
li
>
Drag node close to other node to connect
</
li
>
{
this
.
state
.
connectOnDrag
?
(
<
li
>
Drag node close to other node to connect
</
li
>
)
:
(
""
)
}
</
ul
>
</
ul
>
<
hr
/>
<
hr
/>
<
NodeDetails
<
NodeDetails
...
@@ -409,6 +422,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -409,6 +422,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
<
hr
/>
<
hr
/>
<
div
>
<
div
>
<
input
<
input
id
=
"node-labe-visibility"
type
=
{
"
checkbox
"
}
type
=
{
"
checkbox
"
}
checked
=
{
this
.
state
.
visibleLabels
}
checked
=
{
this
.
state
.
visibleLabels
}
onChange
=
{
(
event
)
=>
{
onChange
=
{
(
event
)
=>
{
...
@@ -422,7 +436,28 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -422,7 +436,28 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
});
});
}
}
}
}
/>
/>
Node labels // TODO: Proper label for checkbox
<
label
htmlFor
=
"node-labe-visibility"
>
Node labels
</
label
>
<
br
/>
<
input
id
=
"connect-on-drag"
type
=
{
"
checkbox
"
}
checked
=
{
this
.
state
.
connectOnDrag
}
onChange
=
{
(
event
)
=>
{
const
newValue
=
event
.
target
.
checked
;
if
(
newValue
==
this
.
state
.
connectOnDrag
)
{
return
;
}
this
.
setState
({
connectOnDrag
:
newValue
,
});
}
}
/>
<
label
htmlFor
=
"connect-on-drag"
>
Connect nodes when dragged
</
label
>
</
div
>
</
div
>
</
div
>
</
div
>
{
this
.
state
.
graph
?
(
{
this
.
state
.
graph
?
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment