]> source.dussan.org Git - sonarqube.git/commitdiff
show more profile changelog
authorStas Vilchik <vilchiks@gmail.com>
Mon, 18 Jul 2016 15:28:05 +0000 (17:28 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 18 Jul 2016 15:28:05 +0000 (17:28 +0200)
server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js
server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js

index 247b3a6f4020e89dda4173c19f2eb8f686e7bce2..2c0bdd1c8826766fdb562fe5525537730991cbaf 100644 (file)
@@ -23,6 +23,7 @@ import ChangelogSearch from './ChangelogSearch';
 import ChangelogEmpty from './ChangelogEmpty';
 import { getProfileChangelog } from '../../../api/quality-profiles';
 import { ProfileType } from '../propTypes';
+import { translate } from '../../../helpers/l10n';
 
 export default class ChangelogContainer extends React.Component {
   static propTypes = {
@@ -82,6 +83,35 @@ export default class ChangelogContainer extends React.Component {
     });
   }
 
+  loadMore (e) {
+    e.preventDefault();
+    e.target.blur();
+
+    this.setState({ loading: true });
+    const { query } = this.props.location;
+    const data = {
+      profileKey: this.props.profile.key,
+      p: this.state.page + 1
+    };
+    if (query.since) {
+      data.since = query.since;
+    }
+    if (query.to) {
+      data.to = query.to;
+    }
+
+    getProfileChangelog(data).then(r => {
+      if (this.mounted) {
+        this.setState({
+          events: [...this.state.events, ...r.events],
+          total: r.total,
+          page: r.p,
+          loading: false
+        });
+      }
+    });
+  }
+
   handleFromDateChange (fromDate) {
     const query = { ...this.props.location.query, since: fromDate };
     this.context.router.push({ pathname: '/changelog', query });
@@ -100,6 +130,9 @@ export default class ChangelogContainer extends React.Component {
   render () {
     const { query } = this.props.location;
 
+    const shouldDisplayFooter = this.state.events != null &&
+        this.state.events.length < this.state.total;
+
     return (
         <div className="quality-profile-box js-profile-changelog">
           <header className="spacer-bottom">
@@ -122,6 +155,14 @@ export default class ChangelogContainer extends React.Component {
           {this.state.events != null && this.state.events.length > 0 && (
               <Changelog events={this.state.events}/>
           )}
+
+          {shouldDisplayFooter && (
+              <footer className="text-center spacer-top small">
+                <a href="#" onClick={this.loadMore.bind(this)}>
+                  {translate('show_more')}
+                </a>
+              </footer>
+          )}
         </div>
     );
   }
index 82e685af4704c0bc09fc06c44871420e95f1d13e..d3ea5ecedb044332a61e4c5f7bd42ec2bb92f4f0 100644 (file)
@@ -31,7 +31,7 @@ export default class ParameterChange extends React.Component {
 
     if (value == null) {
       return (
-          <div>
+          <div style={{ whiteSpace: 'normal '}}>
             {translateWithParameters(
                 'quality_profiles.changelog.parameter_reset_to_default_value',
                 name
@@ -41,7 +41,7 @@ export default class ParameterChange extends React.Component {
     }
 
     return (
-        <div>
+        <div style={{ whiteSpace: 'normal '}}>
           {translateWithParameters(
               'quality_profiles.parameter_set_to',
               name,