@atlaskit/profilecard
Version:
A React component to display a card with user information.
98 lines • 4.25 kB
JavaScript
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React, { useCallback } from 'react';
import { defineMessages, useIntl } from 'react-intl-next';
import Button from '@atlaskit/button/new';
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
import { Text } from '@atlaskit/primitives/compiled';
export var AgentDeleteConfirmationModal = function AgentDeleteConfirmationModal(_ref) {
var onClose = _ref.onClose,
agentName = _ref.agentName,
isOpen = _ref.isOpen,
onSubmit = _ref.onSubmit,
agentId = _ref.agentId;
var _useIntl = useIntl(),
formatMessage = _useIntl.formatMessage;
var handleDeleteAgent = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (!agentId) {
_context.next = 4;
break;
}
_context.next = 3;
return onSubmit();
case 3:
onClose();
case 4:
case "end":
return _context.stop();
}
}, _callee);
})), [agentId, onClose, onSubmit]);
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(Modal, {
width: "small"
}, /*#__PURE__*/React.createElement(ModalHeader, {
hasCloseButton: true
}, /*#__PURE__*/React.createElement(ModalTitle, null, formatMessage(messages.title, {
agentName: agentName
}))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, {
as: "p"
}, formatMessage(messages.body)), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
appearance: "subtle",
onClick: onClose
}, formatMessage(messages.cancelText)), /*#__PURE__*/React.createElement(Button, {
appearance: "danger",
onClick: function onClick(_e, _event) {
handleDeleteAgent();
}
}, formatMessage(messages.confirmText))))));
};
var messages = defineMessages({
cancelText: {
id: 'profilecard.agent-profile.agent-delete-confirm.cancel-text',
defaultMessage: 'Cancel',
description: 'Button label to cancel the agent deletion action in the confirmation modal'
},
confirmText: {
id: 'profilecard.agent-profile.agent-delete-confirm.confirm-text',
defaultMessage: 'Delete',
description: 'Button label to confirm and permanently delete the agent in the confirmation modal'
},
title: {
id: 'profilecard.agent-profile.delete-agent-confirm-title',
defaultMessage: 'Delete "{agentName}"?',
description: 'Title text for the delete agent confirmation modal'
},
body: {
id: 'profilecard.agent-profile.delete-agent-confirm-body',
defaultMessage: "Are you sure you want to delete this agent? This action cannot be undone.",
description: 'Body text for the delete agent confirmation modal'
},
error: {
id: 'profilecard.agent-profile.delete-agent-error',
defaultMessage: 'Could not delete agent',
description: 'Error message displayed when an agent cannot be deleted'
},
errorAgentNotFound: {
id: 'profilecard.agent-profile.delete-agent-error.agent-not-found',
defaultMessage: 'That agent could not be found.',
description: 'Error message displayed when an agent cannot be found'
},
errorAgentInUse: {
id: 'profilecard.agent-profile.delete-agent-error.agent-in-use',
defaultMessage: 'Agent is currently in use. Try again later.',
description: 'Error message displayed when an agent is in use'
},
errorIncorrectOwner: {
id: 'profilecard.agent-profile.delete-agent-error.incorrect-owner',
defaultMessage: 'You cannot delete agents you have not created yourself. Please contact the agent owner.',
description: 'Error message displayed when the agent owner is incorrect'
},
agentDeletedSuccess: {
id: 'profilecard.agent-profile.delete-agent-success',
defaultMessage: 'Agent has been deleted!',
description: 'Success message displayed when an agent is deleted'
}
});