Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Frontend V2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Contributor 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
GraphPolaris
Frontend V2
Commits
267d312e
Commit
267d312e
authored
5 months ago
by
Dennis Collaris
Browse files
Options
Downloads
Patches
Plain Diff
feat: add insert variables dropdown for visualizations
parent
5d099c7d
No related branches found
Branches containing commit
Tags
v1.96.1
Tags containing commit
1 merge request
!254
feat: add insert variables dropdown for visualizations
Pipeline
#139627
passed
5 months ago
Stage: tag-release
Stage: get-release-tag
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/shared/lib/components/textEditor/VariableNode.tsx
+11
-3
11 additions, 3 deletions
libs/shared/lib/components/textEditor/VariableNode.tsx
libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx
+22
-7
22 additions, 7 deletions
...b/components/textEditor/plugins/InsertVariablesPlugin.tsx
with
33 additions
and
10 deletions
libs/shared/lib/components/textEditor/VariableNode.tsx
+
11
−
3
View file @
267d312e
...
...
@@ -2,21 +2,29 @@ import type { NodeKey, LexicalEditor, DOMExportOutput } from 'lexical';
import
{
DecoratorNode
,
EditorConfig
}
from
'
lexical
'
;
export
enum
VariableType
{
statistic
,
visualization
};
export
class
VariableNode
extends
DecoratorNode
<
JSX
.
Element
>
{
__name
:
string
;
__variableType
:
VariableType
;
static
getType
():
string
{
return
'
variable-node
'
;
}
static
clone
(
node
:
VariableNode
):
VariableNode
{
return
new
VariableNode
(
node
.
__name
,
node
.
__key
);
return
new
VariableNode
(
node
.
__name
,
node
.
__variableType
,
node
.
__key
);
}
constructor
(
name
:
string
,
key
?:
NodeKey
)
{
constructor
(
name
:
string
,
type
:
VariableType
,
key
?:
NodeKey
)
{
super
(
key
);
this
.
__name
=
name
;
this
.
__variableType
=
type
;
}
setName
(
name
:
string
)
{
...
...
@@ -31,7 +39,7 @@ export class VariableNode extends DecoratorNode<JSX.Element> {
getTextContent
():
string
{
const
self
=
this
.
getLatest
();
return
`{{
${
self
.
__name
}
}}`
;
return
`{{
${
self
.
__variableType
}
:
${
self
.
__name
}
}}`
;
}
// View
...
...
This diff is collapsed.
Click to expand it.
libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx
+
22
−
7
View file @
267d312e
...
...
@@ -10,18 +10,22 @@ import {
$parseSerializedNode
}
from
"
lexical
"
;
import
{
Input
}
from
'
@graphpolaris/shared/lib/components/inputs
'
;
import
{
VariableNode
}
from
'
../VariableNode
'
;
import
{
VariableNode
,
VariableType
}
from
'
../VariableNode
'
;
import
{
useState
}
from
'
react
'
;
import
{
useGraphQueryResult
}
from
'
@graphpolaris/shared/lib/data-access
'
;
import
{
useGraphQueryResult
,
useVisualization
}
from
'
@graphpolaris/shared/lib/data-access
'
;
export
const
InsertVariablesPlugin
=
()
=>
{
const
[
editor
]
=
useLexicalComposerContext
();
const
{
openVisualizationArray
}
=
useVisualization
();
const
onChange
=
(
value
:
string
|
number
)
=>
{
const
visualizationOptions
=
openVisualizationArray
.
map
(
x
=>
x
.
name
);
const
onChange
=
(
value
:
string
|
number
,
type
:
VariableType
)
=>
{
editor
.
update
(()
=>
{
const
selection
=
$getSelection
()
as
BaseSelection
;
const
node
=
new
VariableNode
(
String
(
value
));
const
node
=
new
VariableNode
(
String
(
value
)
,
type
);
selection
.
insertNodes
([
node
]);
...
...
@@ -43,13 +47,24 @@ export const InsertVariablesPlugin = () => {
return
Object
.
entries
(
typeObj
.
attributes
).
map
(([
k
,
v
])
=>
Object
.
keys
(
v
).
map
(
x
=>
`
${
k
}
_
${
x
}
`
)).
flat
();
}
return
nodeTypes
.
map
((
nodeType
)
=>
return
<>
{
nodeTypes
.
map
((
nodeType
)
=>
<
Input
type
=
"dropdown"
label
=
{
`
${
nodeType
}
variable`
}
value
=
""
options
=
{
optionsForType
(
nodeType
)
}
onChange
=
{
onChange
}
onChange
=
{
(
v
)
=>
onChange
(
v
,
VariableType
.
statistic
)
}
/>
);
)
}
{
(
visualizationOptions
.
length
>
0
)
?
<
Input
type
=
"dropdown"
label
=
{
`Visualization`
}
value
=
""
options
=
{
visualizationOptions
}
onChange
=
{
(
v
)
=>
onChange
(
v
,
VariableType
.
visualization
)
}
/>
:
''
}
</>;
};
\ No newline at end of file
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