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
28025695
Commit
28025695
authored
Feb 05, 2019
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor layout change, simple render test
parent
e4dad780
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
23 deletions
+145
-23
public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.test.tsx
+23
-0
public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx
+24
-13
public/app/features/dashboard/components/AddPanelWidget/_AddPanelWidget.scss
+17
-10
public/app/features/dashboard/components/AddPanelWidget/__snapshots__/AddPanelWidget.test.tsx.snap
+81
-0
No files found.
public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.test.tsx
0 → 100644
View file @
28025695
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
{
AddPanelWidget
,
Props
}
from
'./AddPanelWidget'
;
import
{
DashboardModel
,
PanelModel
}
from
'../../state'
;
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
dashboard
:
{}
as
DashboardModel
,
panel
:
{}
as
PanelModel
,
};
Object
.
assign
(
props
,
propOverrides
);
return
shallow
(<
AddPanelWidget
{
...
props
}
/>);
};
describe
(
'Render'
,
()
=>
{
it
(
'should render component'
,
()
=>
{
const
wrapper
=
setup
();
expect
(
wrapper
).
toMatchSnapshot
();
});
});
public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx
View file @
28025695
import
React
from
'react'
;
import
_
from
'lodash'
;
import
config
from
'app/core/config'
;
import
{
PanelModel
}
from
'../../state
/PanelModel
'
;
import
{
DashboardModel
}
from
'../../state
/DashboardModel
'
;
import
{
PanelModel
}
from
'../../state'
;
import
{
DashboardModel
}
from
'../../state'
;
import
store
from
'app/core/store'
;
import
{
LS_PANEL_COPY_KEY
}
from
'app/core/constants'
;
import
{
updateLocation
}
from
'app/core/actions'
;
...
...
@@ -57,6 +57,7 @@ export class AddPanelWidget extends React.Component<Props, State> {
copiedPanels
.
push
(
pluginCopy
);
}
}
return
_
.
sortBy
(
copiedPanels
,
'sort'
);
}
...
...
@@ -65,14 +66,6 @@ export class AddPanelWidget extends React.Component<Props, State> {
this
.
props
.
dashboard
.
removePanel
(
this
.
props
.
dashboard
.
panels
[
0
]);
}
copyButton
(
panel
)
{
return
(
<
button
className=
"btn-inverse btn"
onClick=
{
()
=>
this
.
onPasteCopiedPanel
(
panel
)
}
title=
{
panel
.
name
}
>
Paste copied Panel
</
button
>
);
}
moveToEdit
(
location
)
{
reduxStore
.
dispatch
(
updateLocation
(
location
));
}
...
...
@@ -151,7 +144,7 @@ export class AddPanelWidget extends React.Component<Props, State> {
renderOptionLink
=
(
icon
,
text
,
onClick
)
=>
{
return
(
<
div
>
<
a
href=
"#"
onClick=
{
onClick
}
className=
"add-panel-widget__link btn-inverse"
>
<
a
href=
"#"
onClick=
{
onClick
}
className=
"add-panel-widget__link btn
btn
-inverse"
>
<
div
className=
"add-panel-widget__icon"
>
<
i
className=
{
`gicon gicon-${icon}`
}
/>
</
div
>
...
...
@@ -162,6 +155,8 @@ export class AddPanelWidget extends React.Component<Props, State> {
};
render
()
{
const
{
copiedPanelPlugins
}
=
this
.
state
;
return
(
<
div
className=
"panel-container add-panel-widget-container"
>
<
div
className=
"add-panel-widget"
>
...
...
@@ -172,9 +167,25 @@ export class AddPanelWidget extends React.Component<Props, State> {
</
button
>
</
div
>
<
div
className=
"add-panel-widget__btn-container"
>
<
div
className=
"add-panel-widget__create"
>
{
this
.
renderOptionLink
(
'queries'
,
'Add query'
,
this
.
onCreateNewPanel
)
}
{
this
.
renderOptionLink
(
'visualization'
,
'Choose Panel type'
,
()
=>
this
.
onCreateNewPanel
(
'visualization'
))
}
{
this
.
renderOptionLink
(
'queries'
,
'Convert to row'
,
this
.
onCreateNewRow
)
}
{
this
.
renderOptionLink
(
'visualization'
,
'Choose Panel type'
,
()
=>
this
.
onCreateNewPanel
(
'visualization'
)
)
}
</
div
>
<
div
className=
"add-panel-widget__actions"
>
<
div
className=
"add-panel-widget__action"
onClick=
{
this
.
onCreateNewRow
}
>
Convert to row
</
div
>
{
copiedPanelPlugins
.
length
===
1
&&
(
<
div
className=
"add-panel-widget__action"
onClick=
{
()
=>
this
.
onPasteCopiedPanel
(
copiedPanelPlugins
[
0
])
}
>
Paste copied panel
</
div
>
)
}
</
div
>
</
div
>
</
div
>
</
div
>
...
...
public/app/features/dashboard/components/AddPanelWidget/_AddPanelWidget.scss
View file @
28025695
...
...
@@ -27,11 +27,8 @@
}
.add-panel-widget__link
{
display
:
block
;
margin
:
0
8px
;
width
:
130px
;
text-align
:
center
;
padding
:
8px
0
;
width
:
150px
;
}
.add-panel-widget__icon
{
...
...
@@ -54,14 +51,24 @@
margin-right
:
-10px
;
}
.add-panel-widget__create
{
display
:
inherit
;
margin-bottom
:
24px
;
}
.add-panel-widget__actions
{
display
:
inherit
;
}
.add-panel-widget__action
{
cursor
:
pointer
;
margin
:
0
4px
;
}
.add-panel-widget__btn-container
{
height
:
100%
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
height
:
100%
;
flex-direction
:
row
;
.btn
{
margin-bottom
:
10px
;
}
flex-direction
:
column
;
}
public/app/features/dashboard/components/AddPanelWidget/__snapshots__/AddPanelWidget.test.tsx.snap
0 → 100644
View file @
28025695
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should render component 1`] = `
<div
className="panel-container add-panel-widget-container"
>
<div
className="add-panel-widget"
>
<div
className="add-panel-widget__header grid-drag-handle"
>
<i
className="gicon gicon-add-panel"
/>
<button
className="add-panel-widget__close"
onClick={[Function]}
>
<i
className="fa fa-close"
/>
</button>
</div>
<div
className="add-panel-widget__btn-container"
>
<div
className="add-panel-widget__create"
>
<div>
<a
className="add-panel-widget__link btn btn-inverse"
href="#"
onClick={[Function]}
>
<div
className="add-panel-widget__icon"
>
<i
className="gicon gicon-queries"
/>
</div>
<span>
Add query
</span>
</a>
</div>
<div>
<a
className="add-panel-widget__link btn btn-inverse"
href="#"
onClick={[Function]}
>
<div
className="add-panel-widget__icon"
>
<i
className="gicon gicon-visualization"
/>
</div>
<span>
Choose Panel type
</span>
</a>
</div>
</div>
<div
className="add-panel-widget__actions"
>
<div
className="add-panel-widget__action"
onClick={[Function]}
>
Convert to row
</div>
</div>
</div>
</div>
</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