import React from 'react'; import PropTypes from 'prop-types'; // eslint-disable-next-line no-unused-vars import { withTranslation } from 'react-i18next'; import ProgressBar from 'react-bootstrap/es/ProgressBar'; import GrowiArchiveImportOption from '@commons/models/admin/growi-archive-import-option'; const MODE_ATTR_MAP = { insert: { color: 'info', icon: 'icon-plus', label: 'Insert' }, upsert: { color: 'success', icon: 'icon-plus', label: 'Upsert' }, flushAndInsert: { color: 'danger', icon: 'icon-refresh', label: 'Flush and Insert' }, }; export const DEFAULT_MODE = 'insert'; export const MODE_RESTRICTED_COLLECTION = { configs: ['flushAndInsert'], users: ['insert', 'upsert'], }; export default class GrowiZipImportItem extends React.Component { constructor(props) { super(props); this.changeHandler = this.changeHandler.bind(this); this.modeSelectedHandler = this.modeSelectedHandler.bind(this); this.configButtonClickedHandler = this.configButtonClickedHandler.bind(this); this.errorLinkClickedHandler = this.errorLinkClickedHandler.bind(this); } changeHandler(e) { const { collectionName, onChange } = this.props; if (onChange != null) { onChange(collectionName, e.target.checked); } } modeSelectedHandler(mode) { const { collectionName, onOptionChange } = this.props; if (onOptionChange == null) { return; } onOptionChange(collectionName, { mode }); } configButtonClickedHandler() { const { collectionName, onConfigButtonClicked } = this.props; if (onConfigButtonClicked == null) { return; } onConfigButtonClicked(collectionName); } errorLinkClickedHandler() { const { collectionName, onErrorLinkClicked } = this.props; if (onErrorLinkClicked == null) { return; } onErrorLinkClicked(collectionName); } renderModeLabel(mode, isColorized = false) { const attrMap = MODE_ATTR_MAP[mode]; const className = isColorized ? `text-${attrMap.color}` : ''; return {attrMap.label}; } renderCheckbox() { const { collectionName, isSelected, isImporting, } = this.props; return (