From bb13476326b81191ba4aa854c25224638735272c Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 28 Mar 2016 16:17:17 -0400 Subject: Added delete buttons to InstalledIntegrations --- .../backstage/installed_incoming_webhook.jsx | 71 +++++++++++++++++++ .../backstage/installed_integrations.jsx | 80 ++++------------------ .../backstage/installed_outgoing_webhook.jsx | 71 +++++++++++++++++++ 3 files changed, 156 insertions(+), 66 deletions(-) create mode 100644 webapp/components/backstage/installed_incoming_webhook.jsx create mode 100644 webapp/components/backstage/installed_outgoing_webhook.jsx (limited to 'webapp/components') diff --git a/webapp/components/backstage/installed_incoming_webhook.jsx b/webapp/components/backstage/installed_incoming_webhook.jsx new file mode 100644 index 000000000..4ca421a02 --- /dev/null +++ b/webapp/components/backstage/installed_incoming_webhook.jsx @@ -0,0 +1,71 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import ChannelStore from 'stores/channel_store.jsx'; +import * as Utils from 'utils/utils.jsx'; + +import {FormattedMessage} from 'react-intl'; + +export default class InstalledIncomingWebhook extends React.Component { + static get propTypes() { + return { + incomingWebhook: React.PropTypes.object.isRequired, + onDeleteClick: React.PropTypes.func.isRequired + }; + } + + constructor(props) { + super(props); + + this.handleDeleteClick = this.handleDeleteClick.bind(this); + } + + handleDeleteClick(e) { + e.preventDefault(); + + this.props.onDeleteClick(this.props.incomingWebhook); + } + + render() { + const incomingWebhook = this.props.incomingWebhook; + + const channel = ChannelStore.get(incomingWebhook.channel_id); + const channelName = channel ? channel.display_name : 'cannot find channel'; + + return ( +
+
+
+ + {channelName} + + + + +
+
+ + {Utils.getWindowLocationOrigin() + '/hooks/' + incomingWebhook.id} + +
+
+
+ + + +
+
+ ); + } +} 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( - ); } @@ -213,9 +224,10 @@ export default class InstalledIntegrations extends React.Component { } integrations.push( - ); } @@ -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 ( -
-
-
- - {channelName} - - - - -
-
- - {Utils.getWindowLocationOrigin() + '/hooks/' + incomingWebhook.id} - -
-
-
- ); -} - -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 ( -
-
-
- - {channelName} - - - - -
-
- - {Utils.getWindowLocationOrigin() + '/hooks/' + outgoingWebhook.id} - -
-
-
- ); -} - -OutgoingWebhook.propTypes = { - outgoingWebhook: React.PropTypes.object.isRequired -}; diff --git a/webapp/components/backstage/installed_outgoing_webhook.jsx b/webapp/components/backstage/installed_outgoing_webhook.jsx new file mode 100644 index 000000000..3c0e20634 --- /dev/null +++ b/webapp/components/backstage/installed_outgoing_webhook.jsx @@ -0,0 +1,71 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import ChannelStore from 'stores/channel_store.jsx'; +import * as Utils from 'utils/utils.jsx'; + +import {FormattedMessage} from 'react-intl'; + +export default class InstalledOutgoingWebhook extends React.Component { + static get propTypes() { + return { + outgoingWebhook: React.PropTypes.object.isRequired, + onDeleteClick: React.PropTypes.func.isRequired + }; + } + + constructor(props) { + super(props); + + this.handleDeleteClick = this.handleDeleteClick.bind(this); + } + + handleDeleteClick(e) { + e.preventDefault(); + + this.props.onDeleteClick(this.props.outgoingWebhook); + } + + render() { + const outgoingWebhook = this.props.outgoingWebhook; + + const channel = ChannelStore.get(outgoingWebhook.channel_id); + const channelName = channel ? channel.display_name : 'cannot find channel'; + + return ( +
+
+
+ + {channelName} + + + + +
+
+ + {Utils.getWindowLocationOrigin() + '/hooks/' + outgoingWebhook.id} + +
+
+
+ + + +
+
+ ); + } +} -- cgit v1.2.3-1-g7c22