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
460847f3
Unverified
Commit
460847f3
authored
May 20, 2020
by
Hugo Häggmark
Committed by
GitHub
May 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Panel: shows correct panel menu items in view mode (#24912)
parent
bb099cb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
4 deletions
+76
-4
public/app/features/dashboard/utils/getPanelMenu.test.ts
+73
-1
public/app/features/dashboard/utils/getPanelMenu.ts
+3
-3
No files found.
public/app/features/dashboard/utils/getPanelMenu.test.ts
View file @
460847f3
import
{
PanelModel
,
Dashboard
Model
}
from
'../state'
;
import
{
DashboardModel
,
Panel
Model
}
from
'../state'
;
import
{
getPanelMenu
}
from
'./getPanelMenu'
;
import
{
describe
}
from
'../../../../test/lib/common'
;
describe
(
'getPanelMenu'
,
()
=>
{
it
(
'should return the correct panel menu items'
,
()
=>
{
...
...
@@ -69,4 +70,75 @@ describe('getPanelMenu', () => {
]
`
);
});
describe
(
'when panel is in view mode'
,
()
=>
{
it
(
'should return the correct panel menu items'
,
()
=>
{
const
getExtendedMenu
=
()
=>
[{
text
:
'Toggle legend'
,
shortcut
:
'p l'
,
click
:
jest
.
fn
()
}];
const
ctrl
:
any
=
{
getExtendedMenu
};
const
scope
:
any
=
{
$
$childHead
:
{
ctrl
}
};
const
angularComponent
:
any
=
{
getScope
:
()
=>
scope
};
const
panel
=
new
PanelModel
({
isViewing
:
true
});
const
dashboard
=
new
DashboardModel
({});
const
menuItems
=
getPanelMenu
(
dashboard
,
panel
,
angularComponent
);
expect
(
menuItems
).
toMatchInlineSnapshot
(
`
Array [
Object {
"iconClassName": "eye",
"onClick": [Function],
"shortcut": "v",
"text": "View",
},
Object {
"iconClassName": "edit",
"onClick": [Function],
"shortcut": "e",
"text": "Edit",
},
Object {
"iconClassName": "share-alt",
"onClick": [Function],
"shortcut": "p s",
"text": "Share",
},
Object {
"iconClassName": "info-circle",
"onClick": [Function],
"shortcut": "i",
"subMenu": Array [
Object {
"onClick": [Function],
"text": "Panel JSON",
},
],
"text": "Inspect",
"type": "submenu",
},
Object {
"iconClassName": "cube",
"onClick": [Function],
"subMenu": Array [
Object {
"href": undefined,
"onClick": [Function],
"shortcut": "p l",
"text": "Toggle legend",
},
],
"text": "More...",
"type": "submenu",
},
Object {
"type": "divider",
},
Object {
"iconClassName": "trash-alt",
"onClick": [Function],
"shortcut": "p r",
"text": "Remove",
},
]
`
);
});
});
});
public/app/features/dashboard/utils/getPanelMenu.ts
View file @
460847f3
import
{
updateLocation
}
from
'app/core/actions'
;
import
{
store
}
from
'app/store/store'
;
import
{
getDataSourceSrv
,
getLocationSrv
,
AngularComponent
}
from
'@grafana/runtime'
;
import
{
AngularComponent
,
getDataSourceSrv
,
getLocationSrv
}
from
'@grafana/runtime'
;
import
{
PanelMenuItem
}
from
'@grafana/data'
;
import
{
copyPanel
,
duplicatePanel
,
removePanel
,
sharePanel
}
from
'app/features/dashboard/utils/panel'
;
import
{
PanelModel
}
from
'app/features/dashboard/state/PanelModel'
;
...
...
@@ -187,12 +187,12 @@ export function getPanelMenu(
}
}
if
(
!
panel
.
isEditing
)
{
if
(
!
panel
.
isEditing
&&
subMenu
.
length
)
{
menu
.
push
({
type
:
'submenu'
,
text
:
'More...'
,
iconClassName
:
'cube'
,
subMenu
:
subMenu
,
subMenu
,
onClick
:
onMore
,
});
}
...
...
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