]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15175 Warn server id is not usable when running on embedded dtabase
authorMathieu Suen <mathieu.suen@sonarsource.com>
Wed, 25 Aug 2021 09:54:11 +0000 (11:54 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 27 Aug 2021 20:03:16 +0000 (20:03 +0000)
server/sonar-docs/src/pages/instance-administration/license-manager.md
server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx
server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx
server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/App-test.tsx.snap
server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index c43e7584ed82ab9c2614378328be6f9c0eea1064..b862cc75399b5a9425c8753cf9f680f9cf22a3e8 100644 (file)
@@ -8,6 +8,9 @@ _Starting in [Developer Edition](https://redirect.sonarsource.com/editions/devel
 
 You can use the License Manager to retrieve your server ID (required for obtaining a License Key) and configure your SonarSource-provided License key.
 
+[[warning]]
+|The server ID is specific to the current database system. Make sure to configure an external database for long-term use prior to requesting your license with this server ID.
+
 ### Retrieving the server ID
 The server ID is always available on the License Manager page, as well as in the **System Info** section at **Administration > System**.
 
index 4ad50569370303d67d50087dd1bf80b9c124297c..133d94d554ec60c49203004a70443531de4981cf 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
+import { connect } from 'react-redux';
 import { ClipboardButton } from '../../../components/controls/clipboard';
+import { Alert } from '../../../components/ui/Alert';
 import { toShortNotSoISOString } from '../../../helpers/dates';
 import { translate } from '../../../helpers/l10n';
+import { getAppState, Store } from '../../../store/rootReducer';
 import PageActions from './PageActions';
 
 export interface Props {
@@ -28,13 +31,22 @@ export interface Props {
   loading: boolean;
   logLevel: string;
   onLogLevelChange: () => void;
+  productionDatabase: boolean;
   serverId?: string;
   showActions: boolean;
   version?: string;
 }
 
-export default function PageHeader(props: Props) {
-  const { isCluster, loading, logLevel, serverId, showActions, version } = props;
+export function PageHeader(props: Props) {
+  const {
+    isCluster,
+    loading,
+    logLevel,
+    serverId,
+    showActions,
+    version,
+    productionDatabase
+  } = props;
   return (
     <header className="page-header">
       <h1 className="page-title">{translate('system_info.page')}</h1>
@@ -54,38 +66,51 @@ export default function PageHeader(props: Props) {
         </div>
       )}
       {serverId && version && (
-        <div className="system-info-copy-paste-id-info boxed-group display-flex-center">
-          <div className="flex-1">
-            <table className="width-100">
-              <tbody>
-                <tr>
-                  <th>
-                    <strong>{translate('system.server_id')}</strong>
-                  </th>
-                  <td>
-                    <code>{serverId}</code>
-                  </td>
-                </tr>
-                <tr>
-                  <th>
-                    <strong>{translate('system.version')}</strong>
-                  </th>
-                  <td>{version}</td>
-                </tr>
-              </tbody>
-            </table>
-          </div>
-          <ClipboardButton
-            className="flex-0"
-            copyValue={`SonarQube ID information
+        <div className="system-info-copy-paste-id-info boxed-group ">
+          {!productionDatabase && (
+            <Alert className="width-100" variant="warning">
+              {translate('system.not_production_database_warning')}
+            </Alert>
+          )}
+          <div className="display-flex-center">
+            <div className="flex-1">
+              <table className="width-100">
+                <tbody>
+                  <tr>
+                    <th>
+                      <strong>{translate('system.server_id')}</strong>
+                    </th>
+                    <td>
+                      <code>{serverId}</code>
+                    </td>
+                  </tr>
+                  <tr>
+                    <th>
+                      <strong>{translate('system.version')}</strong>
+                    </th>
+                    <td>{version}</td>
+                  </tr>
+                </tbody>
+              </table>
+            </div>
+            <ClipboardButton
+              className="flex-0"
+              copyValue={`SonarQube ID information
 Server ID: ${serverId}
 Version: ${version}
 Date: ${toShortNotSoISOString(Date.now())}
 `}>
-            {translate('system.copy_id_info')}
-          </ClipboardButton>
+              {translate('system.copy_id_info')}
+            </ClipboardButton>
+          </div>
         </div>
       )}
     </header>
   );
 }
+
+const mapStateToProps = (store: Store) => ({
+  productionDatabase: getAppState(store).productionDatabase
+});
+
+export default connect(mapStateToProps)(PageHeader);
index 32c07327d72d49f2e82ef339a7a121b15700e7f6..34e2ed927b2efb74993e873206a117ae5107c527 100644 (file)
@@ -19,7 +19,7 @@
  */
 import { shallow } from 'enzyme';
 import * as React from 'react';
-import PageHeader, { Props } from '../PageHeader';
+import { PageHeader, Props } from '../PageHeader';
 
 jest.mock('../../../../helpers/dates', () => ({
   toShortNotSoISOString: () => '2019-01-01'
@@ -27,6 +27,9 @@ jest.mock('../../../../helpers/dates', () => ({
 
 it('should render correctly', () => {
   expect(shallowRender()).toMatchSnapshot();
+  expect(
+    shallowRender({ productionDatabase: false, serverId: 'foo-bar', version: '7.7.0.1234' })
+  ).toMatchSnapshot('on embedded database');
   expect(shallowRender({ loading: true, showActions: false })).toMatchSnapshot();
   expect(shallowRender({ serverId: 'foo-bar', version: '7.7.0.1234' })).toMatchSnapshot();
 });
@@ -38,6 +41,7 @@ function shallowRender(props: Partial<Props> = {}) {
       loading={false}
       logLevel="INFO"
       onLogLevelChange={jest.fn()}
+      productionDatabase={true}
       showActions={true}
       {...props}
     />
index 1e3f9399b541ee5f4a15db34ff6c2bfcc842bca7..c1191f63727061b043359f3cec32e9e6c1260b47 100644 (file)
@@ -13,7 +13,7 @@ exports[`should render correctly: cluster sysinfo 1`] = `
     title="system_info.page"
   />
   <SystemUpgradeNotif />
-  <PageHeader
+  <Connect(PageHeader)
     isCluster={true}
     loading={false}
     logLevel="DEBUG"
@@ -215,7 +215,7 @@ exports[`should render correctly: stand-alone sysinfo 1`] = `
     title="system_info.page"
   />
   <SystemUpgradeNotif />
-  <PageHeader
+  <Connect(PageHeader)
     isCluster={false}
     loading={false}
     logLevel="DEBUG"
index 9792203714fb075db7298185f3aa049513633fec..42c55f420c6dad530a65aea5d5fa062cc6b1f647 100644 (file)
@@ -56,50 +56,130 @@ exports[`should render correctly 3`] = `
     serverId="foo-bar"
   />
   <div
-    className="system-info-copy-paste-id-info boxed-group display-flex-center"
+    className="system-info-copy-paste-id-info boxed-group "
   >
     <div
-      className="flex-1"
+      className="display-flex-center"
     >
-      <table
-        className="width-100"
+      <div
+        className="flex-1"
       >
-        <tbody>
-          <tr>
-            <th>
-              <strong>
-                system.server_id
-              </strong>
-            </th>
-            <td>
-              <code>
-                foo-bar
-              </code>
-            </td>
-          </tr>
-          <tr>
-            <th>
-              <strong>
-                system.version
-              </strong>
-            </th>
-            <td>
-              7.7.0.1234
-            </td>
-          </tr>
-        </tbody>
-      </table>
-    </div>
-    <ClipboardButton
-      className="flex-0"
-      copyValue="SonarQube ID information
+        <table
+          className="width-100"
+        >
+          <tbody>
+            <tr>
+              <th>
+                <strong>
+                  system.server_id
+                </strong>
+              </th>
+              <td>
+                <code>
+                  foo-bar
+                </code>
+              </td>
+            </tr>
+            <tr>
+              <th>
+                <strong>
+                  system.version
+                </strong>
+              </th>
+              <td>
+                7.7.0.1234
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </div>
+      <ClipboardButton
+        className="flex-0"
+        copyValue="SonarQube ID information
 Server ID: foo-bar
 Version: 7.7.0.1234
 Date: 2019-01-01
 "
+      >
+        system.copy_id_info
+      </ClipboardButton>
+    </div>
+  </div>
+</header>
+`;
+
+exports[`should render correctly: on embedded database 1`] = `
+<header
+  className="page-header"
+>
+  <h1
+    className="page-title"
+  >
+    system_info.page
+  </h1>
+  <PageActions
+    canDownloadLogs={false}
+    canRestart={false}
+    cluster={true}
+    logLevel="INFO"
+    onLogLevelChange={[MockFunction]}
+    serverId="foo-bar"
+  />
+  <div
+    className="system-info-copy-paste-id-info boxed-group "
+  >
+    <Alert
+      className="width-100"
+      variant="warning"
     >
-      system.copy_id_info
-    </ClipboardButton>
+      system.not_production_database_warning
+    </Alert>
+    <div
+      className="display-flex-center"
+    >
+      <div
+        className="flex-1"
+      >
+        <table
+          className="width-100"
+        >
+          <tbody>
+            <tr>
+              <th>
+                <strong>
+                  system.server_id
+                </strong>
+              </th>
+              <td>
+                <code>
+                  foo-bar
+                </code>
+              </td>
+            </tr>
+            <tr>
+              <th>
+                <strong>
+                  system.version
+                </strong>
+              </th>
+              <td>
+                7.7.0.1234
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </div>
+      <ClipboardButton
+        className="flex-0"
+        copyValue="SonarQube ID information
+Server ID: foo-bar
+Version: 7.7.0.1234
+Date: 2019-01-01
+"
+      >
+        system.copy_id_info
+      </ClipboardButton>
+    </div>
   </div>
 </header>
 `;
index 90bcc63c6960b2d495a4db77b2a3b92e257b01ac..99e5a57b313667e1b5953cb5cad7ce4b545ecde8 100644 (file)
@@ -2967,6 +2967,7 @@ system.restart_server=Restart Server
 system.instance_restarting={instance} restart is in progress. Ongoing {link} are completing.
 system.search_nodes_title=Search Nodes
 system.see_sonarqube_downloads=See All SonarQube Downloads
+system.not_production_database_warning=This server ID is valid only for the embedded database, which should be considered disposable. Consider configuring an external database for long-term use prior to requesting your license.
 system.server_id=Server ID
 system.set_log_level=Set logs level
 system.show_intermediate_versions=Show intermediate versions