From bb13476326b81191ba4aa854c25224638735272c Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Mon, 28 Mar 2016 16:17:17 -0400
Subject: Added delete buttons to InstalledIntegrations

---
 .../backstage/installed_integrations.jsx           | 80 ++++------------------
 1 file changed, 14 insertions(+), 66 deletions(-)

(limited to 'webapp/components/backstage/installed_integrations.jsx')

diff --git a/webapp/components/backstage/installed_integrations.jsx b/webapp/components/backstage/installed_integrations.jsx
index 9f41ab85e..4f79509d9 100644
--- a/webapp/components/backstage/installed_integrations.jsx
+++ b/webapp/components/backstage/installed_integrations.jsx
@@ -9,6 +9,8 @@ import IntegrationStore from 'stores/integration_store.jsx';
 import * as Utils from 'utils/utils.jsx';
 
 import {FormattedMessage} from 'react-intl';
+import InstalledIncomingWebhook from './installed_incoming_webhook.jsx';
+import InstalledOutgoingWebhook from './installed_outgoing_webhook.jsx';
 import {Link} from 'react-router';
 
 export default class InstalledIntegrations extends React.Component {
@@ -76,6 +78,14 @@ export default class InstalledIntegrations extends React.Component {
         });
     }
 
+    deleteIncomingWebhook(incomingWebhook) {
+        AsyncClient.deleteIncomingHook(incomingWebhook.id);
+    }
+
+    deleteOutgoingWebhook(outgoingWebhook) {
+        AsyncClient.deleteOutgoingHook(outgoingWebhook.id);
+    }
+
     renderTypeFilters(incomingWebhooks, outgoingWebhooks) {
         const fields = [];
 
@@ -194,9 +204,10 @@ export default class InstalledIntegrations extends React.Component {
                 }
 
                 integrations.push(
-                    <IncomingWebhook
+                    <InstalledIncomingWebhook
                         key={incomingWebhook.id}
                         incomingWebhook={incomingWebhook}
+                        onDeleteClick={this.deleteIncomingWebhook}
                     />
                 );
             }
@@ -213,9 +224,10 @@ export default class InstalledIntegrations extends React.Component {
                 }
 
                 integrations.push(
-                    <OutgoingWebhook
+                    <InstalledOutgoingWebhook
                         key={outgoingWebhook.id}
                         outgoingWebhook={outgoingWebhook}
+                        onDeleteClick={this.deleteOutgoingWebhook}
                     />
                 );
             }
@@ -266,67 +278,3 @@ export default class InstalledIntegrations extends React.Component {
         );
     }
 }
-
-function IncomingWebhook({incomingWebhook}) {
-    const channel = ChannelStore.get(incomingWebhook.channel_id);
-    const channelName = channel ? channel.display_name : 'cannot find channel';
-
-    return (
-        <div className='installed-integrations__item installed-integrations__incoming-webhook'>
-            <div className='details'>
-                <div className='details-row'>
-                    <span className='name'>
-                        {channelName}
-                    </span>
-                    <span className='type'>
-                        <FormattedMessage
-                            id='installed_integrations.incomingWebhookType'
-                            defaultMessage='(Incoming Webhook)'
-                        />
-                    </span>
-                </div>
-                <div className='details-row'>
-                    <span className='description'>
-                        {Utils.getWindowLocationOrigin() + '/hooks/' + incomingWebhook.id}
-                    </span>
-                </div>
-            </div>
-        </div>
-    );
-}
-
-IncomingWebhook.propTypes = {
-    incomingWebhook: React.PropTypes.object.isRequired
-};
-
-function OutgoingWebhook({outgoingWebhook}) {
-    const channel = ChannelStore.get(outgoingWebhook.channel_id);
-    const channelName = channel ? channel.display_name : 'cannot find channel';
-
-    return (
-        <div className='installed-integrations__item installed-integrations__outgoing-webhook'>
-            <div className='details'>
-                <div className='details-row'>
-                    <span className='name'>
-                        {channelName}
-                    </span>
-                    <span className='type'>
-                        <FormattedMessage
-                            id='installed_integrations.outgoingWebhookType'
-                            defaultMessage='(Outgoing Webhook)'
-                        />
-                    </span>
-                </div>
-                <div className='details-row'>
-                    <span className='description'>
-                        {Utils.getWindowLocationOrigin() + '/hooks/' + outgoingWebhook.id}
-                    </span>
-                </div>
-            </div>
-        </div>
-    );
-}
-
-OutgoingWebhook.propTypes = {
-    outgoingWebhook: React.PropTypes.object.isRequired
-};
-- 
cgit v1.2.3-1-g7c22

