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
a5674ae1
Commit
a5674ae1
authored
2 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Basic history navigator
parent
46d181da
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Implemented editor in the react framework
Pipeline
#56612
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/editor/js/components/editor.tsx
+3
-0
3 additions, 0 deletions
src/editor/js/components/editor.tsx
src/editor/js/components/historynavigator.tsx
+82
-0
82 additions, 0 deletions
src/editor/js/components/historynavigator.tsx
with
85 additions
and
0 deletions
src/editor/js/components/editor.tsx
+
3
−
0
View file @
a5674ae1
...
@@ -9,6 +9,7 @@ import { SpaceSelect } from "./spaceselect";
...
@@ -9,6 +9,7 @@ import { SpaceSelect } from "./spaceselect";
import
"
./editor.css
"
;
import
"
./editor.css
"
;
import
ReactForceGraph2d
from
"
react-force-graph-2d
"
;
import
ReactForceGraph2d
from
"
react-force-graph-2d
"
;
import
{
Node
}
from
"
../structures/graph/node
"
;
import
{
Node
}
from
"
../structures/graph/node
"
;
import
{
HistoryNavigator
}
from
"
./historynavigator
"
;
type
propTypes
=
any
;
type
propTypes
=
any
;
type
stateTypes
=
{
type
stateTypes
=
{
...
@@ -160,6 +161,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -160,6 +161,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
private
handleNodeClick
(
node
:
Node
)
{
private
handleNodeClick
(
node
:
Node
)
{
node
.
delete
();
node
.
delete
();
this
.
forceUpdate
();
}
}
render
():
React
.
ReactNode
{
render
():
React
.
ReactNode
{
...
@@ -169,6 +171,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
...
@@ -169,6 +171,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
<
h1
>
Interface
</
h1
>
<
h1
>
Interface
</
h1
>
<
div
id
=
"content"
>
<
div
id
=
"content"
>
<
div
id
=
"sidepanel"
>
<
div
id
=
"sidepanel"
>
<
HistoryNavigator
spaceId
=
"space"
historyObject
=
{
this
.
state
.
graph
}
/>
<
SpaceSelect
onLoadSpace
=
{
this
.
loadSpace
}
/>
<
SpaceSelect
onLoadSpace
=
{
this
.
loadSpace
}
/>
<
hr
/>
<
hr
/>
<
ToolPool
state
=
{
this
.
state
.
state
}
/>
<
ToolPool
state
=
{
this
.
state
.
state
}
/>
...
...
This diff is collapsed.
Click to expand it.
src/editor/js/components/historynavigator.tsx
0 → 100644
+
82
−
0
View file @
a5674ae1
import
React
,
{
ChangeEvent
}
from
"
react
"
;
import
{
saveGraphJson
}
from
"
../../../datasets
"
;
import
ManagedData
from
"
../structures/manageddata
"
;
type
propTypes
=
{
historyObject
:
ManagedData
;
spaceId
:
string
;
};
export
class
HistoryNavigator
extends
React
.
Component
<
propTypes
>
{
constructor
(
props
:
propTypes
)
{
super
(
props
);
this
.
handleUndo
=
this
.
handleUndo
.
bind
(
this
);
this
.
handleRedo
=
this
.
handleRedo
.
bind
(
this
);
this
.
handleSave
=
this
.
handleSave
.
bind
(
this
);
this
.
handleSelectSavepoint
=
this
.
handleSelectSavepoint
.
bind
(
this
);
}
/**
* Undo a step in the history object.
*/
handleUndo
()
{
if
(
!
this
.
props
.
historyObject
.
undo
())
{
alert
(
"
Something went wrong, could not undo.
"
);
}
}
/**
* Redo a step in the hisory object.
*/
handleRedo
()
{
if
(
!
this
.
props
.
historyObject
.
redo
())
{
alert
(
"
Something went wrong, could not redo.
"
);
}
}
/**
* Saves current data of history object.
*/
handleSave
()
{
saveGraphJson
(
this
.
props
.
spaceId
,
this
.
props
.
historyObject
.
serialize
());
// TODO: Save successful?
this
.
props
.
historyObject
.
markChangesAsSaved
();
alert
(
"
Saved! (Though not for sure, currently not checking for success of failure)
"
);
}
/**
* Loads selected savepoint into history object.
*/
handleSelectSavepoint
(
e
:
ChangeEvent
<
HTMLSelectElement
>
)
{
if
(
!
this
.
props
.
historyObject
.
goToSavePoint
(
Number
(
e
.
target
.
value
)))
{
alert
(
"
Something went wrong, could not load savepoint.
"
);
}
}
render
():
React
.
ReactNode
{
return
(
<
div
id
=
"history-navigator"
>
<
button
onClick
=
{
this
.
handleUndo
}
>
Undo
</
button
>
<
button
onClick
=
{
this
.
handleRedo
}
>
Redo
</
button
>
<
select
onChange
=
{
this
.
handleSelectSavepoint
}
>
{
this
.
props
.
historyObject
?
this
.
props
.
historyObject
.
history
.
map
((
savepoint
)
=>
{
return
(
<
option
key
=
{
savepoint
.
id
}
value
=
{
savepoint
.
id
}
>
{
savepoint
.
description
}
</
option
>
);
})
:
""
}
</
select
>
<
button
onClick
=
{
this
.
handleSave
}
>
Save
</
button
>
</
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