1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01:00

Small clean up for WebhookSettings

This commit is contained in:
Brett Sun 2016-01-15 13:59:41 +01:00
parent a6463087c0
commit 91c97afb7c

View File

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