@@ -22,7 +22,10 @@ import * as React from 'react'; | |||
import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { ComponentQualifier } from '../../../types/component'; | |||
import { Analysis as TypeAnalysis } from '../../../types/project-activity'; | |||
import { | |||
ProjectAnalysisEventCategory, | |||
Analysis as TypeAnalysis, | |||
} from '../../../types/project-activity'; | |||
import Event from './Event'; | |||
export interface AnalysisProps { | |||
@@ -33,9 +36,19 @@ export interface AnalysisProps { | |||
export function Analysis({ analysis, ...props }: AnalysisProps) { | |||
const sortedEvents = sortBy( | |||
analysis.events, | |||
// versions first | |||
(event) => (event.category === 'VERSION' ? 0 : 1), | |||
// then the rest sorted by category | |||
(event) => { | |||
switch (event.category) { | |||
case ProjectAnalysisEventCategory.Version: | |||
// versions first | |||
return 0; | |||
case ProjectAnalysisEventCategory.SqUpgrade: | |||
// SQ Upgrade second | |||
return 1; | |||
default: | |||
// then the rest sorted by category | |||
return 2; | |||
} | |||
}, | |||
'category', | |||
); | |||
@@ -17,24 +17,39 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { Badge, QualityGateIndicator } from 'design-system'; | |||
import { Badge, FlagMessage, QualityGateIndicator } from 'design-system'; | |||
import * as React from 'react'; | |||
import { FormattedMessage } from 'react-intl'; | |||
import { isDefinitionChangeEvent } from '../../../components/activity-graph/DefinitionChangeEventInner'; | |||
import { isRichQualityGateEvent } from '../../../components/activity-graph/RichQualityGateEventInner'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { AnalysisEvent } from '../../../types/project-activity'; | |||
import { AnalysisEvent, ProjectAnalysisEventCategory } from '../../../types/project-activity'; | |||
interface Props { | |||
event: AnalysisEvent; | |||
} | |||
export function Event({ event }: Props) { | |||
if (event.category === 'VERSION') { | |||
if (event.category === ProjectAnalysisEventCategory.Version) { | |||
return ( | |||
<Badge className="sw-px-1 sw-text-ellipsis sw-mb-1" variant="new"> | |||
{event.name} | |||
</Badge> | |||
<div> | |||
<Badge className="sw-px-1 sw-text-ellipsis sw-mb-1" variant="new"> | |||
{event.name} | |||
</Badge> | |||
</div> | |||
); | |||
} | |||
if (event.category === ProjectAnalysisEventCategory.SqUpgrade) { | |||
return ( | |||
<FlagMessage className="sw-my-1" variant="info"> | |||
<FormattedMessage | |||
id="event.sqUpgrade" | |||
values={{ | |||
sqVersion: event.name, | |||
}} | |||
/> | |||
</FlagMessage> | |||
); | |||
} | |||
@@ -41,6 +41,7 @@ it('should render correctly', async () => { | |||
expect(screen.getByRole('status', { name: 'v1.0' })).toBeInTheDocument(); | |||
expect(screen.getByText(/event.category.OTHER/)).toBeInTheDocument(); | |||
expect(screen.getByText(/event.category.DEFINITION_CHANGE/)).toBeInTheDocument(); | |||
expect(screen.getByText('event.sqUpgrade10.2')).toBeInTheDocument(); | |||
}); | |||
function renderActivityPanel(props: Partial<ActivityPanelProps> = {}) { | |||
@@ -74,6 +75,11 @@ function renderActivityPanel(props: Partial<ActivityPanelProps> = {}) { | |||
], | |||
}, | |||
}), | |||
mockAnalysisEvent({ | |||
key: '5', | |||
category: ProjectAnalysisEventCategory.SqUpgrade, | |||
name: '10.2', | |||
}), | |||
], | |||
}), | |||
mockAnalysis({ key: 'bar' }), |
@@ -69,6 +69,7 @@ export enum ProjectAnalysisEventCategory { | |||
Version = 'VERSION', | |||
QualityGate = 'QUALITY_GATE', | |||
QualityProfile = 'QUALITY_PROFILE', | |||
SqUpgrade = 'SQ_UPGRADE', | |||
Other = 'OTHER', | |||
} | |||
@@ -532,6 +532,7 @@ event.definition_change.branch_added={project} {branch} added | |||
event.definition_change.branch_removed={project} {branch} removed | |||
event.definition_change.branch_replaced={project} {oldBranch} replaced with {newBranch} | |||
event.failed_conditions=Failed Conditions: | |||
event.sqUpgrade=First analysis since upgrading to SonarQube {sqVersion} | |||
#------------------------------------------------------------------------------ | |||
# |