Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
feb6bc67
Unverified
Commit
feb6bc67
authored
Sep 23, 2019
by
Dominik Prokop
Committed by
GitHub
Sep 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataLinks: Small UX improvements to DataLinksInput (#19313)
Closes #19257
parent
9bd6ed88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
packages/grafana-ui/src/components/DataLinks/DataLinkInput.tsx
+4
-6
No files found.
packages/grafana-ui/src/components/DataLinks/DataLinkInput.tsx
View file @
feb6bc67
...
...
@@ -64,7 +64,7 @@ export const DataLinkInput: React.FC<DataLinkInputProps> = ({ value, onChange, s
stateRef
.
current
=
{
showingSuggestions
,
currentSuggestions
,
suggestionsIndex
,
linkUrl
,
onChange
};
// SelectionReference is used to position the variables suggestion relatively to current DOM selection
const
selectionRef
=
useMemo
(()
=>
new
SelectionReference
(),
[
setShowingSuggestions
]);
const
selectionRef
=
useMemo
(()
=>
new
SelectionReference
(),
[
setShowingSuggestions
,
linkUrl
]);
// Keep track of variables that has been used already
const
updateUsedSuggestions
=
()
=>
{
...
...
@@ -79,7 +79,7 @@ export const DataLinkInput: React.FC<DataLinkInputProps> = ({ value, onChange, s
const
onKeyDown
=
React
.
useCallback
((
event
:
KeyboardEvent
,
next
:
()
=>
any
)
=>
{
if
(
!
stateRef
.
current
.
showingSuggestions
)
{
if
(
event
.
key
===
'
?'
||
event
.
key
===
'&
'
||
event
.
key
===
'$'
||
(
event
.
keyCode
===
32
&&
event
.
ctrlKey
))
{
if
(
event
.
key
===
'
=
'
||
event
.
key
===
'$'
||
(
event
.
keyCode
===
32
&&
event
.
ctrlKey
))
{
return
setShowingSuggestions
(
true
);
}
return
next
();
...
...
@@ -100,7 +100,6 @@ export const DataLinkInput: React.FC<DataLinkInputProps> = ({ value, onChange, s
event
.
preventDefault
();
const
direction
=
event
.
key
===
'ArrowDown'
?
1
:
-
1
;
return
setSuggestionsIndex
(
index
=>
modulo
(
index
+
direction
,
stateRef
.
current
.
currentSuggestions
.
length
));
default
:
return
next
();
}
...
...
@@ -118,8 +117,7 @@ export const DataLinkInput: React.FC<DataLinkInputProps> = ({ value, onChange, s
},
[]);
const
onVariableSelect
=
(
item
:
VariableSuggestion
,
editor
=
editorRef
.
current
!
)
=>
{
const
includeDollarSign
=
Plain
.
serialize
(
linkUrl
).
slice
(
-
1
)
!==
'$'
;
const
includeDollarSign
=
Plain
.
serialize
(
editor
.
value
).
slice
(
-
1
)
!==
'$'
;
if
(
item
.
origin
!==
VariableOrigin
.
Template
||
item
.
value
===
DataLinkBuiltInVars
.
includeVars
)
{
editor
.
insertText
(
`
${
includeDollarSign
?
'$'
:
''
}
\{
${
item
.
value
}
}`
);
}
else
{
...
...
@@ -150,7 +148,7 @@ export const DataLinkInput: React.FC<DataLinkInputProps> = ({ value, onChange, s
<
Portal
>
<
ReactPopper
referenceElement=
{
selectionRef
}
placement=
"
auto
-end"
placement=
"
top
-end"
modifiers=
{
{
preventOverflow
:
{
enabled
:
true
,
boundariesElement
:
'window'
},
arrow
:
{
enabled
:
false
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment