Jelajahi Sumber

NotificationChannels: Add delete button to edit page (#19103)

* Add delete button to edit notification channel page

* Simplified code
Lauren Muhlhauser 6 tahun lalu
induk
melakukan
3827913105

+ 7 - 0
public/app/features/alerting/NotificationsEditCtrl.ts

@@ -100,6 +100,13 @@ export class AlertNotificationEditCtrl {
     }
   }
 
+  deleteNotification() {
+    this.backendSrv.delete(`/api/alert-notifications/${this.model.id}`).then((res: any) => {
+      this.model = res;
+      this.$location.path('alerting/notifications');
+    });
+  }
+
   getNotifierTemplateId(type: string) {
     return `notifier-options-${type}`;
   }

+ 1 - 0
public/app/features/alerting/partials/notification_edit.html

@@ -70,6 +70,7 @@
     <div class="gf-form-group gf-form-button-row">
 			<button type="submit" ng-click="ctrl.save()" class="btn btn-primary width-7">Save</button>
 			<button type="submit" ng-click="ctrl.testNotification()" class="btn btn-secondary width-7">Send Test</button>
+			<button type="delete" ng-if="!ctrl.isNew" ng-click="ctrl.deleteNotification()" class="btn btn-danger width-7">Delete</button>
 			<a href="alerting/notifications" class="btn btn-inverse">Back</a>
     </div>
   </form>