* 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, FlagMessage, QualityGateIndicator } from 'design-system';
+import { Badge, 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 { SqUpgradeActivityEventMessage } from '../../../components/activity-graph/SqUpgradeActivityEventMessage';
import { translate } from '../../../helpers/l10n';
import { AnalysisEvent, ProjectAnalysisEventCategory } from '../../../types/project-activity';
}
if (event.category === ProjectAnalysisEventCategory.SqUpgrade) {
- return (
- <FlagMessage className="sw-my-1" id={event.key} variant="info">
- <FormattedMessage
- id="event.sqUpgrade"
- values={{
- sqVersion: event.name,
- }}
- />
- </FlagMessage>
- );
+ return <SqUpgradeActivityEventMessage event={event} />;
}
const eventCategory = translate('event.category', event.category);
const sortedEvents = sortBy(
events,
- // versions last
- (event) => (event.category === ProjectAnalysisEventCategory.Version ? 1 : 0),
- // then the rest sorted by category
+ (event) => {
+ switch (event.category) {
+ case ProjectAnalysisEventCategory.SqUpgrade:
+ // SQ Upgrade first
+ return 0;
+ case ProjectAnalysisEventCategory.Version:
+ // versions last
+ return 2;
+ default:
+ // then the rest in between, sorted by category
+ return 1;
+ }
+ },
'category',
);
onChange={(data: LabelValueSelectOption<string>) => handleCategoryChange(data)}
options={options}
placeholder={translate('project_activity.filter_events')}
- size="small"
+ size="full"
value={options.find((o) => o.value === category)}
classNames={{
menu: () => 'sw-z-dropdown-menu-page',
key: `analysis-4`,
events: [mockAnalysisEvent({ key: '3', category: ProjectAnalysisEventCategory.Version })],
}),
+ mockAnalysis({
+ key: `analysis-5`,
+ events: [mockAnalysisEvent({ key: '4', category: ProjectAnalysisEventCategory.SqUpgrade })],
+ }),
+ mockAnalysis({
+ key: `analysis-6`,
+ events: [mockAnalysisEvent({ key: '5', category: ProjectAnalysisEventCategory.Version })],
+ }),
+ mockAnalysis({
+ key: `analysis-7`,
+ events: [mockAnalysisEvent({ key: '6', category: ProjectAnalysisEventCategory.SqUpgrade })],
+ }),
]);
const { ui } = getPageObject();
await ui.appLoaded();
await ui.filterByCategory(ProjectAnalysisEventCategory.Version);
- expect(ui.activityItem.getAll().length).toBe(2);
+ expect(ui.activityItem.getAll().length).toBe(3);
await ui.filterByCategory(ProjectAnalysisEventCategory.QualityGate);
expect(ui.activityItem.getAll().length).toBe(1);
+
+ await ui.filterByCategory(ProjectAnalysisEventCategory.SqUpgrade);
+ expect(ui.activityItem.getAll().length).toBe(2);
});
it('should correctly filter by date range', async () => {
import { ComponentContext } from '../../app/components/componentContext/ComponentContext';
import { translate } from '../../helpers/l10n';
import { useBranchesQuery } from '../../queries/branch';
-import { AnalysisEvent } from '../../types/project-activity';
+import { AnalysisEvent, ProjectAnalysisEventCategory } from '../../types/project-activity';
import Tooltip from '../controls/Tooltip';
import { DefinitionChangeEventInner, isDefinitionChangeEvent } from './DefinitionChangeEventInner';
import { RichQualityGateEventInner, isRichQualityGateEvent } from './RichQualityGateEventInner';
+import { SqUpgradeActivityEventMessage } from './SqUpgradeActivityEventMessage';
export interface EventInnerProps {
event: AnalysisEvent;
return <RichQualityGateEventInner event={event} readonly={readonly} />;
} else if (isDefinitionChangeEvent(event)) {
return <DefinitionChangeEventInner branchLike={branchLike} event={event} readonly={readonly} />;
+ } else if (event.category === ProjectAnalysisEventCategory.SqUpgrade) {
+ return <SqUpgradeActivityEventMessage event={event} />;
}
const tooltipContent =
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { FlagMessage } from 'design-system';
+import React from 'react';
+import { FormattedMessage } from 'react-intl';
+import { AnalysisEvent } from '../../types/project-activity';
+
+interface SqUpgradeActivityEventMessageProps {
+ event: AnalysisEvent;
+}
+
+export function SqUpgradeActivityEventMessage({
+ event,
+}: Readonly<SqUpgradeActivityEventMessageProps>) {
+ return (
+ <FlagMessage className="sw-my-1" id={event.key} variant="info">
+ <FormattedMessage
+ id="event.sqUpgrade"
+ values={{
+ sqVersion: event.name,
+ }}
+ />
+ </FlagMessage>
+ );
+}
stillFailingTxt: byText('event.quality_gate.still_x'),
versionLabel: byText('event.category.VERSION', { exact: false }),
+
+ sqUpgradeLabel: (sqVersion: string) => byText(`event.sqUpgrade${sqVersion}`),
};
const handler = new BranchesServiceMock();
});
});
+describe('SQ_UPGRADE events', () => {
+ it('should render correctly', () => {
+ renderEventInner({
+ event: mockAnalysisEvent({
+ category: ProjectAnalysisEventCategory.SqUpgrade,
+ name: '10.0',
+ }),
+ });
+
+ expect(ui.sqUpgradeLabel('10.0').get()).toBeInTheDocument();
+ });
+});
+
function renderEventInner(props: Partial<EventInnerProps> = {}, params?: string) {
return renderAppWithComponentContext(
'/',
event.category.VERSION=Version
event.category.QUALITY_GATE=Quality Gate
event.category.QUALITY_PROFILE=Quality Profile
+event.category.SQ_UPGRADE=SonarQube upgrade
event.category.DEFINITION_CHANGE=Definition Change
event.category.ISSUE_DETECTION=Issue Detection
event.category.OTHER=Other