aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-04-17 08:26:05 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-18 20:20:53 +0200
commita22bc323f8d43fb243031ead669c5ff876f75c0a (patch)
treed9d833a2b51a3e1c02c6533690e9d3df236a4773 /server/sonar-web/src
parent482fd5ee07e4d8aadef57dbac9d76450d08b6aff (diff)
downloadsonarqube-a22bc323f8d43fb243031ead669c5ff876f75c0a.tar.gz
sonarqube-a22bc323f8d43fb243031ead669c5ff876f75c0a.zip
SONAR-10573 Allow to navigate on more than 100 rules with keyboard
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx23
1 files changed, 17 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx
index 3dfece11301..d8ba80576a0 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx
@@ -56,6 +56,7 @@ import { scrollToElement } from '../../../helpers/scrolling';
import '../styles.css';
const PAGE_SIZE = 100;
+const LIMIT_BEFORE_LOAD_MORE = 5;
interface Props {
location: { pathname: string; query: RawQuery };
@@ -287,13 +288,23 @@ export default class App extends React.PureComponent<Props, State> {
};
selectNextRule = () => {
- const { rules } = this.state;
+ const { rules, loading, paging } = this.state;
const selectedIndex = this.getSelectedIndex();
- if (rules && selectedIndex !== undefined && selectedIndex < rules.length - 1) {
- if (this.state.openRule) {
- this.openRule(rules[selectedIndex + 1].key);
- } else {
- this.setState({ selected: rules[selectedIndex + 1].key });
+ if (selectedIndex !== undefined) {
+ if (
+ selectedIndex > rules.length - LIMIT_BEFORE_LOAD_MORE &&
+ !loading &&
+ paging &&
+ rules.length < paging.total
+ ) {
+ this.fetchMoreRules();
+ }
+ if (rules && selectedIndex < rules.length - 1) {
+ if (this.state.openRule) {
+ this.openRule(rules[selectedIndex + 1].key);
+ } else {
+ this.setState({ selected: rules[selectedIndex + 1].key });
+ }
}
}
};