diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-04-08 11:51:28 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-04-08 11:51:28 -0400 |
commit | 77ee1ce7fee698847e211dc15d4673300901aa48 (patch) | |
tree | 115391ae591f7e008cf357238be612e7482742fc /webapp/components/backstage/installed_incoming_webhooks.jsx | |
parent | 742d611ba4c08dbc4d30d3ef7a40a872186bd9eb (diff) | |
download | chat-77ee1ce7fee698847e211dc15d4673300901aa48.tar.gz chat-77ee1ce7fee698847e211dc15d4673300901aa48.tar.bz2 chat-77ee1ce7fee698847e211dc15d4673300901aa48.zip |
PLT-2553 Updated backstage page navigation (#2661)
* Updated integrations list based on feedback
* Reorganized Integrations pages
* Repurposed AddIntegration page as a landing page for Integrations
* Moved backstage breadcrumb header into its own component
* Removed unnecessary prop
* Fixed Save links on AddIntegration pages
Diffstat (limited to 'webapp/components/backstage/installed_incoming_webhooks.jsx')
-rw-r--r-- | webapp/components/backstage/installed_incoming_webhooks.jsx | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/webapp/components/backstage/installed_incoming_webhooks.jsx b/webapp/components/backstage/installed_incoming_webhooks.jsx new file mode 100644 index 000000000..de7154afe --- /dev/null +++ b/webapp/components/backstage/installed_incoming_webhooks.jsx @@ -0,0 +1,85 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import * as AsyncClient from 'utils/async_client.jsx'; +import IntegrationStore from 'stores/integration_store.jsx'; + +import {FormattedMessage} from 'react-intl'; +import InstalledIncomingWebhook from './installed_incoming_webhook.jsx'; +import InstalledIntegrations from './installed_integrations.jsx'; + +export default class InstalledIncomingWebhooks extends React.Component { + constructor(props) { + super(props); + + this.handleIntegrationChange = this.handleIntegrationChange.bind(this); + + this.deleteIncomingWebhook = this.deleteIncomingWebhook.bind(this); + + this.state = { + incomingWebhooks: [] + }; + } + + componentWillMount() { + IntegrationStore.addChangeListener(this.handleIntegrationChange); + + if (window.mm_config.EnableIncomingWebhooks === 'true') { + if (IntegrationStore.hasReceivedIncomingWebhooks()) { + this.setState({ + incomingWebhooks: IntegrationStore.getIncomingWebhooks() + }); + } else { + AsyncClient.listIncomingHooks(); + } + } + } + + componentWillUnmount() { + IntegrationStore.removeChangeListener(this.handleIntegrationChange); + } + + handleIntegrationChange() { + this.setState({ + incomingWebhooks: IntegrationStore.getIncomingWebhooks() + }); + } + + deleteIncomingWebhook(incomingWebhook) { + AsyncClient.deleteIncomingHook(incomingWebhook.id); + } + + render() { + const incomingWebhooks = this.state.incomingWebhooks.map((incomingWebhook) => { + return ( + <InstalledIncomingWebhook + key={incomingWebhook.id} + incomingWebhook={incomingWebhook} + onDelete={this.deleteIncomingWebhook} + /> + ); + }); + + return ( + <InstalledIntegrations + header={ + <FormattedMessage + id='installed_incoming_webhooks.header' + defaultMessage='Installed Incoming Webhooks' + /> + } + addText={ + <FormattedMessage + id='installed_incoming_webhooks.add' + defaultMessage='Add Incoming Webhook' + /> + } + addLink='/settings/integrations/incoming_webhooks/add' + > + {incomingWebhooks} + </InstalledIntegrations> + ); + } +} |