Merge pull request #4714 from keithjgrant/4521-noti-template-type-switch

fix bugs when switching NTs to Webhook type

Reviewed-by: Keith Grant
             https://github.com/keithjgrant
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-09-13 18:20:13 +00:00 committed by GitHub
commit 9f0657e19a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -222,7 +222,9 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
function processValue(value, i, field) {
if (field.type === 'textarea') {
if (field.name === 'headers') {
$scope[i] = JSON.parse($scope[i]);
if (typeof $scope[i] === 'string') {
$scope[i] = JSON.parse($scope[i]);
}
}
else if (field.name === 'annotation_tags' && $scope.notification_type.value === "grafana" && value === null) {
$scope[i] = null;

View File

@ -310,7 +310,9 @@ export default ['Rest', 'Wait',
function processValue(value, i, field) {
if (field.type === 'textarea') {
if (field.name === 'headers') {
$scope[i] = JSON.parse($scope[i]);
if (typeof $scope[i] === 'string') {
$scope[i] = JSON.parse($scope[i]);
}
}
else if (field.name === 'annotation_tags' && $scope.notification_type.value === "grafana" && value === null) {
$scope[i] = null;
@ -325,7 +327,12 @@ export default ['Rest', 'Wait',
if (field.type === 'number') {
$scope[i] = Number($scope[i]);
}
if (i === "username" && $scope.notification_type.value === "email" && (value === null || value === undefined)) {
const isUsernameIncluded = (
$scope.notification_type.value === 'email' ||
$scope.notification_type.value === 'webhook'
);
if (i === "username" && isUsernameIncluded &&
(value === null || value === undefined)) {
$scope[i] = "";
}
if (field.type === 'sensitive' && (value === null || value === undefined)) {