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
ed8c3430
Unverified
Commit
ed8c3430
authored
Apr 17, 2020
by
Hugo Häggmark
Committed by
GitHub
Apr 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PanelEditorTabs: adds counter to Query, Alert and Transform (#23645)
parent
89c8855f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
packages/grafana-ui/src/components/Tabs/Tab.tsx
+1
-1
public/app/features/dashboard/components/PanelEditor/PanelEditorTabs.tsx
+18
-1
No files found.
packages/grafana-ui/src/components/Tabs/Tab.tsx
View file @
ed8c3430
...
...
@@ -67,7 +67,7 @@ export const Tab: FC<TabProps> = ({ label, active, icon, onChangeTab, counter })
<
li
className=
{
cx
(
tabsStyles
.
tabItem
,
active
&&
tabsStyles
.
activeStyle
)
}
onClick=
{
onChangeTab
}
>
{
icon
&&
<
Icon
name=
{
icon
}
/>
}
{
label
}
{
!!
counter
&&
<
Counter
value=
{
counter
}
/>
}
{
typeof
counter
===
'number'
&&
<
Counter
value=
{
counter
}
/>
}
</
li
>
);
};
public/app/features/dashboard/components/PanelEditor/PanelEditorTabs.tsx
View file @
ed8c3430
import
React
from
'react'
;
import
React
,
{
useCallback
}
from
'react'
;
import
{
config
}
from
'app/core/config'
;
import
{
css
}
from
'emotion'
;
import
{
IconName
,
stylesFactory
,
Tab
,
TabContent
,
TabsBar
}
from
'@grafana/ui'
;
...
...
@@ -22,6 +22,22 @@ interface PanelEditorTabsProps {
export
const
PanelEditorTabs
:
React
.
FC
<
PanelEditorTabsProps
>
=
({
panel
,
dashboard
,
tabs
,
data
,
onChangeTab
})
=>
{
const
styles
=
getPanelEditorTabsStyles
();
const
activeTab
=
tabs
.
find
(
item
=>
item
.
active
);
const
getCounter
=
useCallback
(
(
tab
:
PanelEditorTab
)
=>
{
switch
(
tab
.
id
)
{
case
PanelEditorTabId
.
Query
:
return
panel
.
targets
.
length
;
case
PanelEditorTabId
.
Alert
:
return
panel
.
alert
?
1
:
0
;
case
PanelEditorTabId
.
Transform
:
const
transformations
=
panel
.
getTransformations
()
??
[];
return
transformations
.
length
;
}
return
null
;
},
[
panel
]
);
if
(
tabs
.
length
===
0
)
{
return
null
;
...
...
@@ -42,6 +58,7 @@ export const PanelEditorTabs: React.FC<PanelEditorTabsProps> = ({ panel, dashboa
active=
{
tab
.
active
}
onChangeTab=
{
()
=>
onChangeTab
(
tab
)
}
icon=
{
tab
.
icon
as
IconName
}
counter=
{
getCounter
(
tab
)
}
/>
);
})
}
...
...
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