diff --git a/js/actions/webhook_actions.js b/js/actions/webhook_actions.js
index 4e5b2462..f9555ce7 100644
--- a/js/actions/webhook_actions.js
+++ b/js/actions/webhook_actions.js
@@ -1,47 +1,19 @@
'use strict';
import { alt } from '../alt';
-import WebhookFetcher from '../fetchers/webhook_fetcher';
class WebhookActions {
constructor() {
this.generateActions(
- 'updateWebhooks',
- 'updateEvents',
- 'removeWebhook'
+ 'fetchWebhooks',
+ 'successFetchWebhooks',
+ 'fetchWebhookEvents',
+ 'successFetchWebhookEvents',
+ 'removeWebhook',
+ 'successRemoveWebhook'
);
}
-
- fetchWebhooks() {
- WebhookFetcher.fetch()
- .then((res) => {
- this.actions.updateWebhooks(res.webhooks);
- })
- .catch((err) => {
- console.logGlobal(err);
- });
- }
-
- fetchWebhookEvents() {
- WebhookFetcher.fetchEvents()
- .then((res) => {
- this.actions.updateEvents(res.events);
- })
- .catch((err) => {
- console.logGlobal(err);
- });
- }
-
- deleteWebhook(id){
- WebhookFetcher.deleteWebhook(id)
- .then((res) => {
- this.actions.removeWebhook(id);
- })
- .catch((err) => {
- console.logGlobal(err);
- });
- }
}
export default alt.createActions(WebhookActions);
diff --git a/js/components/ascribe_settings/webhook_settings.js b/js/components/ascribe_settings/webhook_settings.js
index 1f9eefc5..18c21aa6 100644
--- a/js/components/ascribe_settings/webhook_settings.js
+++ b/js/components/ascribe_settings/webhook_settings.js
@@ -11,6 +11,8 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
import Form from '../ascribe_forms/form';
import Property from '../ascribe_forms/property';
+import AclProxy from '../acl_proxy';
+
import ActionPanel from '../ascribe_panel/action_panel';
import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph';
@@ -43,16 +45,18 @@ let WebhookSettings = React.createClass({
this.setState(state);
},
- onDeleteWebhook(event) {
- let webhookId = event.target.getAttribute('data-id');
- WebhookActions.deleteWebhook(webhookId);
+ onRemoveWebhook(webhookId) {
+ return (event) => {
+ WebhookActions.removeWebhook(webhookId);
- let notification = new GlobalNotificationModel(getLangText('Webhook deleted'), 'success', 2000);
- GlobalNotificationActions.appendGlobalNotification(notification);
+ let notification = new GlobalNotificationModel(getLangText('Webhook deleted'), 'success', 2000);
+ GlobalNotificationActions.appendGlobalNotification(notification);
+ };
},
handleCreateSuccess() {
- WebhookActions.fetchWebhooks();
+ this.refs.webhookCreateForm.reset();
+ WebhookActions.fetchWebhooks(true);
let notification = new GlobalNotificationModel(getLangText('Webhook successfully created'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
@@ -60,7 +64,7 @@ let WebhookSettings = React.createClass({
getWebhooks(){
let content = ;
- if (this.state.webhooks.length > -1) {
+ if (this.state.webhooks) {
content = this.state.webhooks.map(function(webhook, i) {
const event = webhook.event.split('.')[0];
return (
@@ -82,8 +86,7 @@ let WebhookSettings = React.createClass({
@@ -96,14 +99,13 @@ let WebhookSettings = React.createClass({
},
getEvents() {
- if (this.state.events && this.state.events.length > 1) {
+ if (this.state.webhookEvents && this.state.webhookEvents.length) {
return (
-