);
return (
- <div className="sw-body-sm">
+ <div data-analysis-key={analysis.key} className="sw-body-sm">
<div className="sw-flex sw-justify-between sw-mb-1">
<div className="sw-body-sm-highlight">
<DateTimeFormatter date={analysis.date} />
const { failingConditionsOnNewCode, failingConditionsOnOverallCode } =
countFailingConditions(qgStatuses);
- const recentSqUpgradeEvent = React.useMemo(() => {
+ const recentSqUpgrade = React.useMemo(() => {
if (!analyses || analyses.length === 0) {
return undefined;
}
hasQpUpdateEvent || event.category === ProjectAnalysisEventCategory.QualityProfile;
if (sqUpgradeEvent !== undefined && hasQpUpdateEvent) {
- return sqUpgradeEvent;
+ return { analysis, event: sqUpgradeEvent };
}
}
}
}, [analyses]);
const scrollToLatestSqUpgradeEvent = () => {
- document.querySelector(`#${recentSqUpgradeEvent?.key}`)?.scrollIntoView({
- behavior: 'smooth',
- block: 'center',
- inline: 'center',
- });
+ if (recentSqUpgrade) {
+ document
+ .querySelector(`[data-analysis-key="${recentSqUpgrade.analysis.key}"]`)
+ ?.scrollIntoView({
+ behavior: 'smooth',
+ block: 'center',
+ inline: 'center',
+ });
+ }
};
const tabs = [
</div>
) : (
<>
- {recentSqUpgradeEvent && (
+ {recentSqUpgrade && (
<div>
<FlagMessage className="sw-mb-4" variant="info">
<FormattedMessage
<FormattedMessage id="overview.quality_profiles_update_after_sq_upgrade.link" />
</ButtonLink>
),
- sqVersion: recentSqUpgradeEvent.name,
+ sqVersion: recentSqUpgrade.event.name,
}}
/>
</FlagMessage>