]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16435 Clarify date - time on Project Overview
authorGuillaume Peoc'h <guillaume.peoch@sonarsource.com>
Wed, 1 Jun 2022 16:25:00 +0000 (18:25 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 2 Jun 2022 20:03:19 +0000 (20:03 +0000)
server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/HeaderMeta-test.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/HeaderMeta-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 3e78bec5863b64aedab89d9bcae172369b1c7640..27fc83ce27146c418b257ec1e2cc1b28653ae4ee 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
+import { useIntl } from 'react-intl';
 import BranchStatus from '../../../../components/common/BranchStatus';
 import HomePageSelect from '../../../../components/controls/HomePageSelect';
 import DetachIcon from '../../../../components/icons/DetachIcon';
-import DateTimeFormatter from '../../../../components/intl/DateTimeFormatter';
+import { formatterOption } from '../../../../components/intl/DateTimeFormatter';
 import { isBranch, isPullRequest } from '../../../../helpers/branch-like';
-import { translate } from '../../../../helpers/l10n';
+import { translate, translateWithParameters } from '../../../../helpers/l10n';
 import { BranchLike } from '../../../../types/branch-like';
 import { ComponentQualifier } from '../../../../types/component';
 import { TaskWarning } from '../../../../types/tasks';
@@ -48,6 +49,7 @@ export function HeaderMeta(props: HeaderMetaProps) {
 
   const currentPage = getCurrentPage(component, branchLike);
   const displayVersion = component.version !== undefined && isABranch;
+  const lastAnalysisDate = useIntl().formatDate(component.analysisDate, formatterOption);
 
   return (
     <>
@@ -63,8 +65,13 @@ export function HeaderMeta(props: HeaderMetaProps) {
           </span>
         )}
         {component.analysisDate && (
-          <span className="spacer-left nowrap note">
-            <DateTimeFormatter date={component.analysisDate} />
+          <span
+            title={translateWithParameters(
+              'overview.project.last_analysis.date_time',
+              lastAnalysisDate
+            )}
+            className="spacer-left nowrap note">
+            {lastAnalysisDate}
           </span>
         )}
         {displayVersion && (
index a8ca42031b715a7ba41505a1f7a5683b15bf4e18..36cd81491a233ed503004aa273455d0a09ab9321 100644 (file)
@@ -27,6 +27,12 @@ import { mockCurrentUser } from '../../../../../helpers/testMocks';
 import { ComponentQualifier } from '../../../../../types/component';
 import { getCurrentPage, HeaderMeta, HeaderMetaProps } from '../HeaderMeta';
 
+jest.mock('react-intl', () => ({
+  useIntl: jest.fn().mockImplementation(() => ({
+    formatDate: jest.fn().mockImplementation(() => '2017-01-02T00:00:00.000Z')
+  }))
+}));
+
 it('should render correctly for a branch', () => {
   const wrapper = shallowRender();
   expect(wrapper).toMatchSnapshot();
index 8069b500e197dea5e6dc92a6839fe53f0712fa29..677f9989be4f32f33ac641ba69cfaa844b0953a5 100644 (file)
@@ -30,10 +30,9 @@ exports[`should render correctly for a branch 1`] = `
     </span>
     <span
       className="spacer-left nowrap note"
+      title="overview.project.last_analysis.date_time.2017-01-02T00:00:00.000Z"
     >
-      <DateTimeFormatter
-        date="2017-01-02T00:00:00.000Z"
-      />
+      2017-01-02T00:00:00.000Z
     </span>
     <span
       className="spacer-left nowrap note"
@@ -84,10 +83,9 @@ exports[`should render correctly for a main project branch 1`] = `
     </span>
     <span
       className="spacer-left nowrap note"
+      title="overview.project.last_analysis.date_time.2017-01-02T00:00:00.000Z"
     >
-      <DateTimeFormatter
-        date="2017-01-02T00:00:00.000Z"
-      />
+      2017-01-02T00:00:00.000Z
     </span>
     <span
       className="spacer-left nowrap note"
@@ -179,10 +177,9 @@ exports[`should render correctly for a pull request 1`] = `
     </span>
     <span
       className="spacer-left nowrap note"
+      title="overview.project.last_analysis.date_time.2017-01-02T00:00:00.000Z"
     >
-      <DateTimeFormatter
-        date="2017-01-02T00:00:00.000Z"
-      />
+      2017-01-02T00:00:00.000Z
     </span>
   </div>
   <div
index 993f74bfb8d8a6cbd889d3cccbdd080f688db5a5..806319439f447136cd2420b98787d58046c85b96 100644 (file)
@@ -3114,6 +3114,7 @@ overview.project.branch_X_empty=The "{0}" branch of this project is empty.
 overview.project.main_branch_no_lines_of_code=The main branch has no lines of code.
 overview.project.main_branch_empty=The main branch of this project is empty.
 overview.project.branch_needs_new_analysis=The branch data is incomplete. Run a new analysis to update it.
+overview.project.last_analysis.date_time=Last analysis started on {0}
 overview.project.next_steps.set_up_pr_deco_and_ci.admin=To benefit from more of SonarQube's features, {link_ci} and set up DevOps platform integration in your {link_project_settings}.
 overview.project.next_steps.set_up_pr_deco_and_ci=To benefit from more of SonarQube's features, {link_ci} and ask a project administrator to set up DevOps platform integration.
 overview.project.next_steps.set_up_pr_deco.admin=To benefit from more of SonarQube's features, set up DevOps platform integration in your {link_project_settings}.