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

add more button

This commit is contained in:
王健辉
2019-04-24 11:55:48 +08:00
parent 972f3cf91d
commit 11c8aef036
2 changed files with 27 additions and 19 deletions

View File

@@ -11,7 +11,7 @@
.old-history-main { .old-history-main {
padding-top: 16px; padding-top: 16px;
margin-left: 8.333333%; margin: 0 8.333333%;
display: inline !important; display: inline !important;
overflow: auto; overflow: auto;
position: relative; position: relative;
@@ -31,6 +31,18 @@
text-decoration: none; text-decoration: none;
} }
.old-history-main .get-more-btn {
width: 100%;
padding: .5em 0;
background: #efefef;
border: 0;
color: #777;
border-radius: 2px;
}
.old-history-main .get-more-btn:hover {
color: #444;
}
.old-history-main p { .old-history-main p {
color: #808080; color: #808080;
font-size: 12px; font-size: 12px;

View File

@@ -1,5 +1,6 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { Button } from 'reactstrap';
import { Utils } from './utils/utils'; import { Utils } from './utils/utils';
import { seafileAPI } from './utils/seafile-api'; import { seafileAPI } from './utils/seafile-api';
import { siteRoot, gettext, PER_PAGE, filePath, fileName, historyRepoID, useNewAPI } from './utils/constants'; import { siteRoot, gettext, PER_PAGE, filePath, fileName, historyRepoID, useNewAPI } from './utils/constants';
@@ -87,9 +88,6 @@ class FileHistory extends React.Component {
isError: false, isError: false,
fileOwner: result.data[0].creator_email, fileOwner: result.data[0].creator_email,
}); });
if (this.state.historyList.length < 25 && this.state.hasMore) {
this.reloadMore();
}
} }
} else { } else {
this.setState({ this.setState({
@@ -98,21 +96,22 @@ class FileHistory extends React.Component {
}); });
if (this.state.nextCommit) { if (this.state.nextCommit) {
seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, this.state.nextCommit).then((res) => { seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, this.state.nextCommit).then((res) => {
this.setState({isReloadingData: false}); this.initResultState(res.data);
this.updateResultState(res.data);
}); });
} }
} }
} }
onScrollHandler = (event) => { onScrollHandler = (event) => {
const clientHeight = event.target.clientHeight; if (useNewAPI) {
const scrollHeight = event.target.scrollHeight; const clientHeight = event.target.clientHeight;
const scrollTop = event.target.scrollTop; const scrollHeight = event.target.scrollHeight;
const isBottom = (clientHeight + scrollTop + 1 >= scrollHeight); const scrollTop = event.target.scrollTop;
let hasMore = this.state.hasMore; const isBottom = (clientHeight + scrollTop + 1 >= scrollHeight);
if (isBottom && hasMore) { let hasMore = this.state.hasMore;
this.reloadMore(); if (isBottom && hasMore) {
this.reloadMore();
}
} }
} }
@@ -135,13 +134,13 @@ class FileHistory extends React.Component {
this.setState({isReloadingData: true}); this.setState({isReloadingData: true});
if (oldFilePath) { if (oldFilePath) {
seafileAPI.listOldFileHistoryRecords(historyRepoID, oldFilePath, commitID).then((res) => { seafileAPI.listOldFileHistoryRecords(historyRepoID, oldFilePath, commitID).then((res) => {
this.setState({isReloadingData: false});
this.updateResultState(res.data); this.updateResultState(res.data);
this.setState({isReloadingData: false});
}); });
} else { } else {
seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, commitID).then((res) => { seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, commitID).then((res) => {
this.setState({isReloadingData: false});
this.updateResultState(res.data); this.updateResultState(res.data);
this.setState({isReloadingData: false});
}); });
} }
} }
@@ -170,9 +169,6 @@ class FileHistory extends React.Component {
isError: false, isError: false,
fileOwner: result.data[0].creator_email, fileOwner: result.data[0].creator_email,
}); });
if (this.state.historyList.length < 25 && this.state.hasMore) {
this.reloadMore();
}
} }
} else { } else {
this.setState({ this.setState({
@@ -181,7 +177,6 @@ class FileHistory extends React.Component {
}); });
if (this.state.nextCommit) { if (this.state.nextCommit) {
seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, this.state.nextCommit).then((res) => { seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, this.state.nextCommit).then((res) => {
this.setState({isReloadingData: false});
this.updateResultState(res.data); this.updateResultState(res.data);
}); });
} }
@@ -272,6 +267,7 @@ class FileHistory extends React.Component {
</table> </table>
} }
{this.state.isReloadingData && <Loading />} {this.state.isReloadingData && <Loading />}
{this.state.hasMore && <Button className="get-more-btn" onClick={this.reloadMore}>{gettext('More')}</Button>}
</div> </div>
</div> </div>
</div> </div>