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
3fbdcf10
Unverified
Commit
3fbdcf10
authored
Apr 24, 2020
by
Tobias Skarhed
Committed by
GitHub
Apr 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form migrations: Teams and alert list (#23810)
* Basic migration * Update test * Fix feedback
parent
e4d492fd
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
148 additions
and
158 deletions
+148
-158
public/app/features/alerting/AlertRuleItem.tsx
+14
-11
public/app/features/alerting/AlertRuleList.test.tsx
+1
-1
public/app/features/alerting/AlertRuleList.tsx
+18
-15
public/app/features/alerting/__snapshots__/AlertRuleItem.test.tsx.snap
+25
-17
public/app/features/alerting/__snapshots__/AlertRuleList.test.tsx.snap
+74
-98
public/app/features/teams/TeamList.tsx
+4
-4
public/app/features/teams/__snapshots__/TeamList.test.tsx.snap
+12
-12
No files found.
public/app/features/alerting/AlertRuleItem.tsx
View file @
3fbdcf10
...
...
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
// @ts-ignore
import
Highlighter
from
'react-highlight-words'
;
import
{
AlertRule
}
from
'../../types'
;
import
{
Icon
,
IconName
}
from
'@grafana/ui'
;
import
{
Icon
,
IconName
,
Button
,
Tooltip
,
LinkButton
,
HorizontalGroup
}
from
'@grafana/ui'
;
export
interface
Props
{
rule
:
AlertRule
;
...
...
@@ -43,16 +43,19 @@ class AlertRuleItem extends PureComponent<Props> {
</
div
>
<
div
className=
"alert-rule-item__actions"
>
<
button
className=
"btn btn-small btn-inverse alert-list__btn width-2"
title=
"Pausing an alert rule prevents it from executing"
onClick=
{
onTogglePause
}
>
<
Icon
name=
{
rule
.
state
===
'paused'
?
'play'
:
'pause'
}
/>
</
button
>
<
a
className=
"btn btn-small btn-inverse alert-list__btn width-2"
href=
{
ruleUrl
}
title=
"Edit alert rule"
>
<
Icon
name=
"cog"
/>
</
a
>
<
HorizontalGroup
spacing=
"sm"
>
<
Tooltip
placement=
"bottom"
content=
"Pausing an alert rule prevents it from executing"
>
<
Button
variant=
"secondary"
size=
"sm"
icon=
{
rule
.
state
===
'paused'
?
'play'
:
'pause'
}
onClick=
{
onTogglePause
}
/>
</
Tooltip
>
<
Tooltip
placement=
"right"
content=
"Edit alert rule"
>
<
LinkButton
size=
"sm"
variant=
"secondary"
href=
{
ruleUrl
}
icon=
"cog"
/>
</
Tooltip
>
</
HorizontalGroup
>
</
div
>
</
li
>
);
...
...
public/app/features/alerting/AlertRuleList.test.tsx
View file @
3fbdcf10
...
...
@@ -127,7 +127,7 @@ describe('Functions', () => {
describe
(
'State filter changed'
,
()
=>
{
it
(
'should update location'
,
()
=>
{
const
{
instance
}
=
setup
();
const
mockEvent
=
{
target
:
{
value
:
'alerting'
}
}
as
React
.
ChangeEvent
<
HTMLSelectElement
>
;
const
mockEvent
=
{
value
:
'alerting'
}
;
instance
.
onStateFilterChanged
(
mockEvent
);
...
...
public/app/features/alerting/AlertRuleList.tsx
View file @
3fbdcf10
...
...
@@ -10,8 +10,9 @@ import { AlertRule, CoreEvents, StoreState } from 'app/types';
import
{
getAlertRulesAsync
,
togglePauseAlertRule
}
from
'./state/actions'
;
import
{
getAlertRuleItems
,
getSearchQuery
}
from
'./state/selectors'
;
import
{
FilterInput
}
from
'app/core/components/FilterInput/FilterInput'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
{
NavModel
,
SelectableValue
}
from
'@grafana/data'
;
import
{
setSearchQuery
}
from
'./state/reducers'
;
import
{
Button
,
Select
}
from
'@grafana/ui'
;
export
interface
Props
{
navModel
:
NavModel
;
...
...
@@ -27,13 +28,13 @@ export interface Props {
export
class
AlertRuleList
extends
PureComponent
<
Props
,
any
>
{
stateFilters
=
[
{
text
:
'All'
,
value
:
'all'
},
{
text
:
'OK'
,
value
:
'ok'
},
{
text
:
'Not OK'
,
value
:
'not_ok'
},
{
text
:
'Alerting'
,
value
:
'alerting'
},
{
text
:
'No Data'
,
value
:
'no_data'
},
{
text
:
'Paused'
,
value
:
'paused'
},
{
text
:
'Pending'
,
value
:
'pending'
},
{
label
:
'All'
,
value
:
'all'
},
{
label
:
'OK'
,
value
:
'ok'
},
{
label
:
'Not OK'
,
value
:
'not_ok'
},
{
label
:
'Alerting'
,
value
:
'alerting'
},
{
label
:
'No Data'
,
value
:
'no_data'
},
{
label
:
'Paused'
,
value
:
'paused'
},
{
label
:
'Pending'
,
value
:
'pending'
},
];
componentDidMount
()
{
...
...
@@ -58,9 +59,9 @@ export class AlertRuleList extends PureComponent<Props, any> {
return
'all'
;
}
onStateFilterChanged
=
(
evt
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
onStateFilterChanged
=
(
option
:
SelectableValue
)
=>
{
this
.
props
.
updateLocation
({
query
:
{
state
:
evt
.
target
.
value
},
query
:
{
state
:
option
.
value
},
});
};
...
...
@@ -108,15 +109,17 @@ export class AlertRuleList extends PureComponent<Props, any> {
<
label
className=
"gf-form-label"
>
States
</
label
>
<
div
className=
"gf-form-select-wrapper width-13"
>
<
select
className=
"gf-form-input"
onChange=
{
this
.
onStateFilterChanged
}
value=
{
this
.
getStateFilter
()
}
>
{
this
.
stateFilters
.
map
(
this
.
alertStateFilterOption
)
}
</
select
>
<
Select
options=
{
this
.
stateFilters
}
onChange=
{
this
.
onStateFilterChanged
}
value=
{
this
.
getStateFilter
()
}
/>
</
div
>
</
div
>
<
div
className=
"page-action-bar__spacer"
/>
<
a
className=
"btn btn-
secondary"
onClick=
{
this
.
onOpenHowTo
}
>
<
Button
variant=
"
secondary"
onClick=
{
this
.
onOpenHowTo
}
>
How to add an alert
</
a
>
</
Button
>
</
div
>
<
section
>
<
ol
className=
"alert-rule-list"
>
...
...
public/app/features/alerting/__snapshots__/AlertRuleItem.test.tsx.snap
View file @
3fbdcf10
...
...
@@ -60,24 +60,32 @@ exports[`Render should render component 1`] = `
<div
className="alert-rule-item__actions"
>
<button
className="btn btn-small btn-inverse alert-list__btn width-2"
onClick={[MockFunction]}
title="Pausing an alert rule prevents it from executing"
<Component
spacing="sm"
>
<Icon
name="pause"
/>
</button>
<a
className="btn btn-small btn-inverse alert-list__btn width-2"
href="https://something.something.darkside?editPanel=1&tab=alert"
title="Edit alert rule"
>
<Icon
name="cog"
/>
</a>
<Component
content="Pausing an alert rule prevents it from executing"
placement="bottom"
>
<Button
icon="pause"
onClick={[MockFunction]}
size="sm"
variant="secondary"
/>
</Component>
<Component
content="Edit alert rule"
placement="right"
>
<LinkButton
href="https://something.something.darkside?editPanel=1&tab=alert"
icon="cog"
size="sm"
variant="secondary"
/>
</Component>
</Component>
</div>
</li>
`;
public/app/features/alerting/__snapshots__/AlertRuleList.test.tsx.snap
View file @
3fbdcf10
...
...
@@ -32,65 +32,53 @@ exports[`Render should render alert rules 1`] = `
<div
className="gf-form-select-wrapper width-13"
>
<select
className="gf-form-input"
<Select
onChange={[Function]}
options={
Array [
Object {
"label": "All",
"value": "all",
},
Object {
"label": "OK",
"value": "ok",
},
Object {
"label": "Not OK",
"value": "not_ok",
},
Object {
"label": "Alerting",
"value": "alerting",
},
Object {
"label": "No Data",
"value": "no_data",
},
Object {
"label": "Paused",
"value": "paused",
},
Object {
"label": "Pending",
"value": "pending",
},
]
}
value="all"
>
<option
key="all"
value="all"
>
All
</option>
<option
key="ok"
value="ok"
>
OK
</option>
<option
key="not_ok"
value="not_ok"
>
Not OK
</option>
<option
key="alerting"
value="alerting"
>
Alerting
</option>
<option
key="no_data"
value="no_data"
>
No Data
</option>
<option
key="paused"
value="paused"
>
Paused
</option>
<option
key="pending"
value="pending"
>
Pending
</option>
</select>
/>
</div>
</div>
<div
className="page-action-bar__spacer"
/>
<a
className="btn btn-secondary"
<Button
onClick={[Function]}
variant="secondary"
>
How to add an alert
</
a
>
</
Button
>
</div>
<section>
<ol
...
...
@@ -176,65 +164,53 @@ exports[`Render should render component 1`] = `
<div
className="gf-form-select-wrapper width-13"
>
<select
className="gf-form-input"
<Select
onChange={[Function]}
options={
Array [
Object {
"label": "All",
"value": "all",
},
Object {
"label": "OK",
"value": "ok",
},
Object {
"label": "Not OK",
"value": "not_ok",
},
Object {
"label": "Alerting",
"value": "alerting",
},
Object {
"label": "No Data",
"value": "no_data",
},
Object {
"label": "Paused",
"value": "paused",
},
Object {
"label": "Pending",
"value": "pending",
},
]
}
value="all"
>
<option
key="all"
value="all"
>
All
</option>
<option
key="ok"
value="ok"
>
OK
</option>
<option
key="not_ok"
value="not_ok"
>
Not OK
</option>
<option
key="alerting"
value="alerting"
>
Alerting
</option>
<option
key="no_data"
value="no_data"
>
No Data
</option>
<option
key="paused"
value="paused"
>
Paused
</option>
<option
key="pending"
value="pending"
>
Pending
</option>
</select>
/>
</div>
</div>
<div
className="page-action-bar__spacer"
/>
<a
className="btn btn-secondary"
<Button
onClick={[Function]}
variant="secondary"
>
How to add an alert
</
a
>
</
Button
>
</div>
<section>
<ol
...
...
public/app/features/teams/TeamList.tsx
View file @
3fbdcf10
import
React
,
{
PureComponent
}
from
'react'
;
import
{
hot
}
from
'react-hot-loader'
;
import
Page
from
'app/core/components/Page/Page'
;
import
{
DeleteButton
}
from
'@grafana/ui'
;
import
{
DeleteButton
,
LinkButton
}
from
'@grafana/ui'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
EmptyListCTA
from
'app/core/components/EmptyListCTA/EmptyListCTA'
;
import
{
OrgRole
,
StoreState
,
Team
}
from
'app/types'
;
...
...
@@ -109,9 +109,9 @@ export class TeamList extends PureComponent<Props, any> {
<
div
className=
"page-action-bar__spacer"
/>
<
a
className=
{
`btn btn-primary${disabledClass}`
}
href=
{
newTeamHref
}
>
New
t
eam
</
a
>
<
LinkButton
className=
{
disabledClass
}
href=
{
newTeamHref
}
>
New
T
eam
</
LinkButton
>
</
div
>
<
div
className=
"admin-list-table"
>
...
...
public/app/features/teams/__snapshots__/TeamList.test.tsx.snap
View file @
3fbdcf10
...
...
@@ -52,12 +52,12 @@ exports[`Render should render teams table 1`] = `
<div
className="page-action-bar__spacer"
/>
<
a
className="
btn btn-primary
"
<
LinkButton
className=""
href="org/teams/new"
>
New
t
eam
</
a
>
New
T
eam
</
LinkButton
>
</div>
<div
className="admin-list-table"
...
...
@@ -387,12 +387,12 @@ exports[`Render when feature toggle editorsCanAdmin is turned on and signedin us
<div
className="page-action-bar__spacer"
/>
<
a
className="
btn btn-primary
disabled"
<
LinkButton
className=" disabled"
href="#"
>
New
t
eam
</
a
>
New
T
eam
</
LinkButton
>
</div>
<div
className="admin-list-table"
...
...
@@ -514,12 +514,12 @@ exports[`Render when feature toggle editorsCanAdmin is turned on and signedin us
<div
className="page-action-bar__spacer"
/>
<
a
className="
btn btn-primary
"
<
LinkButton
className=""
href="org/teams/new"
>
New
t
eam
</
a
>
New
T
eam
</
LinkButton
>
</div>
<div
className="admin-list-table"
...
...
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