Merge pull request #103 from ascribe/small-cleanup-for-webhook-settings

Small cleanup for webhook settings
This commit is contained in:
Brett Sun 2016-01-18 18:29:31 +01:00
commit 58289c4b9c
1 changed files with 19 additions and 18 deletions

View File

@ -34,7 +34,6 @@ let WebhookSettings = React.createClass({
componentDidMount() {
WebhookStore.listen(this.onChange);
WebhookActions.fetchWebhooks();
WebhookActions.fetchWebhookEvents();
},
componentWillUnmount() {
@ -49,7 +48,7 @@ let WebhookSettings = React.createClass({
return (event) => {
WebhookActions.removeWebhook(webhookId);
let notification = new GlobalNotificationModel(getLangText('Webhook deleted'), 'success', 2000);
const notification = new GlobalNotificationModel(getLangText('Webhook deleted'), 'success', 2000);
GlobalNotificationActions.appendGlobalNotification(notification);
};
},
@ -57,16 +56,16 @@ let WebhookSettings = React.createClass({
handleCreateSuccess() {
this.refs.webhookCreateForm.reset();
WebhookActions.fetchWebhooks(true);
let notification = new GlobalNotificationModel(getLangText('Webhook successfully created'), 'success', 5000);
const notification = new GlobalNotificationModel(getLangText('Webhook successfully created'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
getWebhooks(){
let content = <AscribeSpinner color='dark-blue' size='lg'/>;
getWebhooks() {
if (this.state.webhooks) {
content = this.state.webhooks.map(function(webhook, i) {
return this.state.webhooks.map(function(webhook, i) {
const event = webhook.event.split('.')[0];
return (
<ActionPanel
name={webhook.event}
@ -91,11 +90,14 @@ let WebhookSettings = React.createClass({
</button>
</div>
</div>
}/>
} />
);
}, this);
} else {
return (
<AscribeSpinner color='dark-blue' size='lg'/>
);
}
return content;
},
getEvents() {
@ -110,18 +112,18 @@ let WebhookSettings = React.createClass({
<option
name={i}
key={i}
value={ event + '.webhook' }>
{ event.toUpperCase() }
value={event + '.webhook'}>
{event.toUpperCase()}
</option>
);
})}
</select>
</Property>);
} else {
return null;
}
return null;
},
render() {
return (
<CollapsibleParagraph
@ -138,20 +140,19 @@ let WebhookSettings = React.createClass({
a target url.
</p>
</div>
<AclProxy
show={this.state.webhookEvents && this.state.webhookEvents.length}>
<AclProxy show={this.state.webhookEvents && this.state.webhookEvents.length}>
<Form
ref="webhookCreateForm"
url={ApiUrls.webhooks}
handleSuccess={this.handleCreateSuccess}>
{ this.getEvents() }
{this.getEvents()}
<Property
name='target'
label={getLangText('Redirect Url')}>
<input
type="text"
placeholder={getLangText('Enter the url to be triggered')}
required/>
required />
</Property>
<hr />
</Form>
@ -162,4 +163,4 @@ let WebhookSettings = React.createClass({
}
});
export default WebhookSettings;
export default WebhookSettings;