]> source.dussan.org Git - sonarqube.git/commitdiff
GOV-290 Allow removing past analysis of Portfolios
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 19 Oct 2017 13:25:03 +0000 (15:25 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 20 Oct 2017 12:52:01 +0000 (14:52 +0200)
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index efc78dbe000aa7ff58316d7f6ee18cb3e3168934..2b740b2004b12a81e993a61ac41112d28e627cbc 100644 (file)
@@ -40,6 +40,7 @@ type Props = {
   analyses: Array<Analysis>,
   analysesLoading: boolean,
   canAdmin: boolean,
+  canDeleteAnalyses: boolean,
   className?: string,
   changeEvent: (event: string, name: string) => Promise<*>,
   deleteAnalysis: (analysis: string) => Promise<*>,
@@ -206,6 +207,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
                             addVersion={this.props.addVersion}
                             analysis={analysis}
                             canAdmin={this.props.canAdmin}
+                            canDeleteAnalyses={this.props.canDeleteAnalyses}
                             canCreateVersion={this.props.project.qualifier === 'TRK'}
                             changeEvent={this.props.changeEvent}
                             deleteAnalysis={this.props.deleteAnalysis}
index b9ed0422bb7a86e798641caed71f756f20dae185..88bf5483c11e589a197285e2a01d28ee1b8aaf61 100644 (file)
@@ -34,6 +34,7 @@ type Props = {
   addVersion: (analysis: string, version: string) => Promise<*>,
   analysis: Analysis,
   canAdmin: boolean,
+  canDeleteAnalyses: boolean,
   canCreateVersion: boolean,
   changeEvent: (event: string, name: string) => Promise<*>,
   deleteAnalysis: (analysis: string) => Promise<*>,
@@ -56,6 +57,11 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
     const { date, events } = analysis;
     const analysisTitle = translate('project_activity.analysis');
     const hasVersion = events.find(event => event.category === 'VERSION') != null;
+
+    const canAddVersion = canAdmin && !hasVersion && this.props.canCreateVersion;
+    const canAddEvent = canAdmin;
+    const canDeleteAnalyses = this.props.canDeleteAnalyses && !isFirst;
+
     return (
       <li
         className={classNames('project-activity-analysis clearfix', {
@@ -70,7 +76,7 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
         </div>
         <div className="project-activity-analysis-icon big-spacer-right" title={analysisTitle} />
 
-        {canAdmin && (
+        {(canAddVersion || canAddEvent || canDeleteAnalyses) && (
           <div className="project-activity-analysis-actions spacer-left">
             <div className="dropdown display-inline-block">
               <button
@@ -80,8 +86,7 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
                 <SettingsIcon size={12} style={{ marginTop: 3 }} /> <i className="icon-dropdown" />
               </button>
               <ul className="dropdown-menu dropdown-menu-right">
-                {!hasVersion &&
-                this.props.canCreateVersion && (
+                {canAddVersion && (
                   <li>
                     <AddEventForm
                       addEvent={this.props.addVersion}
@@ -90,15 +95,18 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
                     />
                   </li>
                 )}
-                <li>
-                  <AddEventForm
-                    addEvent={this.props.addCustomEvent}
-                    analysis={analysis}
-                    addEventButtonText="project_activity.add_custom_event"
-                  />
-                </li>
-                {!isFirst && <li role="separator" className="divider" />}
-                {!isFirst && (
+                {canAddEvent && (
+                  <li>
+                    <AddEventForm
+                      addEvent={this.props.addCustomEvent}
+                      analysis={analysis}
+                      addEventButtonText="project_activity.add_custom_event"
+                    />
+                  </li>
+                )}
+                {(canAddVersion || canAddEvent) &&
+                canDeleteAnalyses && <li role="separator" className="divider" />}
+                {canDeleteAnalyses && (
                   <li>
                     <RemoveAnalysisForm
                       analysis={analysis}
@@ -115,6 +123,7 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
           <Events
             analysis={analysis.key}
             canAdmin={canAdmin}
+            canDeleteAnalyses={this.props.canDeleteAnalyses}
             changeEvent={this.props.changeEvent}
             deleteEvent={this.props.deleteEvent}
             events={events}
index cceffeabb0f8d0c65a7c0b8b7c30a0615a5bc501..592c3bbf7c59914c6a128ac6d2dad7c1d987da39 100644 (file)
@@ -58,6 +58,7 @@ export default function ProjectActivityApp(props /*: Props */) {
   const canAdmin =
     (props.project.qualifier === 'TRK' || props.project.qualifier === 'APP') &&
     (configuration ? configuration.showHistory : false);
+  const canDeleteAnalyses = configuration ? configuration.showHistory : false;
   return (
     <div id="project-activity" className="page page-limited">
       <Helmet title={translate('project_activity.page')} />
@@ -78,6 +79,7 @@ export default function ProjectActivityApp(props /*: Props */) {
             analysesLoading={props.analysesLoading}
             analyses={analyses}
             canAdmin={canAdmin}
+            canDeleteAnalyses={canDeleteAnalyses}
             className="boxed-group-inner"
             changeEvent={props.changeEvent}
             deleteAnalysis={props.deleteAnalysis}
index 64f9f8018aca928043af4696b83b6e62d4b111da..0e51a64862b2f9655bf3a34993e2da5725982698 100644 (file)
@@ -66,6 +66,7 @@ exports[`should render correctly 1`] = `
         }
         analysesLoading={false}
         canAdmin={false}
+        canDeleteAnalyses={false}
         changeEvent={[Function]}
         className="boxed-group-inner"
         deleteAnalysis={[Function]}
index 6d02a1caaf8ec3e3b42fa32281c4da0682888f22..b9cd14ffae543abc17229cf44b6f7d834c9702d3 100644 (file)
@@ -936,7 +936,7 @@ project_activity.remove_custom_event=Delete Event
 project_activity.remove_custom_event.question=Are you sure you want to delete this event?
 project_activity.reset_dates=Reset dates
 project_activity.delete_analysis=Delete Analysis
-project_activity.delete_analysis.question=Are you sure you want to delete this analysis from the project history?
+project_activity.delete_analysis.question=Are you sure you want to delete this analysis from the history?
 project_activity.filter_events=Filter events
 
 project_activity.graphs.issues=Issues