2020-11-25 18:56:31 +01:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
2020-11-26 11:56:24 +01:00
|
|
|
import MediaPreviewList from '../../MediaPreviewList';
|
|
|
|
|
import RelationPreviewList from '../../RelationPreviewList';
|
|
|
|
|
import Truncate from '../../Truncate';
|
|
|
|
|
import Truncated from '../../Truncated';
|
2020-11-25 18:56:31 +01:00
|
|
|
|
2020-12-01 12:20:35 +01:00
|
|
|
const Cell = ({ options }) => {
|
|
|
|
|
if (options.type === 'media') {
|
|
|
|
|
return <MediaPreviewList files={options.value} />;
|
2020-11-25 18:56:31 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-01 12:20:35 +01:00
|
|
|
if (options.type === 'relation') {
|
|
|
|
|
return <RelationPreviewList options={options} />;
|
2020-11-25 18:56:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Truncate>
|
2020-12-01 12:20:35 +01:00
|
|
|
<Truncated title={options.value}>{options.value}</Truncated>
|
2020-11-25 18:56:31 +01:00
|
|
|
</Truncate>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-01 12:20:35 +01:00
|
|
|
Cell.propTypes = {
|
|
|
|
|
options: PropTypes.shape({
|
|
|
|
|
cellId: PropTypes.string.isRequired,
|
|
|
|
|
metadatas: PropTypes.shape({
|
2020-12-03 13:04:55 +01:00
|
|
|
mainField: PropTypes.object,
|
2020-12-01 12:20:35 +01:00
|
|
|
}).isRequired,
|
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
|
relationType: PropTypes.string,
|
|
|
|
|
rowId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
|
|
|
type: PropTypes.string,
|
2020-12-08 15:30:32 +01:00
|
|
|
queryInfos: PropTypes.shape({
|
|
|
|
|
endPoint: PropTypes.string.isRequired,
|
|
|
|
|
}),
|
2020-12-01 12:20:35 +01:00
|
|
|
value: PropTypes.any,
|
|
|
|
|
}).isRequired,
|
2020-11-25 18:56:31 +01:00
|
|
|
};
|
|
|
|
|
|
2020-12-01 12:20:35 +01:00
|
|
|
export default memo(Cell);
|