UNPKG

@carbon/ibm-cloud-cognitive-cdai

Version:
54 lines (53 loc) 1.97 kB
// // Copyright IBM Corp. 2020, 2020 // // This source code is licensed under the Apache-2.0 license found in the // LICENSE file in the root directory of this source tree. // import React from 'react'; import PropTypes from 'prop-types'; import { Button } from 'carbon-components-react'; import { CheckmarkOutline16, Save16 } from '@carbon/icons-react'; import { idePrefix } from '../../globals/js/settings'; var IdeManualSave = function IdeManualSave(_ref) { var state = _ref.state, saveText = _ref.saveText, cancelText = _ref.cancelText, onSave = _ref.onSave, onCancel = _ref.onCancel; return /*#__PURE__*/React.createElement("div", { className: "".concat(idePrefix, "-manual-save") }, /*#__PURE__*/React.createElement(Button, { className: "".concat(idePrefix, "-manual-save__cancel-button ").concat(idePrefix, "-manual-save--button"), kind: "secondary", onClick: function onClick(evt) { return onCancel(evt); }, disabled: state === 'saved' }, cancelText), /*#__PURE__*/React.createElement(Button, { className: "".concat(idePrefix, "-manual-save__save-button ").concat(idePrefix, "-manual-save--button"), kind: "primary", onClick: function onClick(evt) { return onSave(evt); }, renderIcon: state === 'saved' ? CheckmarkOutline16 : Save16 }, saveText)); }; IdeManualSave.defaultProps = { state: 'save', saveText: '', cancelText: '' }; IdeManualSave.propTypes = { /** The text to show for the Cancel button. Must be pre-translated */ cancelText: PropTypes.string.isRequired, /** Function to call when the Cancel button is pressed */ onCancel: PropTypes.func, /** Function to call when the Save button is pressed */ onSave: PropTypes.func, /** The text to show for Save button. Must be pre-translated */ saveText: PropTypes.string.isRequired, /** The current state to show */ state: PropTypes.oneOf(['save', 'saved']).isRequired }; export default IdeManualSave;