'use strict'; import React from 'react'; import WebhookStore from '../../stores/webhook_store'; import WebhookActions from '../../actions/webhook_actions'; import GlobalNotificationModel from '../../models/global_notification_model'; 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'; import ApiUrls from '../../constants/api_urls'; import AscribeSpinner from '../ascribe_spinner'; import { getLangText } from '../../utils/lang_utils'; let WebhookSettings = React.createClass({ propTypes: { defaultExpanded: React.PropTypes.bool }, getInitialState() { return WebhookStore.getState(); }, componentDidMount() { WebhookStore.listen(this.onChange); WebhookActions.fetchWebhooks(); }, componentWillUnmount() { WebhookStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, onRemoveWebhook(webhookId) { return (event) => { WebhookActions.removeWebhook(webhookId); const notification = new GlobalNotificationModel(getLangText('Webhook deleted'), 'success', 2000); GlobalNotificationActions.appendGlobalNotification(notification); }; }, handleCreateSuccess() { this.refs.webhookCreateForm.reset(); WebhookActions.fetchWebhooks(true); const notification = new GlobalNotificationModel(getLangText('Webhook successfully created'), 'success', 5000); GlobalNotificationActions.appendGlobalNotification(notification); }, getWebhooks() { if (this.state.webhooks) { return this.state.webhooks.map(function(webhook, i) { const event = webhook.event.split('.')[0]; return (
{event.toUpperCase()}
{webhook.target}
} buttons={
} /> ); }, this); } else { return ( ); } }, getEvents() { if (this.state.webhookEvents && this.state.webhookEvents.length) { return ( ); } else { return null; } }, render() { return (

Webhooks allow external services to receive notifications from ascribe. Currently we support webhook notifications when someone transfers, consigns, loans or shares (by email) a work to you.

To get started, simply choose the prefered action that you want to be notified upon and supply a target url.

{this.getEvents()}
{this.getWebhooks()}
); } }); export default WebhookSettings;