@@ -49,7 +49,7 @@ declare namespace T { | |||
} | |||
export interface Analysis { | |||
codePeriodVersion?: string; | |||
buildString?: string; | |||
date: string; | |||
events: AnalysisEvent[]; | |||
key: string; |
@@ -117,27 +117,25 @@ export default class ProjectActivityAnalysis extends React.PureComponent<Props, | |||
}; | |||
render() { | |||
const { analysis, isFirst, canAdmin } = this.props; | |||
const { analysis, isFirst, canAdmin, canCreateVersion } = this.props; | |||
const { date, events } = analysis; | |||
const parsedDate = parseDate(date); | |||
const hasVersion = events.find(event => event.category === 'VERSION') != null; | |||
const canAddVersion = canAdmin && !hasVersion && this.props.canCreateVersion; | |||
const canAddVersion = canAdmin && !hasVersion && canCreateVersion; | |||
const canAddEvent = canAdmin; | |||
const canDeleteAnalyses = | |||
this.props.canDeleteAnalyses && !isFirst && !analysis.manualNewCodePeriodBaseline; | |||
let tooltipContent = <TimeFormatter date={parsedDate} long={true} />; | |||
// If projectVersion AND codePeriodVersion are set, add the projectVersion | |||
// to the tooltip content. | |||
if (analysis.projectVersion && analysis.codePeriodVersion) { | |||
if (analysis.buildString) { | |||
tooltipContent = ( | |||
<> | |||
{tooltipContent} | |||
<br /> | |||
{translateWithParameters( | |||
'project_activity.analysis_project_version_X', | |||
analysis.projectVersion | |||
'project_activity.analysis_build_string_X', | |||
analysis.buildString | |||
)} | |||
</> | |||
); | |||
@@ -147,7 +145,7 @@ export default class ProjectActivityAnalysis extends React.PureComponent<Props, | |||
<Tooltip mouseEnterDelay={0.5} overlay={tooltipContent} placement="left"> | |||
<li | |||
className={classNames('project-activity-analysis', { selected: this.props.selected })} | |||
data-date={date.valueOf()} | |||
data-date={parsedDate.valueOf()} | |||
onClick={this.handleClick} | |||
tabIndex={0}> | |||
<div className="project-activity-time spacer-right"> |
@@ -31,7 +31,7 @@ it('should render correctly', () => { | |||
key: '1', | |||
date: new Date('2019-01-14T15:44:51.000Z'), | |||
events: [{ key: '2', category: 'VERSION', name: '1.0' }], | |||
codePeriodVersion: '1.0', | |||
projectVersion: '1.0', | |||
manualNewCodePeriodBaseline: false | |||
}} | |||
onClose={jest.fn()} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { InjectedRouter } from 'react-router'; | |||
import { Location } from 'history'; | |||
import { ParsedAnalysis } from '../apps/projectActivity/utils'; | |||
import { Profile } from '../apps/quality-profiles/types'; | |||
export function mockAlmApplication(overrides: Partial<T.AlmApplication> = {}): T.AlmApplication { | |||
@@ -47,6 +48,42 @@ export function mockAlmOrganization(overrides: Partial<T.AlmOrganization> = {}): | |||
}; | |||
} | |||
export function mockParsedAnalysis(overrides: Partial<ParsedAnalysis> = {}): ParsedAnalysis { | |||
return { | |||
date: new Date('2017-03-01T09:36:01+0100'), | |||
events: [], | |||
key: 'foo', | |||
projectVersion: '1.0', | |||
...overrides | |||
}; | |||
} | |||
export function mockAnalysisEvent(overrides: Partial<T.AnalysisEvent> = {}): T.AnalysisEvent { | |||
return { | |||
category: 'QUALITY_GATE', | |||
key: 'E11', | |||
description: 'Lorem ipsum dolor sit amet', | |||
name: 'Lorem ipsum', | |||
qualityGate: { | |||
status: 'ERROR', | |||
stillFailing: true, | |||
failing: [ | |||
{ | |||
key: 'foo', | |||
name: 'Foo', | |||
branch: 'master' | |||
}, | |||
{ | |||
key: 'bar', | |||
name: 'Bar', | |||
branch: 'feature/bar' | |||
} | |||
] | |||
}, | |||
...overrides | |||
}; | |||
} | |||
export function mockAppState(overrides: Partial<T.AppState> = {}): T.AppState { | |||
return { | |||
defaultOrganization: 'foo', |
@@ -1050,7 +1050,7 @@ custom_measures.metric=Metric | |||
#------------------------------------------------------------------------------ | |||
project_activity.analysis=Analysis | |||
project_activity.analysis_project_version_X=Project version: {0} | |||
project_activity.analysis_build_string_X=Build string: {0} | |||
project_activity.add_version=Create Version | |||
project_activity.analyzed.TRK=Project Analyzed | |||
project_activity.analyzed.APP=Application Analyzed |