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
b12df9d6
Unverified
Commit
b12df9d6
authored
Jun 02, 2020
by
Dominik Prokop
Committed by
GitHub
Jun 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not show alerts tab when alerting is disabled (#25285)
* Do not show alerts tab when alerting is disabled * Add tests
parent
add1bcb5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletions
+76
-1
public/app/features/dashboard/components/PanelEditor/state/selectors.test.ts
+74
-0
public/app/features/dashboard/components/PanelEditor/state/selectors.ts
+2
-1
No files found.
public/app/features/dashboard/components/PanelEditor/state/selectors.test.ts
0 → 100644
View file @
b12df9d6
import
{
getPanelEditorTabs
}
from
'./selectors'
;
import
{
LocationState
}
from
'app/types'
;
import
{
PanelPlugin
}
from
'@grafana/data'
;
import
{
PanelEditorTabId
}
from
'../types'
;
import
{
updateConfig
}
from
'../../../../../core/config'
;
describe
(
'getPanelEditorTabs selector'
,
()
=>
{
it
(
'return no tabs when no plugin provided'
,
()
=>
{
expect
(
getPanelEditorTabs
({}
as
LocationState
)).
toEqual
([]);
});
it
(
'return no tabs when plugin do not support queries'
,
()
=>
{
expect
(
getPanelEditorTabs
({}
as
LocationState
,
{
meta
:
{
skipDataQuery
:
true
}
}
as
PanelPlugin
)).
toEqual
([]);
});
describe
(
'alerts tab'
,
()
=>
{
describe
(
'when alerting enabled'
,
()
=>
{
beforeAll
(()
=>
{
updateConfig
({
alertingEnabled
:
true
,
});
});
it
(
'returns Alerts tab for graph panel'
,
()
=>
{
const
tabs
=
getPanelEditorTabs
(
{
query
:
{}
}
as
LocationState
,
{
meta
:
{
id
:
'graph'
,
},
}
as
PanelPlugin
);
expect
(
tabs
.
length
).
toEqual
(
3
);
expect
(
tabs
[
2
].
id
).
toEqual
(
PanelEditorTabId
.
Alert
);
});
it
(
'does not returns tab for panel other than graph'
,
()
=>
{
const
tabs
=
getPanelEditorTabs
(
{
query
:
{}
}
as
LocationState
,
{
meta
:
{
id
:
'table'
,
},
}
as
PanelPlugin
);
expect
(
tabs
.
length
).
toEqual
(
2
);
expect
(
tabs
[
1
].
id
).
toEqual
(
PanelEditorTabId
.
Transform
);
});
});
describe
(
'when alerting disabled'
,
()
=>
{
beforeAll
(()
=>
{
updateConfig
({
alertingEnabled
:
false
,
});
});
it
(
'does not return Alerts tab'
,
()
=>
{
const
tabs
=
getPanelEditorTabs
(
{
query
:
{}
}
as
LocationState
,
{
meta
:
{
id
:
'graph'
,
},
}
as
PanelPlugin
);
expect
(
tabs
.
length
).
toEqual
(
2
);
expect
(
tabs
[
1
].
id
).
toEqual
(
PanelEditorTabId
.
Transform
);
});
});
});
});
public/app/features/dashboard/components/PanelEditor/state/selectors.ts
View file @
b12df9d6
...
...
@@ -2,6 +2,7 @@ import memoizeOne from 'memoize-one';
import
{
LocationState
}
from
'app/types'
;
import
{
PanelPlugin
}
from
'@grafana/data'
;
import
{
PanelEditorTab
,
PanelEditorTabId
}
from
'../types'
;
import
{
getConfig
}
from
'app/core/config'
;
export
const
getPanelEditorTabs
=
memoizeOne
((
location
:
LocationState
,
plugin
?:
PanelPlugin
)
=>
{
const
tabs
:
PanelEditorTab
[]
=
[];
...
...
@@ -34,7 +35,7 @@ export const getPanelEditorTabs = memoizeOne((location: LocationState, plugin?:
});
}
if
(
plugin
.
meta
.
id
===
'graph'
)
{
if
(
getConfig
().
alertingEnabled
&&
plugin
.
meta
.
id
===
'graph'
)
{
tabs
.
push
({
id
:
PanelEditorTabId
.
Alert
,
text
:
'Alert'
,
...
...
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