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
a9b5cbf3
Commit
a9b5cbf3
authored
Nov 13, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adced clickoutside wrapper
parent
a0496d55
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
5 deletions
+70
-5
public/app/core/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx
+36
-0
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
+32
-4
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx
+2
-1
No files found.
public/app/core/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx
0 → 100644
View file @
a9b5cbf3
import
{
PureComponent
}
from
'react'
;
import
ReactDOM
from
'react-dom'
;
export
interface
Props
{
onClick
:
()
=>
void
;
}
interface
State
{
hasEventListener
:
boolean
;
}
export
class
ClickOutsideWrapper
extends
PureComponent
<
Props
,
State
>
{
state
=
{
hasEventListener
:
false
,
};
componentDidMount
()
{
window
.
addEventListener
(
'click'
,
this
.
onOutsideClick
,
false
);
}
componentWillUnmount
()
{
window
.
removeEventListener
(
'click'
,
this
.
onOutsideClick
,
false
);
}
onOutsideClick
=
event
=>
{
const
domNode
=
ReactDOM
.
findDOMNode
(
this
)
as
Element
;
if
(
!
domNode
||
!
domNode
.
contains
(
event
.
target
))
{
this
.
props
.
onClick
();
}
};
render
()
{
return
this
.
props
.
children
;
}
}
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
View file @
a9b5cbf3
...
...
@@ -5,13 +5,37 @@ import { PanelHeaderMenu } from './PanelHeaderMenu';
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
{
ClickOutsideWrapper
}
from
'../../../../core/components/ClickOutsideWrapper/ClickOutsideWrapper'
;
export
interface
Props
{
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
}
export
class
PanelHeader
extends
PureComponent
<
Props
>
{
interface
State
{
panelMenuOpen
:
boolean
;
}
export
class
PanelHeader
extends
PureComponent
<
Props
,
State
>
{
state
=
{
panelMenuOpen
:
false
,
};
onMenuToggle
=
event
=>
{
event
.
stopPropagation
();
console
.
log
(
'toggle menu'
);
this
.
setState
(
prevState
=>
({
panelMenuOpen
:
!
prevState
.
panelMenuOpen
,
}));
};
closeMenu
=
()
=>
{
this
.
setState
({
panelMenuOpen
:
false
,
});
};
render
()
{
const
isFullscreen
=
false
;
const
isLoading
=
false
;
...
...
@@ -31,14 +55,18 @@ export class PanelHeader extends PureComponent<Props> {
</
span
>
)
}
<
div
className=
"panel-title-container"
>
<
div
className=
"panel-title-container"
onClick=
{
this
.
onMenuToggle
}
>
<
div
className=
"panel-title"
>
<
span
className=
"icon-gf panel-alert-icon"
/>
<
span
className=
"panel-title-text"
data
-
toggle=
"dropdown"
>
<
span
className=
"panel-title-text"
>
{
panel
.
title
}
<
span
className=
"fa fa-caret-down panel-menu-toggle"
/>
</
span
>
<
PanelHeaderMenu
panel=
{
panel
}
dashboard=
{
dashboard
}
/>
{
this
.
state
.
panelMenuOpen
&&
(
<
ClickOutsideWrapper
onClick=
{
this
.
closeMenu
}
>
<
PanelHeaderMenu
panel=
{
panel
}
dashboard=
{
dashboard
}
/>
</
ClickOutsideWrapper
>
)
}
<
span
className=
"panel-time-info"
>
<
i
className=
"fa fa-clock-o"
/>
4m
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx
View file @
a9b5cbf3
...
...
@@ -35,6 +35,7 @@ export class PanelHeaderMenu extends PureComponent<Props> {
render
()
{
const
{
dashboard
,
panel
}
=
this
.
props
;
const
menu
=
getPanelMenu
(
dashboard
,
panel
);
return
<
div
className=
"panel-menu-container dropdown"
>
{
this
.
renderItems
(
menu
)
}
</
div
>;
return
<
div
className=
"panel-menu-container dropdown open"
>
{
this
.
renderItems
(
menu
)
}
</
div
>;
}
}
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