]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9953 Apply feedbacks on system upgrades
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 23 Oct 2017 12:54:22 +0000 (14:54 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 25 Oct 2017 12:28:47 +0000 (14:28 +0200)
server/sonar-web/src/main/js/apps/system/components/SystemUpgradeNotif.tsx [deleted file]
server/sonar-web/src/main/js/apps/system/components/system-upgrade/SystemUpgradeForm.tsx
server/sonar-web/src/main/js/apps/system/components/system-upgrade/SystemUpgradeIntermediate.tsx
server/sonar-web/src/main/js/apps/system/components/system-upgrade/SystemUpgradeItem.tsx
server/sonar-web/src/main/js/apps/system/components/system-upgrade/__tests__/SystemUpgradeItem-test.tsx
server/sonar-web/src/main/js/apps/system/components/system-upgrade/__tests__/__snapshots__/SystemUpgradeForm-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

diff --git a/server/sonar-web/src/main/js/apps/system/components/SystemUpgradeNotif.tsx b/server/sonar-web/src/main/js/apps/system/components/SystemUpgradeNotif.tsx
deleted file mode 100644 (file)
index cdb15d7..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-import * as React from 'react';
-import { getSystemUpgrades, SystemUpgrade } from '../../../api/system';
-import { translate } from '../../../helpers/l10n';
-
-interface State {
-  systemUpgrades?: SystemUpgrade[];
-}
-
-export default class SystemUpgradeNotif extends React.PureComponent<{}, State> {
-  mounted: boolean;
-  state: State = {};
-
-  componentDidMount() {
-    this.mounted = true;
-    this.fetchSystemUpgrades();
-  }
-
-  componentWillUnmount() {
-    this.mounted = false;
-  }
-
-  fetchSystemUpgrades = () =>
-    getSystemUpgrades().then(
-      ({ upgrades }) => {
-        if (this.mounted) {
-          this.setState({ systemUpgrades: upgrades });
-        }
-      },
-      () => {}
-    );
-
-  handleLearnMore = () => {};
-
-  render() {
-    const { systemUpgrades } = this.state;
-
-    if (!systemUpgrades || systemUpgrades.length <= 0) {
-      return null;
-    }
-
-    return (
-      <div className="page-notifs">
-        <div className="alert alert-info">
-          {translate('system.new_version_available')}
-          <button className="spacer-left" onClick={this.handleLearnMore}>
-            {translate('learn_more')}
-          </button>
-        </div>
-      </div>
-    );
-  }
-}
index 9370ea4493ba5e70b10364f8e1a004b8fcc86c2c..0c508a86706ced364a8516887168ae65bbe67029 100644 (file)
@@ -35,16 +35,6 @@ interface State {
 export default class SystemUpgradeForm extends React.PureComponent<Props, State> {
   state: State = { upgrading: false };
 
-  getBadge = (idx: number) => {
-    if (this.props.systemUpgrades.length <= 1) {
-      return undefined;
-    }
-    if (idx === 0) {
-      return translate('system.latest_version');
-    }
-    return translate('system.latest_lts_version');
-  };
-
   handleCancelClick = (event: React.SyntheticEvent<HTMLElement>) => {
     event.preventDefault();
     event.stopPropagation();
@@ -69,7 +59,9 @@ export default class SystemUpgradeForm extends React.PureComponent<Props, State>
           {systemUpgrades.map((upgrades, idx) => (
             <SystemUpgradeItem
               key={upgrades[upgrades.length - 1].version}
-              badge={this.getBadge(idx)}
+              type={
+                idx === 0 ? translate('system.latest_version') : translate('system.lts_version')
+              }
               systemUpgrades={upgrades}
             />
           ))}
index d428dc2310b2237e8ccad2e6b7071706496e29ee..ccafec8a1aa6fae8a0346d583d7cc5e462726329 100644 (file)
@@ -74,6 +74,11 @@ export default class SystemUpgradeIntermediate extends React.PureComponent<Props
                   <p>
                     <b className="little-spacer-right">SonarQube {upgrade.version}</b>
                     {formattedDate}
+                    {upgrade.changeLogUrl && (
+                      <a className="spacer-left" href={upgrade.changeLogUrl} target="_blank">
+                        {translate('system.release_notes')}
+                      </a>
+                    )}
                   </p>
                 )}
               </DateFormatter>
index 980cae8d2e18041c0ee2826d904acfc3d82bf998..83d45e9ea63593373faa7521a9b4d68e2c89e1fd 100644 (file)
@@ -25,15 +25,19 @@ import { SystemUpgrade } from '../../../../api/system';
 import { translate, translateWithParameters } from '../../../../helpers/l10n';
 
 interface Props {
-  badge?: string;
+  type?: string;
   systemUpgrades: SystemUpgrade[];
 }
 
-export default function SystemUpgradeItem({ badge, systemUpgrades }: Props) {
+export default function SystemUpgradeItem({ type, systemUpgrades }: Props) {
   const lastUpgrade = systemUpgrades[0];
   return (
     <div className="system-upgrade-version">
-      {badge && <span className="spacer-bottom badge badge-secondary">{badge}</span>}
+      {type && (
+        <h1 className="spacer-bottom">
+          <strong>{type}</strong>
+        </h1>
+      )}
       <p>
         <FormattedMessage
           defaultMessage={translate('system.version_is_availble')}
@@ -48,9 +52,11 @@ export default function SystemUpgradeItem({ badge, systemUpgrades }: Props) {
             <span>{translateWithParameters('system.released_x', formattedDate)}</span>
           )}
         </DateFormatter>
-        <a className="spacer-left" href={lastUpgrade.changeLogUrl} target="_blank">
-          {translate('system.release_notes')}
-        </a>
+        {lastUpgrade.changeLogUrl && (
+          <a className="spacer-left" href={lastUpgrade.changeLogUrl} target="_blank">
+            {translate('system.release_notes')}
+          </a>
+        )}
       </div>
       <SystemUpgradeIntermediate className="spacer-top" upgrades={systemUpgrades.slice(1)} />
       <div className="big-spacer-top">
index f23842f8689af247112a56e7745bc4f7385897d4..b7bd0280a44a15b07eb7f8c8372229c1126fd1f8 100644 (file)
@@ -54,6 +54,6 @@ it('should display correctly', () => {
 });
 
 it('should display a badge', () => {
-  const wrapper = shallow(<SystemUpgradeItem badge="test badge" systemUpgrades={UPGRADES} />);
-  expect(wrapper.find('.badge').exists()).toBeTruthy();
+  const wrapper = shallow(<SystemUpgradeItem type="LTS Version" systemUpgrades={UPGRADES} />);
+  expect(wrapper.find('h1').exists()).toBeTruthy();
 });
index 3bfbebace5af4b3e5d23265c2451eca7754b3917..0f84689c1043080ee4f985b1e41b68d7261cb840 100644 (file)
@@ -25,7 +25,6 @@ exports[`should display correctly 1`] = `
     className="modal-body"
   >
     <SystemUpgradeItem
-      badge="system.latest_version"
       systemUpgrades={
         Array [
           Object {
@@ -46,9 +45,9 @@ exports[`should display correctly 1`] = `
           },
         ]
       }
+      type="system.latest_version"
     />
     <SystemUpgradeItem
-      badge="system.latest_lts_version"
       systemUpgrades={
         Array [
           Object {
@@ -77,6 +76,7 @@ exports[`should display correctly 1`] = `
           },
         ]
       }
+      type="system.lts_version"
     />
   </div>
   <div
index 7af87b0afb83e62d9f006075ca73ef8a82628ce8..30f40064b7801fcded300a3a7b7de6e5526e3366 100644 (file)
@@ -2192,7 +2192,7 @@ system.hide_intermediate_versions=Hide intermediate versions
 system.how_to_upgrade=How to upgrade?
 system.is_restarting=Server is restarting. This page will be automatically refreshed.
 system.latest_version=Latest Version
-system.latest_lts_version=Latest LTS Version
+system.lts_version=LTS Version
 system.log_level.warning=This level has performance impacts, please make sure to get back to INFO level once your investigation is done. Please note that when the server is restarted, logging will revert to the level configured in sonar.properties.
 system.log_level.warning.short=Current logs level has performance impacts, get back to INFO level.
 system.log_level.info=Changes don't apply to Search.