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
f43d834a
Unverified
Commit
f43d834a
authored
Feb 09, 2021
by
Hugo Häggmark
Committed by
GitHub
Feb 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alerting: Fixes so notification channels are properly deleted (#31040)
parent
c69c8bd4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
3 deletions
+84
-3
public/app/features/alerting/AlertTabCtrl.test.ts
+81
-0
public/app/features/alerting/AlertTabCtrl.ts
+3
-3
No files found.
public/app/features/alerting/AlertTabCtrl.test.ts
0 → 100644
View file @
f43d834a
import
{
AlertTabCtrl
}
from
'./AlertTabCtrl'
;
interface
Args
{
notifications
?:
Array
<
{
uid
?:
string
;
id
?:
number
;
isDefault
:
boolean
}
>
;
}
function
setupTestContext
({
notifications
=
[]
}:
Args
=
{})
{
const
panel
=
{
alert
:
{
notifications
},
options
:
[],
title
:
'Testing Alerts'
,
};
const
$scope
=
{
ctrl
:
{
panel
,
render
:
jest
.
fn
(),
},
};
const
dashboardSrv
:
any
=
{};
const
uiSegmentSrv
:
any
=
{};
const
datasourceSrv
:
any
=
{};
const
controller
=
new
AlertTabCtrl
(
$scope
,
dashboardSrv
,
uiSegmentSrv
,
datasourceSrv
);
controller
.
notifications
=
notifications
;
controller
.
alertNotifications
=
[];
controller
.
initModel
();
return
{
controller
};
}
describe
(
'AlertTabCtrl'
,
()
=>
{
describe
(
'when removeNotification is called with an uid'
,
()
=>
{
it
(
'then the correct notifier should be removed'
,
()
=>
{
const
{
controller
}
=
setupTestContext
({
notifications
:
[
{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
},
{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
},
],
});
expect
(
controller
.
alert
.
notifications
).
toEqual
([
{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
,
iconClass
:
'bell'
},
{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
,
iconClass
:
'bell'
},
]);
expect
(
controller
.
alertNotifications
).
toEqual
([
{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
,
iconClass
:
'bell'
},
{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
,
iconClass
:
'bell'
},
]);
controller
.
removeNotification
({
uid
:
'one'
});
expect
(
controller
.
alert
.
notifications
).
toEqual
([{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
,
iconClass
:
'bell'
}]);
expect
(
controller
.
alertNotifications
).
toEqual
([{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
,
iconClass
:
'bell'
}]);
});
});
describe
(
'when removeNotification is called with an id'
,
()
=>
{
it
(
'then the correct notifier should be removed'
,
()
=>
{
const
{
controller
}
=
setupTestContext
({
notifications
:
[
{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
},
{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
},
],
});
expect
(
controller
.
alert
.
notifications
).
toEqual
([
{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
,
iconClass
:
'bell'
},
{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
,
iconClass
:
'bell'
},
]);
expect
(
controller
.
alertNotifications
).
toEqual
([
{
id
:
2
,
uid
:
'two'
,
isDefault
:
false
,
iconClass
:
'bell'
},
{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
,
iconClass
:
'bell'
},
]);
controller
.
removeNotification
({
id
:
2
});
expect
(
controller
.
alert
.
notifications
).
toEqual
([{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
,
iconClass
:
'bell'
}]);
expect
(
controller
.
alertNotifications
).
toEqual
([{
id
:
1
,
uid
:
'one'
,
isDefault
:
true
,
iconClass
:
'bell'
}]);
});
});
});
public/app/features/alerting/AlertTabCtrl.ts
View file @
f43d834a
...
...
@@ -165,10 +165,10 @@ export class AlertTabCtrl {
}
removeNotification
(
an
:
any
)
{
// remove notifiers refe
e
red to by id and uid to support notifiers added
// remove notifiers refe
r
red to by id and uid to support notifiers added
// before and after we added support for uid
_
.
remove
(
this
.
alert
.
notifications
,
(
n
:
any
)
=>
n
.
uid
===
an
.
uid
);
_
.
remove
(
this
.
alertNotifications
,
(
n
:
any
)
=>
n
.
uid
===
an
.
uid
);
_
.
remove
(
this
.
alert
.
notifications
,
(
n
:
any
)
=>
n
.
uid
===
an
.
uid
||
n
.
id
===
an
.
id
);
_
.
remove
(
this
.
alertNotifications
,
(
n
:
any
)
=>
n
.
uid
===
an
.
uid
||
n
.
id
===
an
.
id
);
}
addAlertRuleTag
()
{
...
...
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