"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactBootstrap = require("react-bootstrap");
var _actions = require("./actions");
var _reactFontawesome = require("@fortawesome/react-fontawesome");
var _identifierModalBody = _interopRequireDefault(require("./identifier-modal-body"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _reactRedux = require("react-redux");
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
/*
* Copyright (C) 2016 Ben Ockmore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* Container component. The IdentifierEditor component contains a number of
* IdentifierRow elements, and renders these inside a modal, which appears when
* the show property of the component is set.
*
* @param {Object} props - The properties passed to the component.
* @param {Array} props.identifiers - The list of identifiers to be rendered in
* the editor.
* @param {Array} props.identifierTypes - The list of possible types for an
* identifier.
* @param {Function} props.onAddIdentifier - A function to be called when the
* button to add an identifier is clicked.
* @param {Function} props.onClose - A function to be called when the button to
* close the editor is clicked.
* @param {boolean} props.show - Whether or not the editor modal should be
* visible.
* @returns {ReactElement} React element containing the rendered
* IdentifierEditor.
*/
var IdentifierEditor = function IdentifierEditor(_ref) {
var identifierTypes = _ref.identifierTypes,
onClose = _ref.onClose,
show = _ref.show;
var helpText = "identity of the entity in other databases and services, such as ISBN, barcode, MusicBrainz ID, WikiData ID, OpenLibrary ID, etc.\n\tYou can enter either the identifier only (Q2517049) or a full link (https://www.wikidata.org/wiki/Q2517049).";
var helpIconElement = /*#__PURE__*/_react.default.createElement(_reactBootstrap.OverlayTrigger, {
delay: 50,
overlay: /*#__PURE__*/_react.default.createElement(_reactBootstrap.Tooltip, {
id: "identifier-editor-tooltip"
}, helpText),
placement: "right"
}, /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
className: "fa-sm",
icon: _freeSolidSvgIcons.faQuestionCircle
}));
return /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal, {
show: show,
size: "lg",
onHide: onClose
}, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Header, null, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Title, null, "Identifier Editor ", helpIconElement)), /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Body, null, /*#__PURE__*/_react.default.createElement(_identifierModalBody.default, {
identifierTypes: identifierTypes
})), /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Footer, null, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Button, {
variant: "primary",
onClick: onClose
}, "Close")));
};
IdentifierEditor.displayName = 'IdentifierEditor';
IdentifierEditor.propTypes = {
identifierTypes: _propTypes.default.array.isRequired,
onClose: _propTypes.default.func.isRequired,
show: _propTypes.default.bool
};
IdentifierEditor.defaultProps = {
show: false
};
function mapDispatchToProps(dispatch) {
return {
onClose: function onClose() {
dispatch((0, _actions.hideIdentifierEditor)());
dispatch((0, _actions.removeEmptyIdentifiers)());
}
};
}
var _default = (0, _reactRedux.connect)(null, mapDispatchToProps)(IdentifierEditor);
exports.default = _default;
//# sourceMappingURL=identifier-editor.js.map