From d9a297d6291838e08a4acdbd603c35601c0e9878 Mon Sep 17 00:00:00 2001 From: Ari Autio Date: Thu, 2 Mar 2017 19:34:53 +0200 Subject: PLT-4929: Confirmation Dialog when Deleting Entry on the Integrations pages (#5529) --- .../integrations/components/delete_integration.jsx | 89 ++++++++++++++++++++++ .../integrations/components/installed_command.jsx | 19 ++--- .../components/installed_incoming_webhook.jsx | 19 ++--- .../components/installed_oauth_app.jsx | 19 ++--- .../components/installed_outgoing_webhook.jsx | 19 ++--- webapp/i18n/en.json | 6 ++ 6 files changed, 123 insertions(+), 48 deletions(-) create mode 100644 webapp/components/integrations/components/delete_integration.jsx diff --git a/webapp/components/integrations/components/delete_integration.jsx b/webapp/components/integrations/components/delete_integration.jsx new file mode 100644 index 000000000..442ac57f7 --- /dev/null +++ b/webapp/components/integrations/components/delete_integration.jsx @@ -0,0 +1,89 @@ +import React from 'react'; +import {FormattedMessage} from 'react-intl'; + +import ConfirmModal from '../../confirm_modal.jsx'; + +export default class DeleteIntegration extends React.Component { + constructor(props) { + super(props); + + this.handleConfirm = this.handleConfirm.bind(this); + this.handleCancel = this.handleCancel.bind(this); + this.handleOpenModal = this.handleOpenModal.bind(this); + + this.state = { + showDeleteModal: false + }; + } + + handleOpenModal(e) { + e.preventDefault(); + + this.setState({ + showDeleteModal: true + }); + } + + handleConfirm() { + this.props.onDelete(); + } + + handleCancel() { + this.setState({ + showDeleteModal: false + }); + } + + render() { + const title = ( + + ); + + const message = ( +
+ + +
+ ); + + const confirmButton = ( + + ); + + return ( + + + + + + + ); + } +} + +DeleteIntegration.propTypes = { + messageId: React.PropTypes.string.isRequired, + onDelete: React.PropTypes.func.isRequired +}; diff --git a/webapp/components/integrations/components/installed_command.jsx b/webapp/components/integrations/components/installed_command.jsx index 2e45739a0..f07d261b8 100644 --- a/webapp/components/integrations/components/installed_command.jsx +++ b/webapp/components/integrations/components/installed_command.jsx @@ -5,6 +5,8 @@ import React from 'react'; import {Link} from 'react-router'; import {FormattedMessage} from 'react-intl'; +import DeleteIntegration from './delete_integration.jsx'; + export default class InstalledCommand extends React.Component { static get propTypes() { return { @@ -33,9 +35,7 @@ export default class InstalledCommand extends React.Component { this.props.onRegenToken(this.props.command); } - handleDelete(e) { - e.preventDefault(); - + handleDelete() { this.props.onDelete(this.props.command); } @@ -106,15 +106,10 @@ export default class InstalledCommand extends React.Component { /> {' - '} - - - + ); } diff --git a/webapp/components/integrations/components/installed_incoming_webhook.jsx b/webapp/components/integrations/components/installed_incoming_webhook.jsx index 52d0d7d67..7091f5eb8 100644 --- a/webapp/components/integrations/components/installed_incoming_webhook.jsx +++ b/webapp/components/integrations/components/installed_incoming_webhook.jsx @@ -3,6 +3,8 @@ import React from 'react'; +import DeleteIntegration from './delete_integration.jsx'; + import ChannelStore from 'stores/channel_store.jsx'; import {getSiteURL} from 'utils/url.jsx'; @@ -27,9 +29,7 @@ export default class InstalledIncomingWebhook extends React.Component { this.handleDelete = this.handleDelete.bind(this); } - handleDelete(e) { - e.preventDefault(); - + handleDelete() { this.props.onDelete(this.props.incomingWebhook); } @@ -97,15 +97,10 @@ export default class InstalledIncomingWebhook extends React.Component { /> {' - '} - - - + ); } diff --git a/webapp/components/integrations/components/installed_oauth_app.jsx b/webapp/components/integrations/components/installed_oauth_app.jsx index a6dea65bf..bb6e271d4 100644 --- a/webapp/components/integrations/components/installed_oauth_app.jsx +++ b/webapp/components/integrations/components/installed_oauth_app.jsx @@ -10,6 +10,8 @@ import * as Utils from 'utils/utils.jsx'; import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; import {regenerateOAuthAppSecret} from 'actions/admin_actions.jsx'; +import DeleteIntegration from './delete_integration.jsx'; + const FAKE_SECRET = '***************'; export default class InstalledOAuthApp extends React.Component { @@ -61,9 +63,7 @@ export default class InstalledOAuthApp extends React.Component { ); } - handleDelete(e) { - e.preventDefault(); - + handleDelete() { this.props.onDelete(this.props.oauthApp); } @@ -246,15 +246,10 @@ export default class InstalledOAuthApp extends React.Component { {' - '} {regen} {' - '} - - - + ); diff --git a/webapp/components/integrations/components/installed_outgoing_webhook.jsx b/webapp/components/integrations/components/installed_outgoing_webhook.jsx index ebf4f75e1..a452979ae 100644 --- a/webapp/components/integrations/components/installed_outgoing_webhook.jsx +++ b/webapp/components/integrations/components/installed_outgoing_webhook.jsx @@ -8,6 +8,8 @@ import ChannelStore from 'stores/channel_store.jsx'; import {FormattedMessage} from 'react-intl'; import {Link} from 'react-router'; +import DeleteIntegration from './delete_integration.jsx'; + export default class InstalledOutgoingWebhook extends React.Component { static get propTypes() { return { @@ -34,9 +36,7 @@ export default class InstalledOutgoingWebhook extends React.Component { this.props.onRegenToken(this.props.outgoingWebhook); } - handleDelete(e) { - e.preventDefault(); - + handleDelete() { this.props.onDelete(this.props.outgoingWebhook); } @@ -170,15 +170,10 @@ export default class InstalledOutgoingWebhook extends React.Component { /> {' - '} - - - + ); } diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index 7bddea682..a0ae76c72 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -1448,6 +1448,7 @@ "help.messaging.write": "**Write messages** using the text input box at the bottom of Mattermost. Press ENTER to send a message. Use SHIFT+ENTER to create a new line without sending a message.", "installed_command.header": "Slash Commands", "installed_commands.add": "Add Slash Command", + "installed_commands.delete.confirm": "This action permanently deletes the slash command and breaks any integrations using it. Are you sure you want to delete it?", "installed_commands.empty": "No commands found", "installed_commands.header": "Slash Commands", "installed_commands.help": "Create slash commands for use in external integrations. Please see the {link} to learn more.", @@ -1455,6 +1456,7 @@ "installed_commands.search": "Search Slash Commands", "installed_commands.unnamed_command": "Unnamed Slash Command", "installed_incoming_webhooks.add": "Add Incoming Webhook", + "installed_incoming_webhooks.delete.confirm": "This action permanently deletes the incoming webhook and breaks any integrations using it. Are you sure you want to delete it?", "installed_incoming_webhooks.empty": "No incoming webhooks found", "installed_incoming_webhooks.header": "Incoming Webhooks", "installed_incoming_webhooks.help": "Create incoming webhook URLs for use in external integrations. Please see the {link} to learn more.", @@ -1481,6 +1483,7 @@ "installed_oauth_apps.callbackUrls": "Callback URLs (One Per Line)", "installed_oauth_apps.cancel": "Cancel", "installed_oauth_apps.description": "Description", + "installed_oauth_apps.delete.confirm": "This action permanently deletes the OAuth 2.0 application and breaks any integrations using it. Are you sure you want to delete it?", "installed_oauth_apps.empty": "No OAuth 2.0 Applications found", "installed_oauth_apps.header": "OAuth 2.0 Applications", "installed_oauth_apps.help": "Create OAuth 2.0 applications to securely integrate bots and third-party applications with Mattermost. Please see {link} to learn more.", @@ -1495,6 +1498,7 @@ "installed_oauth_apps.trusted.no": "No", "installed_oauth_apps.trusted.yes": "Yes", "installed_outgoing_webhooks.add": "Add Outgoing Webhook", + "installed_outgoing_webhooks.delete.confirm": "This action permanently deletes the outgoing webhook and breaks any integrations using it. Are you sure you want to delete it?", "installed_outgoing_webhooks.empty": "No outgoing webhooks found", "installed_outgoing_webhooks.header": "Outgoing Webhooks", "installed_outgoing_webhooks.help": "Create outgoing webhook URLs for use in external integrations. Please see the {link} to learn more.", @@ -1504,6 +1508,8 @@ "integrations.add": "Add", "integrations.command.description": "Slash commands send events to external integrations", "integrations.command.title": "Slash Command", + "integrations.delete.confirm.button": "Delete", + "integrations.delete.confirm.title": "Delete Integration", "integrations.done": "Done", "integrations.edit": "Edit", "integrations.header": "Integrations", -- cgit v1.2.3-1-g7c22