1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Bug repair (#2458)

This commit is contained in:
山水人家
2018-10-25 14:42:53 +08:00
committed by Daniel Pan
parent f3e0284751
commit 209237a22a
12 changed files with 80 additions and 91 deletions

View File

@@ -53,7 +53,7 @@ class CopyDirent extends React.Component {
} }
if ( filePath && filePath.length > direntPath.length && filePath.indexOf(direntPath) > -1) { if ( filePath && filePath.length > direntPath.length && filePath.indexOf(direntPath) > -1) {
message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s') message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s');
message = message.replace('%(src)s', direntPath); message = message.replace('%(src)s', direntPath);
message = message.replace('%(des)s', filePath); message = message.replace('%(des)s', filePath);
this.setState({errMessage: message}); this.setState({errMessage: message});
@@ -88,7 +88,7 @@ class CopyDirent extends React.Component {
} }
render() { render() {
let title = gettext("Copy {placeholder} to:"); let title = gettext('Copy {placeholder} to:');
title = title.replace('{placeholder}', '<span class="sf-font">' + Utils.HTMLescape(this.props.dirent.name) + '</span>'); title = title.replace('{placeholder}', '<span class="sf-font">' + Utils.HTMLescape(this.props.dirent.name) + '</span>');
return ( return (
<Modal isOpen={true} toggle={this.toggle}> <Modal isOpen={true} toggle={this.toggle}>

View File

@@ -53,7 +53,7 @@ class MoveDirent extends React.Component {
} }
if ( filePath && filePath.length > direntPath.length && filePath.indexOf(direntPath) > -1) { if ( filePath && filePath.length > direntPath.length && filePath.indexOf(direntPath) > -1) {
message = gettext('Can not move directory %(src)s to its subdirectory %(des)s') message = gettext('Can not move directory %(src)s to its subdirectory %(des)s');
message = message.replace('%(src)s', direntPath); message = message.replace('%(src)s', direntPath);
message = message.replace('%(des)s', filePath); message = message.replace('%(des)s', filePath);
this.setState({errMessage: message}); this.setState({errMessage: message});
@@ -87,7 +87,7 @@ class MoveDirent extends React.Component {
} }
render() { render() {
let title = gettext("Move {placeholder} to:"); let title = gettext('Move {placeholder} to:');
title = title.replace('{placeholder}', '<span class="sf-font">' + Utils.HTMLescape(this.props.dirent.name) + '</span>'); title = title.replace('{placeholder}', '<span class="sf-font">' + Utils.HTMLescape(this.props.dirent.name) + '</span>');
return ( return (
<Modal isOpen={true} toggle={this.toggle}> <Modal isOpen={true} toggle={this.toggle}>

View File

@@ -79,8 +79,12 @@ class DraftListItem extends React.Component {
return ( return (
<tr className={this.state.highlight} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}> <tr className={this.state.highlight} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
<td className="icon"><img src={siteRoot + 'media/img/file/192/txt.png'} alt='icon' /></td> <td className="icon"><img src={siteRoot + 'media/img/file/192/txt.png'} alt='icon' /></td>
<td className="name a-simulate" onClick={this.onDraftEditClick}>{fileName}</td> <td className="name a-simulate" >
<td className="library a-simulate" onClick={this.onLibraryClick}>{draft.repo_name}</td> <span onClick={this.onDraftEditClick}>{fileName}</span>
</td>
<td className="library a-simulate">
<span onClick={this.onLibraryClick}>{draft.repo_name}</span>
</td>
<td className="review"> <td className="review">
{ draft.review_id && draft.review_status === 'open' ? <span className="a-simulate" onClick={this.onReviewClick}>#{draft.review_id}</span> : <span>--</span> } { draft.review_id && draft.review_status === 'open' ? <span className="a-simulate" onClick={this.onReviewClick}>#{draft.review_id}</span> : <span>--</span> }
</td> </td>

View File

@@ -1,10 +0,0 @@
.activity-table a {
color: #333;
}
.activity-op {
color: #707070;
background: #f0f0f0;
padding: 4px;
border-radius: 4px;
}

View File

@@ -72,6 +72,7 @@
flex-direction: column; flex-direction: column;
flex: 1 1 auto; flex: 1 1 auto;
overflow: hidden; overflow: hidden;
min-height: 0;
} }
.cur-view-path { .cur-view-path {
@@ -94,9 +95,10 @@
} }
.cur-view-content { .cur-view-content {
padding: 10px 16px 20px; padding: 0;
height: calc(100% - 40px); height: calc(100% - 40px);
flex: 1; flex: 1;
min-height: 0;
overflow: auto; overflow: auto;
} }

View File

@@ -57,19 +57,8 @@ img[src=""] {
min-height: 0; min-height: 0;
} }
.cur-view-container {
min-height: 0;
}
.cur-view-content {
display: flex;
padding: 0;
min-height: 0;
}
.cur-view-content .markdown-container{ .cur-view-content .markdown-container{
padding-left: 40px; padding: 10px 40px 20px;
padding-right: 40px;
display: flex; display: flex;
flex: 1; flex: 1;
overflow: auto; overflow: auto;

View File

@@ -17,8 +17,8 @@ class FileActivitiesContent extends Component {
return <p className="error text-center">{error_msg}</p>; return <p className="error text-center">{error_msg}</p>;
} else { } else {
return ( return (
<React.Fragment> <div className="activity-table-container">
<table className="table table-hover table-vcenter activity-table"> <table className="table table-hover table-vcenter">
<thead> <thead>
<tr> <tr>
<th width="8%">{/* avatar */}</th> <th width="8%">{/* avatar */}</th>
@@ -32,7 +32,7 @@ class FileActivitiesContent extends Component {
</table> </table>
{has_more ? <span className="loading-icon loading-tip"></span> : ''} {has_more ? <span className="loading-icon loading-tip"></span> : ''}
{error_msg ? <p className="error text-center">{error_msg}</p> : ''} {error_msg ? <p className="error text-center">{error_msg}</p> : ''}
</React.Fragment> </div>
); );
} }
} }

View File

@@ -103,7 +103,7 @@ class DraftContent extends React.Component {
render() { render() {
return ( return (
<div className="cur-view-content" style={{padding: 0}}> <div className="cur-view-content">
{this.state.isLoadingDraft && <Loading /> } {this.state.isLoadingDraft && <Loading /> }
{(!this.state.isLoadingDraft && this.state.draftList.length !==0) && {(!this.state.isLoadingDraft && this.state.draftList.length !==0) &&
<DraftListView <DraftListView

View File

@@ -31,7 +31,7 @@ class ReviewContent extends React.Component {
render() { render() {
return ( return (
<div className="cur-view-content" style={{padding: 0}}> <div className="cur-view-content">
{this.state.isLoadingReviews && <Loading /> } {this.state.isLoadingReviews && <Loading /> }
{(!this.state.isLoadingReviews && this.state.reviewsList.length !==0) && {(!this.state.isLoadingReviews && this.state.reviewsList.length !==0) &&
<ReviewListView <ReviewListView

View File

@@ -17,9 +17,9 @@ class Content extends Component {
<thead> <thead>
<tr> <tr>
<th width="5%"></th> <th width="5%"></th>
<th width="40%">{gettext("File Name")}</th> <th width="40%">{gettext('File Name')}</th>
<th width="32%">{gettext("Library")}</th> <th width="32%">{gettext('Library')}</th>
<th width="18%">{gettext("Last Update")}</th> <th width="18%">{gettext('Last Update')}</th>
<th width="5%"></th> <th width="5%"></th>
</tr> </tr>
</thead> </thead>
@@ -28,7 +28,7 @@ class Content extends Component {
<thead> <thead>
<tr> <tr>
<th width="5%"></th> <th width="5%"></th>
<th width="90%">{gettext("File Name")}</th> <th width="90%">{gettext('File Name')}</th>
<th width="5%"></th> <th width="5%"></th>
</tr> </tr>
</thead> </thead>
@@ -71,14 +71,11 @@ class TableBody extends Component {
const _this = this; const _this = this;
let getThumbnail = function(i) { let getThumbnail = function(i) {
const curItem = items[i]; const curItem = items[i];
seafileAPI.createThumbnail(curItem.repo_id, curItem.path, thumbnailSize). seafileAPI.createThumbnail(curItem.repo_id, curItem.path, thumbnailSize).then((res) => {
then((res) => { curItem.encoded_thumbnail_src = res.data.encoded_thumbnail_src;
curItem.encoded_thumbnail_src = res.data.encoded_thumbnail_src; }).catch((error) => {
})
.catch((error) => {
// do nothing // do nothing
}) }).then(() => {
.then(() => {
if (i < len - 1) { if (i < len - 1) {
getThumbnail(++i); getThumbnail(++i);
} else { } else {
@@ -144,14 +141,12 @@ class Item extends Component {
e.preventDefault(); e.preventDefault();
const data = this.props.data; const data = this.props.data;
seafileAPI.unStarFile(data.repo_id, data.path) seafileAPI.unStarFile(data.repo_id, data.path).then((res) => {
.then((res) => { this.setState({
this.setState({ unstarred: true
unstarred: true });
}); // TODO: show feedback msg
// TODO: show feedback msg }).catch((error) => {
})
.catch((error) => {
// TODO: show feedback msg // TODO: show feedback msg
}); });
} }
@@ -170,23 +165,23 @@ class Item extends Component {
const desktopItem = ( const desktopItem = (
<tr onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}> <tr onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
<td className="alc"> <td className="alc">
{ {
data.thumbnail_url ? data.thumbnail_url ?
<img className="thumbnail" src={data.thumbnail_url} alt="" /> : <img className="thumbnail" src={data.thumbnail_url} alt="" /> :
<img src={data.file_icon_url} alt={gettext("icon")} width="24" /> <img src={data.file_icon_url} alt={gettext('icon')} width="24" />
} }
</td> </td>
<td> <td>
{ {
data.is_img ? data.is_img ?
<a className="img-name-link normal" href={data.file_view_url} target="_blank" data-mfp-src={data.file_raw_url}>{data.file_name}</a> : <a className="img-name-link normal" href={data.file_view_url} target="_blank" data-mfp-src={data.file_raw_url}>{data.file_name}</a> :
<a className="normal" href={data.file_view_url} target="_blank">{data.file_name}</a> <a className="normal" href={data.file_view_url} target="_blank">{data.file_name}</a>
} }
</td> </td>
<td>{data.repo_name}</td> <td>{data.repo_name}</td>
<td dangerouslySetInnerHTML={{__html:data.mtime_relative}}></td> <td dangerouslySetInnerHTML={{__html:data.mtime_relative}}></td>
<td> <td>
<a href="#" className={opClasses} title={gettext("Unstar")} aria-label={gettext("Unstar")} onClick={this.handleClick}></a> <a href="#" className={opClasses} title={gettext('Unstar')} aria-label={gettext('Unstar')} onClick={this.handleClick}></a>
</td> </td>
</tr> </tr>
); );
@@ -194,24 +189,24 @@ class Item extends Component {
const mobileItem = ( const mobileItem = (
<tr> <tr>
<td className="alc"> <td className="alc">
{ {
data.thumbnail_url ? data.thumbnail_url ?
<img className="thumbnail" src={data.thumbnail_url} alt="" /> : <img className="thumbnail" src={data.thumbnail_url} alt="" /> :
<img src={data.file_icon_url} alt={gettext("icon")} width="24" /> <img src={data.file_icon_url} alt={gettext('icon')} width="24" />
} }
</td> </td>
<td> <td>
{ {
data.is_img ? data.is_img ?
<a className="img-name-link normal" href={data.file_view_url} target="_blank" data-mfp-src={data.file_raw_url}>{data.file_name}</a> : <a className="img-name-link normal" href={data.file_view_url} target="_blank" data-mfp-src={data.file_raw_url}>{data.file_name}</a> :
<a className="normal" href={data.file_view_url} target="_blank">{data.file_name}</a> <a className="normal" href={data.file_view_url} target="_blank">{data.file_name}</a>
} }
<br /> <br />
<span className="dirent-meta-info">{data.repo_name}</span> <span className="dirent-meta-info">{data.repo_name}</span>
<span className="dirent-meta-info" dangerouslySetInnerHTML={{__html:data.mtime_relative}}></span> <span className="dirent-meta-info" dangerouslySetInnerHTML={{__html:data.mtime_relative}}></span>
</td> </td>
<td> <td>
<a href="#" className="sf2-icon-delete unstar op-icon" title={gettext("Unstar")} aria-label={gettext("Unstar")} onClick={this.handleClick}></a> <a href="#" className="sf2-icon-delete unstar op-icon" title={gettext('Unstar')} aria-label={gettext('Unstar')} onClick={this.handleClick}></a>
</td> </td>
</tr> </tr>
); );
@@ -235,33 +230,31 @@ class Starred extends Component {
} }
componentDidMount() { componentDidMount() {
seafileAPI.listStarred() seafileAPI.listStarred().then((res) => {
.then((res) => { //res: {data: Array(2), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
// res: {data: Array(2), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
this.setState({ this.setState({
loading: false, loading: false,
items: res.data items: res.data
}); });
}) }).catch((error) => {
.catch((error) => {
if (error.response) { if (error.response) {
if (error.response.status == 403) { if (error.response.status == 403) {
this.setState({ this.setState({
loading: false, loading: false,
errorMsg: gettext("Permission denied") errorMsg: gettext('Permission denied')
}); });
location.href = `${loginUrl}?next=${encodeURIComponent(location.href)}`; location.href = `${loginUrl}?next=${encodeURIComponent(location.href)}`;
} else { } else {
this.setState({ this.setState({
loading: false, loading: false,
errorMsg: gettext("Error") errorMsg: gettext('Error')
}); });
} }
} else { } else {
this.setState({ this.setState({
loading: false, loading: false,
errorMsg: gettext("Please check the network.") errorMsg: gettext('Please check the network.')
}); });
} }
}); });
@@ -271,10 +264,12 @@ class Starred extends Component {
return ( return (
<div className="cur-view-container" id="starred"> <div className="cur-view-container" id="starred">
<div className="cur-view-path"> <div className="cur-view-path">
<h3 className="sf-heading">{gettext("Favorites")}</h3> <h3 className="sf-heading">{gettext('Favorites')}</h3>
</div> </div>
<div className="cur-view-content"> <div className="cur-view-content">
<Content data={this.state} /> <div className="table-container">
<Content data={this.state} />
</div>
</div> </div>
</div> </div>
); );

View File

@@ -158,8 +158,8 @@ export const Utils = {
HTMLescape: function(html) { HTMLescape: function(html) {
return document.createElement('div') return document.createElement('div')
.appendChild(document.createTextNode(html)) .appendChild(document.createTextNode(html))
.parentNode .parentNode
.innerHTML; .innerHTML;
}, },
}; };

View File

@@ -972,3 +972,12 @@ a.op-icon:focus {
text-decoration:none; text-decoration:none;
border-bottom-color:#eb8205; border-bottom-color:#eb8205;
} }
/* begin activity page */
.activity-table-container {
flex: 1;
padding: 10px 16px 20px;
overflow: auto;
}
/* end activity page */