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
22566c23
Commit
22566c23
authored
2 years ago
by
Matthias Konitzny
Browse files
Options
Downloads
Patches
Plain Diff
Moved sidepanel to its own component
parent
0574d98c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/editor/components/settings.tsx
+1
-1
1 addition, 1 deletion
src/editor/components/settings.tsx
src/editor/components/sidepanel.tsx
+71
-0
71 additions, 0 deletions
src/editor/components/sidepanel.tsx
src/editor/editor.tsx
+31
-55
31 additions, 55 deletions
src/editor/editor.tsx
with
103 additions
and
56 deletions
src/editor/components/settings.tsx
+
1
−
1
View file @
22566c23
import
React
from
"
react
"
;
interface
SettingsProps
{
labelVisibility
:
boolean
;
labelVisibility
:
boolean
;
// TODO: Refactor to one settings object
onLabelVisibilityChange
:
(
state
:
boolean
)
=>
void
;
connectOnDrag
:
boolean
;
...
...
This diff is collapsed.
Click to expand it.
src/editor/components/sidepanel.tsx
0 → 100644
+
71
−
0
View file @
22566c23
import
React
from
"
react
"
;
import
HistoryNavigator
from
"
./historynavigator
"
;
import
{
DynamicGraph
}
from
"
../graph
"
;
import
NodeDetails
from
"
./nodedetails
"
;
import
{
NodeTypesEditor
}
from
"
./nodetypeseditor
"
;
import
Settings
from
"
./settings
"
;
import
Instructions
from
"
./instructions
"
;
import
{
Checkpoint
,
History
}
from
"
../../common/history
"
;
import
{
Node
}
from
"
../../common/graph/node
"
;
import
{
NodeType
}
from
"
../../common/graph/nodetype
"
;
import
{
SimGraphData
}
from
"
../../common/graph/graph
"
;
import
{
NodeDataChangeRequest
}
from
"
../editor
"
;
interface
SidepanelProps
{
graph
:
DynamicGraph
;
onCheckpointLoad
:
{
(
checkpoint
:
Checkpoint
<
SimGraphData
>
):
void
};
onNodeTypeSelect
:
(
type
:
NodeType
)
=>
void
;
onConnectOnDragChange
:
(
connectOnDrag
:
boolean
)
=>
void
;
onLabelVisibilityChange
:
(
state
:
boolean
)
=>
void
;
onNodeDataChange
:
{
(
requests
:
NodeDataChangeRequest
[]):
void
};
selectedNodes
:
Node
[];
visibleLabels
:
boolean
;
connectOnDrag
:
boolean
;
}
function
Sidepanel
({
graph
,
onCheckpointLoad
,
onNodeTypeSelect
,
onConnectOnDragChange
,
onLabelVisibilityChange
,
onNodeDataChange
,
selectedNodes
,
visibleLabels
,
connectOnDrag
,
}:
SidepanelProps
)
{
return
(
<
div
id
=
"sidepanel"
>
<
HistoryNavigator
history
=
{
graph
.
history
}
onCheckpointLoad
=
{
onCheckpointLoad
}
/>
<
hr
/>
<
NodeDetails
selectedNodes
=
{
selectedNodes
}
nameToObjectType
=
{
graph
.
nameToObjectGroup
}
// TODO: Change to id
onNodeDataChange
=
{
onNodeDataChange
}
/>
<
hr
/>
<
NodeTypesEditor
onChange
=
{
()
=>
console
.
log
(
"
Refactor onChange for nodetypes editor!
"
)
}
// TODO: Refactor
graph
=
{
graph
}
onSelectAll
=
{
onNodeTypeSelect
}
/>
<
hr
/>
<
Settings
labelVisibility
=
{
visibleLabels
}
onLabelVisibilityChange
=
{
onLabelVisibilityChange
}
connectOnDrag
=
{
connectOnDrag
}
onConnectOnDragChange
=
{
onConnectOnDragChange
}
/>
<
hr
/>
<
Instructions
connectOnDragEnabled
=
{
connectOnDrag
}
/>
</
div
>
);
}
export
default
Sidepanel
;
This diff is collapsed.
Click to expand it.
src/editor/editor.tsx
+
31
−
55
View file @
22566c23
import
React
from
"
react
"
;
import
{
DynamicGraph
}
from
"
./graph
"
;
import
{
listAllSpaces
,
loadGraphJson
}
from
"
../common/datasets
"
;
import
NodeDetails
from
"
./components/nodedetails
"
;
import
SpaceSelect
from
"
./components/spaceselect
"
;
import
"
./editor.css
"
;
import
*
as
Helpers
from
"
../common/helpers
"
;
import
{
Node
,
NodeProperties
}
from
"
../common/graph/node
"
;
import
{
NodeTypesEditor
}
from
"
./components/nodetypeseditor
"
;
import
{
SpaceManager
}
from
"
./components/spacemanager
"
;
import
{
SelectLayer
}
from
"
./components/selectlayer
"
;
import
{
GraphData
}
from
"
../common/graph/graph
"
;
import
{
NodeType
}
from
"
../common/graph/nodetype
"
;
import
{
GraphRenderer2D
}
from
"
./renderer
"
;
import
Instructions
from
"
./components/instructions
"
;
import
Settings
from
"
./components/settings
"
;
import
HistoryNavigator
from
"
./components/historynavigator
"
;
import
*
as
Config
from
"
../config
"
;
import
Sidepanel
from
"
./components/sidepanel
"
;
export
interface
NodeDataChangeRequest
extends
NodeProperties
{
id
:
number
;
type
:
NodeType
;
}
type
propTypes
=
{};
type
stateTypes
=
{
/**
* Graph structure holding the basic information.
...
...
@@ -63,11 +58,11 @@ type stateTypes = {
/**
* Knowledge space graph editor. Allows easy editing of the graph structure.
*/
export
class
Editor
extends
React
.
PureComponent
<
propTypes
,
stateTypes
>
{
export
class
Editor
extends
React
.
PureComponent
<
any
,
stateTypes
>
{
private
graphContainer
:
React
.
RefObject
<
HTMLDivElement
>
;
private
rendererRef
:
React
.
RefObject
<
GraphRenderer2D
>
;
constructor
(
props
:
propTypes
)
{
constructor
(
props
:
any
)
{
super
(
props
);
// Making sure, all functions retain the proper this-bind
...
...
@@ -273,55 +268,36 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
/>
</
SelectLayer
>
</
div
>
<
div
id
=
"sidepanel"
>
<
HistoryNavigator
history
=
{
this
.
state
.
graph
.
history
}
onCheckpointLoad
=
{
(
checkpoint
)
=>
{
const
graph
=
new
DynamicGraph
();
this
.
setState
({
graph
:
graph
.
fromSerializedObject
(
checkpoint
.
data
),
});
}
}
/>
<
hr
/>
<
NodeDetails
selectedNodes
=
{
this
.
state
.
selectedNodes
}
nameToObjectType
=
{
this
.
state
.
graph
.
nameToObjectGroup
}
// TODO: Change to id
onNodeDataChange
=
{
this
.
handleNodeDataChange
}
/>
<
hr
/>
<
NodeTypesEditor
onChange
=
{
this
.
forceUpdate
}
graph
=
{
this
.
state
.
graph
}
onSelectAll
=
{
this
.
handleNodeTypeSelect
}
/>
<
hr
/>
<
Settings
labelVisibility
=
{
this
.
state
.
visibleLabels
}
onLabelVisibilityChange
=
{
(
visible
)
=>
this
.
setState
({
visibleLabels
:
visible
,
})
}
connectOnDrag
=
{
this
.
state
.
connectOnDrag
}
onConnectOnDragChange
=
{
(
connectOnDrag
)
=>
this
.
setState
({
connectOnDrag
:
connectOnDrag
,
})
}
/>
<
hr
/>
<
Instructions
connectOnDragEnabled
=
{
this
.
state
.
connectOnDrag
}
/>
</
div
>
</
div
>
)
}
{
this
.
state
.
graph
&&
(
<
Sidepanel
graph
=
{
this
.
state
.
graph
}
onCheckpointLoad
=
{
(
checkpoint
)
=>
{
const
graph
=
new
DynamicGraph
();
this
.
setState
({
graph
:
graph
.
fromSerializedObject
(
checkpoint
.
data
),
});
}
}
onNodeTypeSelect
=
{
this
.
handleNodeTypeSelect
}
onConnectOnDragChange
=
{
(
connectOnDrag
)
=>
this
.
setState
({
connectOnDrag
:
connectOnDrag
,
})
}
onLabelVisibilityChange
=
{
(
visible
)
=>
this
.
setState
({
visibleLabels
:
visible
,
})
}
selectedNodes
=
{
this
.
state
.
selectedNodes
}
visibleLabels
=
{
this
.
state
.
visibleLabels
}
connectOnDrag
=
{
this
.
state
.
connectOnDrag
}
onNodeDataChange
=
{
this
.
handleNodeDataChange
}
/>
)
}
</
div
>
);
}
...
...
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