2019-02-22 18:16:44 +08:00
|
|
|
import React from 'react';
|
2019-03-23 14:15:45 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2019-02-22 18:16:44 +08:00
|
|
|
import { gettext } from '../../utils/constants';
|
|
|
|
|
2019-05-16 12:25:12 +08:00
|
|
|
const { err } = window.app.pageOptions;
|
2019-03-23 14:15:45 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
errorMsg: PropTypes.string
|
|
|
|
};
|
2019-02-22 18:16:44 +08:00
|
|
|
|
|
|
|
class FileViewTip extends React.Component {
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let errorMsg;
|
|
|
|
if (err == 'File preview unsupported') {
|
|
|
|
errorMsg = <p>{gettext('Online view is not applicable to this file format')}</p>;
|
|
|
|
} else {
|
2019-03-23 14:15:45 +08:00
|
|
|
errorMsg = <p className="error">{err || this.props.errorMsg}</p>;
|
|
|
|
}
|
|
|
|
|
2019-02-22 18:16:44 +08:00
|
|
|
return (
|
2019-04-30 12:14:23 +08:00
|
|
|
<div className="file-view-content flex-1 o-auto">
|
2019-02-22 18:16:44 +08:00
|
|
|
<div className="file-view-tip">
|
|
|
|
{errorMsg}
|
|
|
|
<a href="?dl=1" className="btn btn-secondary">{gettext('Download')}</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-02 13:56:35 +08:00
|
|
|
);
|
2019-02-22 18:16:44 +08:00
|
|
|
}
|
|
|
|
}
|
2019-03-23 14:15:45 +08:00
|
|
|
FileViewTip.propTypes = propTypes;
|
2019-02-22 18:16:44 +08:00
|
|
|
|
|
|
|
export default FileViewTip;
|