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
512a42d2
Commit
512a42d2
authored
Jan 03, 2020
by
okhowang
Committed by
Torkel Ödegaard
Jan 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Panel: disable edit/duplicate/delete entry for repeat panel (#21257)
parent
d63ad9ac
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
public/app/core/services/keybindingSrv.ts
+5
-4
public/app/features/dashboard/state/DashboardModel.ts
+8
-0
public/app/features/dashboard/utils/getPanelMenu.ts
+3
-3
public/app/features/panel/panel_ctrl.ts
+3
-3
No files found.
public/app/core/services/keybindingSrv.ts
View file @
512a42d2
...
...
@@ -14,6 +14,7 @@ import { ContextSrv } from './context_srv';
import
{
ILocationService
,
IRootScopeService
,
ITimeoutService
}
from
'angular'
;
import
{
GrafanaRootScope
}
from
'app/routes/GrafanaCtrl'
;
import
{
getLocationSrv
}
from
'@grafana/runtime'
;
import
{
DashboardModel
}
from
'../../features/dashboard/state'
;
export
class
KeybindingSrv
{
helpModal
:
boolean
;
...
...
@@ -174,7 +175,7 @@ export class KeybindingSrv {
this
.
$location
.
search
(
search
);
}
setupDashboardBindings
(
scope
:
IRootScopeService
&
AppEventEmitter
,
dashboard
:
any
)
{
setupDashboardBindings
(
scope
:
IRootScopeService
&
AppEventEmitter
,
dashboard
:
DashboardModel
)
{
this
.
bind
(
'mod+o'
,
()
=>
{
dashboard
.
graphTooltip
=
(
dashboard
.
graphTooltip
+
1
)
%
3
;
appEvents
.
emit
(
CoreEvents
.
graphHoverClear
);
...
...
@@ -203,7 +204,7 @@ export class KeybindingSrv {
// edit panel
this
.
bind
(
'e'
,
()
=>
{
if
(
dashboard
.
meta
.
focusPanelId
&&
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
canEditPanelById
(
dashboard
.
meta
.
focusPanelId
)
)
{
appEvents
.
emit
(
PanelEvents
.
panelChangeView
,
{
fullscreen
:
true
,
edit
:
true
,
...
...
@@ -248,7 +249,7 @@ export class KeybindingSrv {
// delete panel
this
.
bind
(
'p r'
,
()
=>
{
if
(
dashboard
.
meta
.
focusPanelId
&&
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
canEditPanelById
(
dashboard
.
meta
.
focusPanelId
)
)
{
appEvents
.
emit
(
CoreEvents
.
removePanel
,
dashboard
.
meta
.
focusPanelId
);
dashboard
.
meta
.
focusPanelId
=
0
;
}
...
...
@@ -256,7 +257,7 @@ export class KeybindingSrv {
// duplicate panel
this
.
bind
(
'p d'
,
()
=>
{
if
(
dashboard
.
meta
.
focusPanelId
&&
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
canEditPanelById
(
dashboard
.
meta
.
focusPanelId
)
)
{
const
panelIndex
=
dashboard
.
getPanelInfoById
(
dashboard
.
meta
.
focusPanelId
).
index
;
dashboard
.
duplicatePanel
(
dashboard
.
panels
[
panelIndex
]);
}
...
...
public/app/features/dashboard/state/DashboardModel.ts
View file @
512a42d2
...
...
@@ -293,6 +293,14 @@ export class DashboardModel {
return
null
;
}
canEditPanel
(
panel
?:
PanelModel
):
boolean
{
return
this
.
meta
.
canEdit
&&
panel
&&
!
panel
.
repeatPanelId
;
}
canEditPanelById
(
id
:
number
):
boolean
{
return
this
.
canEditPanel
(
this
.
getPanelById
(
id
));
}
addPanel
(
panelData
:
any
)
{
panelData
.
id
=
this
.
getNextPanelId
();
...
...
public/app/features/dashboard/utils/getPanelMenu.ts
View file @
512a42d2
...
...
@@ -107,7 +107,7 @@ export const getPanelMenu = (dashboard: DashboardModel, panel: PanelModel) => {
shortcut
:
'v'
,
});
if
(
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
canEditPanel
(
panel
)
)
{
menu
.
push
({
text
:
'Edit'
,
iconClassName
:
'gicon gicon-editor'
,
...
...
@@ -152,7 +152,7 @@ export const getPanelMenu = (dashboard: DashboardModel, panel: PanelModel) => {
const
subMenu
:
PanelMenuItem
[]
=
[];
if
(
!
panel
.
fullscreen
&&
dashboard
.
meta
.
canEdit
)
{
if
(
!
panel
.
fullscreen
&&
dashboard
.
canEditPanel
(
panel
)
)
{
subMenu
.
push
({
text
:
'Duplicate'
,
onClick
:
onDuplicatePanel
,
...
...
@@ -178,7 +178,7 @@ export const getPanelMenu = (dashboard: DashboardModel, panel: PanelModel) => {
onClick
:
onMore
,
});
if
(
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
canEditPanel
(
panel
)
)
{
menu
.
push
({
type
:
'divider'
});
menu
.
push
({
...
...
public/app/features/panel/panel_ctrl.ts
View file @
512a42d2
...
...
@@ -127,7 +127,7 @@ export class PanelCtrl {
shortcut
:
'v'
,
});
if
(
this
.
dashboard
.
meta
.
canEdit
)
{
if
(
this
.
dashboard
.
canEditPanel
(
this
.
panel
)
)
{
menu
.
push
({
text
:
'Edit'
,
click
:
'ctrl.editPanel();'
,
...
...
@@ -164,7 +164,7 @@ export class PanelCtrl {
submenu
:
extendedMenu
,
});
if
(
this
.
dashboard
.
meta
.
canEdit
)
{
if
(
this
.
dashboard
.
canEditPanel
(
this
.
panel
)
)
{
menu
.
push
({
divider
:
true
,
role
:
'Editor'
});
menu
.
push
({
text
:
'Remove'
,
...
...
@@ -180,7 +180,7 @@ export class PanelCtrl {
getExtendedMenu
()
{
const
menu
=
[];
if
(
!
this
.
panel
.
fullscreen
&&
this
.
dashboard
.
meta
.
canEdit
)
{
if
(
!
this
.
panel
.
fullscreen
&&
this
.
dashboard
.
canEditPanel
(
this
.
panel
)
)
{
menu
.
push
({
text
:
'Duplicate'
,
click
:
'ctrl.duplicate()'
,
...
...
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