2024-11-08 15:31:48 +08:00
|
|
|
import React from 'react';
|
2024-11-11 13:44:09 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2024-11-08 15:31:48 +08:00
|
|
|
import CellFormatter from '../../../../components/cell-formatter';
|
|
|
|
import { CellType } from '../../../../constants';
|
|
|
|
import { Utils } from '../../../../../utils/utils';
|
|
|
|
|
|
|
|
const SPECIAL_FILE_ICON = [
|
|
|
|
'excel.png',
|
|
|
|
'md.png',
|
|
|
|
'ppt.png',
|
|
|
|
'sdoc_notification.ico',
|
|
|
|
'sdoc.png',
|
|
|
|
'txt.png',
|
|
|
|
'word.png',
|
|
|
|
];
|
|
|
|
|
2025-05-28 21:29:46 +08:00
|
|
|
const Formatter = ({ value, column, record, tagsData, ...params }) => {
|
2024-11-08 15:31:48 +08:00
|
|
|
let className = '';
|
|
|
|
|
|
|
|
if (column.type === CellType.FILE_NAME && value) {
|
|
|
|
const icon = Utils.getFileIconName(value);
|
|
|
|
if (SPECIAL_FILE_ICON.includes(icon)) {
|
|
|
|
className = 'sf-metadata-special-file-name-formatter';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-05-28 21:29:46 +08:00
|
|
|
return (<CellFormatter { ...params } readonly={true} className={className} value={value} field={column} record={record} tagsData={tagsData} />);
|
2024-11-11 13:44:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Formatter.propTypes = {
|
|
|
|
value: PropTypes.any,
|
|
|
|
column: PropTypes.object,
|
|
|
|
record: PropTypes.object,
|
2024-11-08 15:31:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Formatter;
|