зеркало из https://github.com/docker/kitematic.git
Added reset of pagination for new search. Fixes #1151
Signed-off-by: French Ben <me+git@frenchben.com>
This commit is contained in:
Родитель
c1b9dc5fce
Коммит
9f05ce192e
|
@ -66,16 +66,21 @@ module.exports = React.createClass({
|
||||||
_searchPromise.cancel();
|
_searchPromise.cancel();
|
||||||
_searchPromise = null;
|
_searchPromise = null;
|
||||||
}
|
}
|
||||||
|
let previousPage, nextPage, totalPage = null;
|
||||||
let previousPage = (page - 1 < 1) ? 1 : page - 1;
|
// If query remains, retain pagination
|
||||||
let nextPage = (page + 1 > this.state.totalPage) ? this.state.totalPage : page + 1;
|
if (this.state.query === query) {
|
||||||
|
previousPage = (page - 1 < 1) ? 1 : page - 1;
|
||||||
|
nextPage = (page + 1 > this.state.totalPage) ? this.state.totalPage : page + 1;
|
||||||
|
totalPage = this.state.totalPage;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
query: query,
|
query: query,
|
||||||
loading: true,
|
loading: true,
|
||||||
currentPage: page,
|
currentPage: page,
|
||||||
previousPage: previousPage,
|
previousPage: previousPage,
|
||||||
nextPage: nextPage
|
nextPage: nextPage,
|
||||||
|
totalPage: totalPage
|
||||||
});
|
});
|
||||||
|
|
||||||
_searchPromise = Promise.delay(200).cancellable().then(() => {
|
_searchPromise = Promise.delay(200).cancellable().then(() => {
|
||||||
|
@ -174,8 +179,7 @@ module.exports = React.createClass({
|
||||||
<span>{this.state.currentPage} <span className="sr-only">(current)</span></span>
|
<span>{this.state.currentPage} <span className="sr-only">(current)</span></span>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
paginateResults = (next.length || previous.length) && (this.state.query !== '') ? (
|
||||||
paginateResults = next.length || previous.length ? (
|
|
||||||
<nav>
|
<nav>
|
||||||
<ul className="pagination">
|
<ul className="pagination">
|
||||||
{previous}
|
{previous}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class RepositoryStore {
|
||||||
let nextPage = (page + 1 > this.totalPage) ? this.totalPage : page + 1;
|
let nextPage = (page + 1 > this.totalPage) ? this.totalPage : page + 1;
|
||||||
this.setState({query: query, error: null, resultsLoading: true, currentPage: page, nextPage: nextPage, previousPage: previousPage});
|
this.setState({query: query, error: null, resultsLoading: true, currentPage: page, nextPage: nextPage, previousPage: previousPage});
|
||||||
} else {
|
} else {
|
||||||
this.setState({query: query, error: null, resultsLoading: true, nextPage: null, previousPage: null, currentPage: 1});
|
this.setState({query: query, error: null, resultsLoading: true, nextPage: null, previousPage: null, currentPage: 1, totalPage: null});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче