'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports.default = ReportModal;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactIntl = require('react-intl');

var _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

var _InvocationModal = require('../invocable/InvocationModal');

var _InvocationModal2 = _interopRequireDefault(_InvocationModal);

var _RunReportButton = require('../../../styles/cspace-ui/RunReportButton.css');

var _RunReportButton2 = _interopRequireDefault(_RunReportButton);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

const messages = (0, _reactIntl.defineMessages)({
  prompt: {
    'id': 'reportModal.prompt',
    'defaultMessage': 'Run this report?'
  },
  unsaved: {
    'id': 'reportModal.unsaved',
    'defaultMessage': 'This record has changes that have not been saved. The report will not include any unsaved data.'
  },
  cancel: {
    'id': 'reportModal.cancel',
    'defaultMessage': 'Cancel'
  },
  run: {
    'id': 'reportModal.run',
    'defaultMessage': 'Run'
  }
});

const propTypes = {
  config: _propTypes2.default.object,
  isOpen: _propTypes2.default.bool,
  isRecordModified: _propTypes2.default.bool,
  reportItem: _propTypes2.default.instanceOf(_immutable2.default.Map),
  onCancelButtonClick: _propTypes2.default.func,
  onCloseButtonClick: _propTypes2.default.func,
  onRunButtonClick: _propTypes2.default.func
};

function ReportModal(props) {
  const reportItem = props.reportItem,
        remainingProps = _objectWithoutProperties(props, ['reportItem']);

  return _react2.default.createElement(_InvocationModal2.default, _extends({
    invocationItem: reportItem,
    messages: messages,
    runButtonClassName: _RunReportButton2.default.common,
    type: 'report'
  }, remainingProps));
}

ReportModal.propTypes = propTypes;