1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 06:34:40 +00:00

Merge pull request #2639 from haiwen/refresh-bug

repair refresh bug and rename bug
This commit is contained in:
Daniel Pan
2018-12-13 13:02:28 +08:00
committed by GitHub
5 changed files with 15 additions and 13 deletions

View File

@@ -64,9 +64,6 @@ class App extends Component {
let href = window.location.href.split('/');
this.getDrafts();
this.setState({currentTab: href[href.length - 2]});
if (this.currentTab) {
this.setState({currentTab: this.currentTab});
}
}
getDrafts = () => {

View File

@@ -44,6 +44,8 @@ class DirView extends React.Component {
}
componentDidMount() {
// eg: http://127.0.0.1:8000/library/repo_id/repo_name/**/**/\
let location = decodeURIComponent(window.location.href);
let repoID = this.props.repoID;
seafileAPI.getRepoInfo(repoID).then(res => {
let repo = new Repo(res.data);
@@ -53,8 +55,11 @@ class DirView extends React.Component {
permission: repo.permission === 'rw',
currentRepo: repo,
});
this.updateDirentList(this.state.path);
let repoName = repo.repo_name;
let index = location.indexOf(repoName);
let path = location.slice(index + repoName.length);
this.updateDirentList(path);
this.setState({path: path});
});
}
@@ -81,7 +86,7 @@ class DirView extends React.Component {
this.updateDirentList(direntPath);
this.setState({path: direntPath});
let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + direntPath;
let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + Utils.encodePath(direntPath);
window.history.pushState({url: fileUrl, path: direntPath}, direntPath, fileUrl);
} else {
const w=window.open('about:blank');
@@ -301,7 +306,7 @@ class DirView extends React.Component {
this.updateDirentList(path);
this.setState({path: path});
let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + path;
let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + Utils.encodePath(path);
window.history.pushState({url: fileUrl, path: path}, path, fileUrl);
}

View File

@@ -376,7 +376,7 @@ class DirentListItem extends React.Component {
render() {
let { path, dirent } = this.props;
let direntPath = Utils.joinPath(path, dirent.name);
let href = siteRoot + 'wiki/lib/' + this.props.repoID + direntPath;
let href = siteRoot + 'wiki/lib/' + this.props.repoID + Utils.encodePath(direntPath);
return (
<Fragment>
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>

View File

@@ -91,7 +91,7 @@ class SharedRepoListItem extends React.Component {
});
//todo change to library; div-view is not compatibility
let libPath = `${siteRoot}library/${this.props.repo.repo_id}/`;
let libPath = `${siteRoot}library/${repo.repo_id}/${Utils.encodePath(repo.repo_name)}/`;
return { iconUrl, iconTitle, libPath };
}
@@ -285,7 +285,7 @@ class SharedRepoListItem extends React.Component {
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
<td><img src={iconUrl} title={iconTitle} alt={iconTitle}/></td>
<td>
<a href={libPath}>{repo.repo_name}</a><br />
<Link to={libPath}>{repo.repo_name}</Link><br />
<span className="item-meta-info" title={repo.owner_contact_email}>{repo.owner_name}</span>
<span className="item-meta-info">{repo.size}</span>
<span className="item-meta-info" title={moment(repo.last_modified).format('llll')}>{moment(repo.last_modified).fromNow()}</span>

View File

@@ -168,7 +168,7 @@ class Item extends Component {
'is_admin': data.is_admin,
'permission': permission
});
data.url = `${siteRoot}library/${data.repo_id}/`;
data.url = `${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}`;
let iconVisibility = this.state.showOpIcon ? '' : ' invisible';
let shareIconClassName = 'sf2-icon-share sf2-x op-icon' + iconVisibility;
@@ -243,7 +243,7 @@ class Item extends Component {
/>
)}
{!this.state.showChangeLibName && data.repo_name && (
<Link to={`${siteRoot}library/${data.repo_id}/${data.repo_name}/`}>{data.repo_name}</Link>
<Link to={data.url}>{data.repo_name}</Link>
)}
{!this.state.showChangeLibName && !data.repo_name &&
(gettext('Broken (please contact your administrator to fix this library)'))
@@ -261,7 +261,7 @@ class Item extends Component {
<td><img src={data.icon_url} title={data.icon_title} alt={data.icon_title} width="24" /></td>
<td>
{data.repo_name ?
<Link to={`${siteRoot}library/${data.repo_id}/${data.repo_name}/`}>{data.repo_name}</Link> :
<Link to={data.url}>{data.repo_name}</Link> :
gettext('Broken (please contact your administrator to fix this library)')}
<br />
<span className="item-meta-info">{Utils.formatSize({bytes: data.size})}</span>