2020-03-04 12:16:26 +01:00
|
|
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
2019-07-17 15:35:19 +02:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
import pluginId from '../../pluginId';
|
|
|
|
|
import IconRemove from '../../assets/images/icon_remove.svg';
|
2020-04-16 11:13:38 +02:00
|
|
|
import { Span } from './components';
|
2019-07-17 15:35:19 +02:00
|
|
|
|
2020-01-21 16:03:31 +01:00
|
|
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
|
|
|
|
2020-06-29 15:48:51 +02:00
|
|
|
const Relation = ({ data, isDisabled, mainField, onRemove, to }) => {
|
|
|
|
|
const cursor = isDisabled ? 'not-allowed' : 'pointer';
|
|
|
|
|
|
2019-07-17 15:35:19 +02:00
|
|
|
return (
|
|
|
|
|
<>
|
2020-06-29 15:48:51 +02:00
|
|
|
<div style={{ cursor }}>
|
2019-07-17 15:35:19 +02:00
|
|
|
<div className="dragHandle">
|
|
|
|
|
<span />
|
|
|
|
|
</div>
|
|
|
|
|
<FormattedMessage id={`${pluginId}.containers.Edit.clickToJump`}>
|
|
|
|
|
{title => (
|
|
|
|
|
<Link to={to} title={title}>
|
2020-04-16 11:13:38 +02:00
|
|
|
<Span>{data[mainField]}</Span>
|
2019-07-17 15:35:19 +02:00
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</FormattedMessage>
|
|
|
|
|
</div>
|
2020-06-29 15:48:51 +02:00
|
|
|
<div style={{ cursor }}>
|
2019-07-17 15:35:19 +02:00
|
|
|
<img src={IconRemove} alt="Remove Icon" onClick={onRemove} />
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Relation.defaultProps = {
|
|
|
|
|
onRemove: () => {},
|
|
|
|
|
to: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Relation.propTypes = {
|
|
|
|
|
data: PropTypes.object.isRequired,
|
2020-06-29 15:48:51 +02:00
|
|
|
isDisabled: PropTypes.bool.isRequired,
|
2019-07-17 15:35:19 +02:00
|
|
|
mainField: PropTypes.string.isRequired,
|
|
|
|
|
onRemove: PropTypes.func,
|
|
|
|
|
to: PropTypes.string,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default memo(Relation);
|