From 94fc10c569dbd25394b4fef84c74cd1a35776817 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 19 Oct 2017 15:25:03 +0200 Subject: [PATCH] GOV-290 Allow removing past analysis of Portfolios --- .../components/ProjectActivityAnalysesList.js | 2 ++ .../components/ProjectActivityAnalysis.js | 33 ++++++++++++------- .../components/ProjectActivityApp.js | 2 ++ .../ProjectActivityApp-test.js.snap | 1 + .../resources/org/sonar/l10n/core.properties | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js index efc78dbe000..2b740b2004b 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js @@ -40,6 +40,7 @@ type Props = { analyses: Array, 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} diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js index b9ed0422bb7..88bf5483c11 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js @@ -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 (
  • - {canAdmin && ( + {(canAddVersion || canAddEvent || canDeleteAnalyses) && (
      - {!hasVersion && - this.props.canCreateVersion && ( + {canAddVersion && (
    • )} -
    • - -
    • - {!isFirst &&
    • } - {!isFirst && ( + {canAddEvent && ( +
    • + +
    • + )} + {(canAddVersion || canAddEvent) && + canDeleteAnalyses &&
    • } + {canDeleteAnalyses && (
    • @@ -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} diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap index 64f9f8018ac..0e51a64862b 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap @@ -66,6 +66,7 @@ exports[`should render correctly 1`] = ` } analysesLoading={false} canAdmin={false} + canDeleteAnalyses={false} changeEvent={[Function]} className="boxed-group-inner" deleteAnalysis={[Function]} diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 6d02a1caaf8..b9cd14ffae5 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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 -- 2.39.5