From 46f448899bf715fa2b557562a6a01d80ca4fc6b4 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 22 Oct 2015 14:16:51 -0400
Subject: In webhooks UI handle error if channel can't be found, also use
 display name over url name, plus warning fixes

---
 .../user_settings/manage_incoming_hooks.jsx        | 52 +++++++++++++---------
 1 file changed, 32 insertions(+), 20 deletions(-)

(limited to 'web/react/components/user_settings/manage_incoming_hooks.jsx')

diff --git a/web/react/components/user_settings/manage_incoming_hooks.jsx b/web/react/components/user_settings/manage_incoming_hooks.jsx
index f5a2774a0..812169be4 100644
--- a/web/react/components/user_settings/manage_incoming_hooks.jsx
+++ b/web/react/components/user_settings/manage_incoming_hooks.jsx
@@ -96,7 +96,14 @@ export default class ManageIncomingHooks extends React.Component {
         const options = [];
         channels.forEach((channel) => {
             if (channel.type !== Constants.DM_CHANNEL) {
-                options.push(<option value={channel.id}>{channel.name}</option>);
+                options.push(
+                    <option
+                        key={'incoming-hook' + channel.id}
+                        value={channel.id}
+                    >
+                        {channel.display_name}
+                    </option>
+                );
             }
         });
 
@@ -108,26 +115,31 @@ export default class ManageIncomingHooks extends React.Component {
         const hooks = [];
         this.state.hooks.forEach((hook) => {
             const c = ChannelStore.get(hook.channel_id);
-            hooks.push(
-                <div className='font--small'>
-                    <div className='padding-top x2 divider-light'></div>
-                    <div className='padding-top x2'>
-                        <strong>{'URL: '}</strong><span className='word-break--all'>{Utils.getWindowLocationOrigin() + '/hooks/' + hook.id}</span>
-                    </div>
-                    <div className='padding-top'>
-                        <strong>{'Channel: '}</strong>{c.name}
-                    </div>
-                    <div className='padding-top'>
-                        <a
-                            className={'text-danger'}
-                            href='#'
-                            onClick={this.removeHook.bind(this, hook.id)}
-                        >
-                            {'Remove'}
-                        </a>
+            if (c) {
+                hooks.push(
+                    <div
+                        key={hook.id}
+                        className='font--small'
+                    >
+                        <div className='padding-top x2 divider-light'></div>
+                        <div className='padding-top x2'>
+                            <strong>{'URL: '}</strong><span className='word-break--all'>{Utils.getWindowLocationOrigin() + '/hooks/' + hook.id}</span>
+                        </div>
+                        <div className='padding-top'>
+                            <strong>{'Channel: '}</strong>{c.display_name}
+                        </div>
+                        <div className='padding-top'>
+                            <a
+                                className={'text-danger'}
+                                href='#'
+                                onClick={this.removeHook.bind(this, hook.id)}
+                            >
+                                {'Remove'}
+                            </a>
+                        </div>
                     </div>
-                </div>
-            );
+                );
+            }
         });
 
         let displayHooks;
-- 
cgit v1.2.3-1-g7c22

