]> source.dussan.org Git - sonarqube.git/commitdiff
Check the edition status only while an operation is in progress
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 20 Oct 2017 06:43:33 +0000 (08:43 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 23 Oct 2017 15:01:13 +0000 (08:01 -0700)
server/sonar-web/src/main/js/api/marketplace.ts
server/sonar-web/src/main/js/apps/marketplace/App.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionsStatusNotif-test.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionsStatusNotif-test.tsx.snap

index d067f7b3e22848642463e08dc2b528f51896b9aa..8bb8a462a42845ec29a3c69f73898f962326f7d1 100644 (file)
@@ -42,7 +42,6 @@ export interface EditionStatus {
     | 'AUTOMATIC_IN_PROGRESS'
     | 'MANUAL_IN_PROGRESS'
     | 'AUTOMATIC_READY'
-    | 'AUTOMATIC_FAILURE'
     | 'UNINSTALL_IN_PROGRESS';
 }
 
index 0c008e09b7c60a640d10dab408217720974c03a7..969c1c7135c1e49e873b1eb53f2282d9fe6eb917 100644 (file)
@@ -63,6 +63,7 @@ interface State {
 
 export default class App extends React.PureComponent<Props, State> {
   mounted: boolean;
+  timer?: NodeJS.Timer;
 
   static contextTypes = {
     router: PropTypes.object.isRequired
@@ -159,7 +160,6 @@ export default class App extends React.PureComponent<Props, State> {
       editionStatus => {
         if (this.mounted) {
           this.updateEditionStatus(editionStatus);
-          setTimeout(this.fetchEditionStatus, 5000);
         }
       },
       () => {}
@@ -184,8 +184,19 @@ export default class App extends React.PureComponent<Props, State> {
     );
   };
 
-  updateEditionStatus = (editionStatus: EditionStatus) =>
+  updateEditionStatus = (editionStatus: EditionStatus) => {
     this.setState({ editionStatus: editionStatus });
+    if (this.timer) {
+      global.clearTimeout(this.timer);
+      this.timer = undefined;
+    }
+    if (editionStatus.installationStatus === 'AUTOMATIC_IN_PROGRESS') {
+      this.timer = global.setTimeout(() => {
+        this.fetchEditionStatus();
+        this.timer = undefined;
+      }, 2000);
+    }
+  };
 
   updateQuery = (newQuery: Partial<Query>) => {
     const query = serializeQuery({ ...parseQuery(this.props.location.query), ...newQuery });
index 0a3ca4c9acdb05839e324be44c6f3cd1af298b23..d86c8ac266c7d35bfe36ef348bfbcc926cf760b8 100644 (file)
@@ -42,16 +42,6 @@ it('should display an in progress notif', () => {
   expect(wrapper).toMatchSnapshot();
 });
 
-it('should display an error notification', () => {
-  const wrapper = shallow(
-    <EditionsStatusNotif
-      editionStatus={{ installationStatus: 'AUTOMATIC_FAILURE' }}
-      updateEditionStatus={jest.fn()}
-    />
-  );
-  expect(wrapper).toMatchSnapshot();
-});
-
 it('should display a ready notification', () => {
   const wrapper = shallow(
     <EditionsStatusNotif
index 70b4ce43ef0482d6717318dddd49197f0e4e1c5f..e52e16c6fa7c49bf773670d0a8c15c8556b892ef 100644 (file)
@@ -18,8 +18,6 @@ exports[`should display a ready notification 1`] = `
 </div>
 `;
 
-exports[`should display an error notification 1`] = `<div />`;
-
 exports[`should display an in progress notif 1`] = `
 <div>
   <div