mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 14:21:23 +00:00
Merge branch '7.0'
This commit is contained in:
@@ -87,14 +87,7 @@ class DirTool extends React.Component {
|
||||
let trashUrl = siteRoot + 'repo/' + repoID + '/trash/';
|
||||
let historyUrl = siteRoot + 'repo/history/' + repoID + '/';
|
||||
if (permission) {
|
||||
if (isFile) { // isFile
|
||||
historyUrl = siteRoot + 'repo/file_revisions/' + repoID + '/?p=' + Utils.encodePath(currentPath);
|
||||
return (
|
||||
<ul className="path-toolbar">
|
||||
<li className="toolbar-item"><a className="op-link sf2-icon-history" href={historyUrl} title={gettext('History')} aria-label={gettext('History')}></a></li>
|
||||
</ul>
|
||||
);
|
||||
} else {
|
||||
if (!isFile) {
|
||||
if (name) { // name not '' is not root path
|
||||
trashUrl = siteRoot + 'repo/' + repoID + '/trash/?path=' + encodeURIComponent(currentPath);
|
||||
return (
|
||||
|
@@ -110,9 +110,9 @@ class FileChooser extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentRepoToggle = () => [
|
||||
this.setState({isCurrentRepoShow: !this.state.isCurrentRepoShow})
|
||||
]
|
||||
onCurrentRepoToggle = () => {
|
||||
this.setState({isCurrentRepoShow: !this.state.isCurrentRepoShow});
|
||||
}
|
||||
|
||||
onDirentItemClick = (repo, filePath, dirent) => {
|
||||
this.props.onDirentItemClick(repo, filePath, dirent);
|
||||
@@ -310,7 +310,7 @@ class FileChooser extends React.Component {
|
||||
selectedItemInfo: selectedItemInfo
|
||||
});
|
||||
|
||||
if (item.repo_id === this.props.repoID) {
|
||||
if (this.props.repoID && item.repo_id === this.props.repoID) {
|
||||
seafileAPI.getRepoInfo(this.props.repoID).then(res => {
|
||||
// need to optimized
|
||||
let repoInfo = new RepoInfo(res.data);
|
||||
|
@@ -36,7 +36,11 @@ class TreeViewItem extends React.Component {
|
||||
|
||||
onItemClick = (e) => {
|
||||
e.stopPropagation(); // need prevent event popup
|
||||
let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
|
||||
let isCurrentRepo = false;
|
||||
if (this.props.selectedRepo) {
|
||||
isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
|
||||
}
|
||||
|
||||
if (isCurrentRepo) {
|
||||
if (this.props.selectedPath !== this.state.filePath) {
|
||||
this.props.onDirentItemClick(this.state.filePath, this.props.node.object);
|
||||
@@ -77,7 +81,10 @@ class TreeViewItem extends React.Component {
|
||||
|
||||
render() {
|
||||
let { node } = this.props;
|
||||
let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
|
||||
let isCurrentRepo = false;
|
||||
if (this.props.selectedRepo) {
|
||||
isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
|
||||
}
|
||||
let isCurrentPath = this.props.selectedPath === this.state.filePath;
|
||||
|
||||
const fileName = node.object.name;
|
||||
|
@@ -5,8 +5,11 @@ import { gettext, siteRoot } from '../../utils/constants';
|
||||
import '../../css/image-file-view.css';
|
||||
|
||||
const {
|
||||
repoID,
|
||||
fileName, previousImage, nextImage, rawPath
|
||||
repoID, repoEncrypted,
|
||||
fileExt, filePath, fileName,
|
||||
thumbnailSizeForOriginal,
|
||||
previousImage, nextImage, rawPath,
|
||||
xmindImageSrc // for xmind file
|
||||
} = window.app.pageOptions;
|
||||
|
||||
let previousImageUrl, nextImageUrl;
|
||||
@@ -19,6 +22,13 @@ if (nextImage) {
|
||||
|
||||
class FileContent extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
loadFailed: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (previousImage && e.keyCode == 37) { // press '<-'
|
||||
@@ -30,7 +40,28 @@ class FileContent extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
handleLoadFailure = () => {
|
||||
this.setState({
|
||||
loadFailed: true
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.loadFailed) {
|
||||
return this.props.tip;
|
||||
}
|
||||
|
||||
// request thumbnails for some files
|
||||
// only for 'file view'. not for 'history/trash file view'
|
||||
let thumbnailURL = '';
|
||||
const fileExtList = ['tif', 'tiff', 'psd'];
|
||||
if (this.props.canUseThumbnail && !repoEncrypted && fileExtList.includes(fileExt)) {
|
||||
thumbnailURL = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${Utils.encodePath(filePath)}`;
|
||||
}
|
||||
|
||||
// for xmind file
|
||||
const xmindSrc = xmindImageSrc ? `${siteRoot}${xmindImageSrc}` : '';
|
||||
|
||||
return (
|
||||
<div className="file-view-content flex-1 image-file-view">
|
||||
{previousImage && (
|
||||
@@ -39,7 +70,7 @@ class FileContent extends React.Component {
|
||||
{nextImage && (
|
||||
<a href={nextImageUrl} id="img-next" title={gettext('you can also press →')}><span className="fas fa-chevron-right"></span></a>
|
||||
)}
|
||||
<img src={rawPath} alt={fileName} id="image-view" />
|
||||
<img src={xmindSrc || thumbnailURL || rawPath} alt={fileName} id="image-view" onError={this.handleLoadFailure} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import React, { Component, Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import MediaQuery from 'react-responsive';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { gettext, siteRoot } from '../../utils/constants';
|
||||
import { gettext, siteRoot, username } from '../../utils/constants';
|
||||
import SearchResultItem from './search-result-item';
|
||||
import editorUtilities from '../../utils/editor-utilties';
|
||||
import More from '../more';
|
||||
@@ -276,7 +276,7 @@ class Search extends Component {
|
||||
onChange={this.onChangeHandler}
|
||||
autoComplete="off"
|
||||
/>
|
||||
{this.state.isCloseShow &&
|
||||
{(this.state.isCloseShow && username) &&
|
||||
<i className='search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow'
|
||||
onClick={this.onSearchPage}></i>
|
||||
}
|
||||
@@ -288,7 +288,7 @@ class Search extends Component {
|
||||
</div>
|
||||
</div>
|
||||
</MediaQuery>
|
||||
<MediaQuery query="(max-width: 768px)">
|
||||
<MediaQuery query="(max-width: 767.8px)">
|
||||
<div className="search-icon-container">
|
||||
<i className="search-icon fas fa-search" onClick={this.onSearchToggle}></i>
|
||||
</div>
|
||||
@@ -309,7 +309,7 @@ class Search extends Component {
|
||||
onChange={this.onChangeHandler}
|
||||
autoComplete="off"
|
||||
/>
|
||||
{this.state.isCloseShow &&
|
||||
{(this.state.isCloseShow && username) &&
|
||||
<i className='search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow'
|
||||
onClick={this.onSearchPage}></i>
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class InvitationsToolbar extends React.Component {
|
||||
</Button>
|
||||
</div>
|
||||
</MediaQuery>
|
||||
<MediaQuery query="(max-width: 768px)">
|
||||
<MediaQuery query="(max-width: 767.8px)">
|
||||
<span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('Invite People')}></span>
|
||||
</MediaQuery>
|
||||
</div>
|
||||
|
@@ -61,7 +61,7 @@ class RepoViewToolbar extends React.Component {
|
||||
)}
|
||||
</div>
|
||||
</MediaQuery>
|
||||
<MediaQuery query="(max-width: 768px)">
|
||||
<MediaQuery query="(max-width: 767.8px)">
|
||||
<span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('New Library')} onClick={this.onCreateToggle}></span>
|
||||
</MediaQuery>
|
||||
</div>
|
||||
|
@@ -85,6 +85,11 @@ class ViewFileToolbar extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onHistoryClick = () => {
|
||||
let historyUrl = siteRoot + 'repo/file_revisions/' + this.props.repoID + '/?p=' + Utils.encodePath(this.props.path);
|
||||
location.href = historyUrl;
|
||||
}
|
||||
|
||||
render() {
|
||||
let { filePermission } = this.props;
|
||||
let name = Utils.getFileName(this.props.path);
|
||||
@@ -114,6 +119,7 @@ class ViewFileToolbar extends React.Component {
|
||||
}
|
||||
<DropdownItem onClick={this.onEditFileTagToggle}>{gettext('Tags')}</DropdownItem>
|
||||
<DropdownItem onClick={this.onListRelatedFileToggle}>{gettext('Related Files')}</DropdownItem>
|
||||
<DropdownItem onClick={this.onHistoryClick}>{gettext('History')}</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
)}
|
||||
|
@@ -43,7 +43,7 @@ class WikiListView extends Component {
|
||||
<th width="4%"></th>
|
||||
<th width="36%">{gettext('Name')}</th>
|
||||
</MediaQuery>
|
||||
<MediaQuery query="(max-width: 768px)">
|
||||
<MediaQuery query="(max-width: 767.8px)">
|
||||
<th width="10%"></th>
|
||||
<th width="30%">{gettext('Name')}</th>
|
||||
</MediaQuery>
|
||||
|
Reference in New Issue
Block a user