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-03-23 14:15:45 +08:00
|
|
|
const { err, filePerm, fileType, repoID, filePath } = window.app.pageOptions;
|
|
|
|
|
|
|
|
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>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let canOpenViaClient = false;
|
|
|
|
if (filePerm == 'rw' && (fileType == 'Document' || fileType == 'SpreadSheet')) {
|
|
|
|
canOpenViaClient = true;
|
|
|
|
}
|
|
|
|
|
2019-02-22 18:16:44 +08:00
|
|
|
return (
|
|
|
|
<div className="file-view-content flex-1">
|
|
|
|
<div className="file-view-tip">
|
|
|
|
{errorMsg}
|
|
|
|
<a href="?dl=1" className="btn btn-secondary">{gettext('Download')}</a>
|
2019-03-23 14:15:45 +08:00
|
|
|
{canOpenViaClient && (
|
|
|
|
<React.Fragment>
|
|
|
|
<a className="open-via-client" href={`seafile://openfile?repo_id=${repoID}&path=${encodeURIComponent(filePath)}`}>{gettext('Open via Client')}</a>
|
|
|
|
<p className="tip">{gettext('Please install the desktop client to open file via client.')}</p>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
2019-02-22 18:16:44 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-03-23 14:15:45 +08:00
|
|
|
FileViewTip.propTypes = propTypes;
|
2019-02-22 18:16:44 +08:00
|
|
|
|
|
|
|
export default FileViewTip;
|