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
89db44e6
Unverified
Commit
89db44e6
authored
May 04, 2020
by
Dominik Prokop
Committed by
GitHub
May 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataLinks: Do not add empty links (#24088)
* Do not add empty links * Review
parent
a5b377e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinkEditorModalContent.tsx
+6
-7
packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksInlineEditor.tsx
+26
-12
No files found.
packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinkEditorModalContent.tsx
View file @
89db44e6
...
...
@@ -9,16 +9,16 @@ interface DataLinkEditorModalContentProps {
index
:
number
;
data
:
DataFrame
[];
suggestions
:
VariableSuggestion
[];
on
Chang
e
:
(
index
:
number
,
ink
:
DataLink
)
=>
void
;
onC
lose
:
(
)
=>
void
;
on
Sav
e
:
(
index
:
number
,
ink
:
DataLink
)
=>
void
;
onC
ancel
:
(
index
:
number
)
=>
void
;
}
export
const
DataLinkEditorModalContent
:
FC
<
DataLinkEditorModalContentProps
>
=
({
link
,
index
,
suggestions
,
on
Chang
e
,
onC
lose
,
on
Sav
e
,
onC
ancel
,
})
=>
{
const
[
dirtyLink
,
setDirtyLink
]
=
useState
(
link
);
return
(
...
...
@@ -35,13 +35,12 @@ export const DataLinkEditorModalContent: FC<DataLinkEditorModalContentProps> = (
<
HorizontalGroup
>
<
Button
onClick=
{
()
=>
{
onChange
(
index
,
dirtyLink
);
onClose
();
onSave
(
index
,
dirtyLink
);
}
}
>
Save
</
Button
>
<
Button
variant=
"secondary"
onClick=
{
()
=>
onC
lose
(
)
}
>
<
Button
variant=
"secondary"
onClick=
{
()
=>
onC
ancel
(
index
)
}
>
Cancel
</
Button
>
</
HorizontalGroup
>
...
...
packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksInlineEditor.tsx
View file @
89db44e6
...
...
@@ -18,26 +18,40 @@ interface DataLinksInlineEditorProps {
export
const
DataLinksInlineEditor
:
React
.
FC
<
DataLinksInlineEditorProps
>
=
({
links
,
onChange
,
suggestions
,
data
})
=>
{
const
theme
=
useTheme
();
const
[
editIndex
,
setEditIndex
]
=
useState
<
number
|
null
>
(
null
);
const
[
isNew
,
setIsNew
]
=
useState
(
false
);
const
styles
=
getDataLinksInlineEditorStyles
(
theme
);
const
linksSafe
:
DataLink
[]
=
links
??
[];
const
isEditing
=
editIndex
!==
null
&&
linksSafe
[
editIndex
]
!==
undefined
;
const
isEditing
=
editIndex
!==
null
;
const
onDataLinkChange
=
(
index
:
number
,
link
:
DataLink
)
=>
{
if
(
isNew
)
{
if
(
link
.
title
.
trim
()
===
''
&&
link
.
url
.
trim
()
===
''
)
{
setIsNew
(
false
);
setEditIndex
(
null
);
return
;
}
else
{
setEditIndex
(
null
);
setIsNew
(
false
);
}
}
const
update
=
cloneDeep
(
linksSafe
);
update
[
index
]
=
link
;
onChange
(
update
);
setEditIndex
(
null
);
};
const
onDataLinkAdd
=
()
=>
{
let
update
=
cloneDeep
(
linksSafe
);
setEditIndex
(
update
.
length
);
setIsNew
(
true
);
};
update
.
push
({
title
:
''
,
url
:
''
,
});
setEditIndex
(
update
.
length
-
1
);
onChange
(
update
);
const
onDataLinkCancel
=
(
index
:
number
)
=>
{
if
(
isNew
)
{
setIsNew
(
false
);
}
setEditIndex
(
null
);
};
const
onDataLinkRemove
=
(
index
:
number
)
=>
{
...
...
@@ -72,15 +86,15 @@ export const DataLinksInlineEditor: React.FC<DataLinksInlineEditorProps> = ({ li
title=
"Edit link"
isOpen=
{
true
}
onDismiss=
{
()
=>
{
setEditIndex
(
null
);
onDataLinkCancel
(
editIndex
);
}
}
>
<
DataLinkEditorModalContent
index=
{
editIndex
}
link=
{
linksSafe
[
editIndex
]
}
link=
{
isNew
?
{
title
:
''
,
url
:
''
}
:
linksSafe
[
editIndex
]
}
data=
{
data
}
on
Chang
e=
{
onDataLinkChange
}
onC
lose=
{
()
=>
setEditIndex
(
null
)
}
on
Sav
e=
{
onDataLinkChange
}
onC
ancel=
{
onDataLinkCancel
}
suggestions=
{
suggestions
}
/>
</
Modal
>
...
...
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