]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15139 - Add scheduled email reports subscription
authorBelen Pruvost <belen.pruvost@sonarsource.com>
Wed, 11 Aug 2021 11:07:48 +0000 (13:07 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 12 Aug 2021 20:07:59 +0000 (20:07 +0000)
server/sonar-web/src/main/js/components/controls/ComponentReportActionsRenderer.tsx
server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/ComponentReportActionsRenderer-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index b08035d53253bbce28d2ffcdcd49c569bfcdfd7c..a693b8315f7cf8a60fcb6d118da120a49de554d0 100644 (file)
@@ -25,7 +25,6 @@ import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon';
 import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
 import { getReportUrl } from '../../api/component-report';
 import { Branch } from '../../types/branch-like';
-import { isPortfolioLike } from '../../types/component';
 
 export interface ComponentReportActionsRendererProps {
   component: T.Component;
@@ -47,6 +46,7 @@ export default function ComponentReportActionsRenderer(props: ComponentReportAct
         download={[component.name, branch?.name, 'PDF Report.pdf'].filter(s => !!s).join(' - ')}
         href={getReportUrl(component.key, branch?.name)}
         target="_blank"
+        data-test="overview__download-pdf-report-button"
         rel="noopener noreferrer">
         {simple
           ? translate('download_verb')
@@ -72,13 +72,13 @@ export default function ComponentReportActionsRenderer(props: ComponentReportAct
     const frequencyTranslation = translate('report.frequency', frequency).toLowerCase();
 
     return (
-      <a href="#" onClick={onClickHandler}>
+      <a href="#" onClick={onClickHandler} data-test="overview__subscribe-to-report-button">
         {translateWithParameters(translationKey, frequencyTranslation)}
       </a>
     );
   };
 
-  return canSubscribe && isPortfolioLike(component.qualifier) ? (
+  return canSubscribe ? (
     <Dropdown
       overlay={
         <ul className="menu">
index df37dbbcc683e1a55140b56c58ae6fca0b38227b..e80e9bbf4e095e11506b416165f96a8c395d87c0 100644 (file)
@@ -8,6 +8,7 @@ exports[`should render correctly: can subscribe, not subscribed 1`] = `
     >
       <li>
         <a
+          data-test="overview__download-pdf-report-button"
           download="MyProject - PDF Report.pdf"
           href="/api/governance_reports/download?componentKey=my-project"
           rel="noopener noreferrer"
@@ -18,6 +19,7 @@ exports[`should render correctly: can subscribe, not subscribed 1`] = `
       </li>
       <li>
         <a
+          data-test="overview__subscribe-to-report-button"
           href="#"
           onClick={[MockFunction]}
         >
@@ -46,6 +48,7 @@ exports[`should render correctly: can subscribe, subscribed 1`] = `
     >
       <li>
         <a
+          data-test="overview__download-pdf-report-button"
           download="MyProject - PDF Report.pdf"
           href="/api/governance_reports/download?componentKey=my-project"
           rel="noopener noreferrer"
@@ -56,6 +59,7 @@ exports[`should render correctly: can subscribe, subscribed 1`] = `
       </li>
       <li>
         <a
+          data-test="overview__subscribe-to-report-button"
           href="#"
           onClick={[MockFunction]}
         >
@@ -78,6 +82,7 @@ exports[`should render correctly: can subscribe, subscribed 1`] = `
 
 exports[`should render correctly: cannot subscribe 1`] = `
 <a
+  data-test="overview__download-pdf-report-button"
   download="MyProject - PDF Report.pdf"
   href="/api/governance_reports/download?componentKey=my-project"
   rel="noopener noreferrer"
@@ -95,6 +100,7 @@ exports[`should render correctly: current user without email 1`] = `
     >
       <li>
         <a
+          data-test="overview__download-pdf-report-button"
           download="MyProject - PDF Report.pdf"
           href="/api/governance_reports/download?componentKey=my-project"
           rel="noopener noreferrer"
@@ -125,12 +131,41 @@ exports[`should render correctly: current user without email 1`] = `
 `;
 
 exports[`should render correctly: not a portfolio 1`] = `
-<a
-  download="MyProject - PDF Report.pdf"
-  href="/api/governance_reports/download?componentKey=my-project"
-  rel="noopener noreferrer"
-  target="_blank"
+<Dropdown
+  overlay={
+    <ul
+      className="menu"
+    >
+      <li>
+        <a
+          data-test="overview__download-pdf-report-button"
+          download="MyProject - PDF Report.pdf"
+          href="/api/governance_reports/download?componentKey=my-project"
+          rel="noopener noreferrer"
+          target="_blank"
+        >
+          download_verb
+        </a>
+      </li>
+      <li>
+        <a
+          data-test="overview__subscribe-to-report-button"
+          href="#"
+          onClick={[MockFunction]}
+        >
+          component_report.subscribe_x.report.frequency.weekly
+        </a>
+      </li>
+    </ul>
+  }
 >
-  component_report.download.qualifier.trk
-</a>
+  <Button
+    className="dropdown-toggle"
+  >
+    component_report.report.qualifier.TRK
+    <DropdownIcon
+      className="spacer-left icon-half-transparent"
+    />
+  </Button>
+</Dropdown>
 `;
index a34df0bccc2db9a8b1db2936bd42e2f99120c064..8e79a50764e42e06fcaf67157338b88ccb27efc3 100644 (file)
@@ -2867,6 +2867,7 @@ background_task.type.APP_REFRESH=Recomputation
 background_task.type.PROJECT_EXPORT=Project Export
 background_task.type.PROJECT_IMPORT=Project Import
 background_task.type.AUDIT_PURGE=Audit Log Purge
+background_task.type.REPORT_SUBMIT=Report Email Submit
 
 background_tasks.page=Background Tasks
 background_tasks.page.description=This page allows monitoring of the queue of tasks running asynchronously on the server. It also gives access to the history of finished tasks and their status. Analysis report processing is the most common kind of background task.