AnnoList: Fix annotations not loading when in a repeated row (#111540)

This commit is contained in:
Josh Hunt
2025-09-24 10:31:19 +00:00
committed by GitHub
parent a72e02f88a
commit 46adb9a158
4 changed files with 14 additions and 12 deletions
-5
View File
@@ -4418,11 +4418,6 @@
"count": 1
}
},
"public/app/plugins/panel/annolist/AnnoListPanel.tsx": {
"@typescript-eslint/consistent-type-assertions": {
"count": 1
}
},
"public/app/plugins/panel/annolist/AnnotationListItem.tsx": {
"no-restricted-syntax": {
"count": 1
@@ -15,7 +15,7 @@ import {
const units: string[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q'] satisfies DurationUnit[];
const isDurationUnit = (value: string): value is DurationUnit => {
export const isDurationUnit = (value: string): value is DurationUnit => {
return units.includes(value);
};
@@ -105,7 +105,7 @@ describe('AnnoListPanel', () => {
tags: ['tag A', 'tag B'],
type: 'annotation',
},
'anno-list-panel-1'
expect.stringMatching(/^anno-list-panel-\d\.\d+/) // string is appended with Math.random()
);
});
});
@@ -268,7 +268,7 @@ describe('AnnoListPanel', () => {
tags: ['tag A', 'tag B', 'Result tag B'],
type: 'annotation',
},
'anno-list-panel-1'
expect.stringMatching(/^anno-list-panel-\d\.\d+/) // string is appended with Math.random()
);
expect(screen.getByText(/filter:/i)).toBeInTheDocument();
expect(screen.getAllByText(/result tag b/i)).toHaveLength(2);
@@ -293,7 +293,7 @@ describe('AnnoListPanel', () => {
type: 'annotation',
userId: 1,
},
'anno-list-panel-1'
expect.stringMatching(/^anno-list-panel-\d\.\d+/) // string is appended with Math.random()
);
expect(screen.getByText(/filter:/i)).toBeInTheDocument();
expect(screen.getByRole('button', { name: /result email/i })).toBeInTheDocument();
@@ -7,7 +7,7 @@ import {
AnnotationEvent,
AppEvents,
dateTime,
DurationUnit,
dateMath,
GrafanaTheme2,
locationUtil,
PanelProps,
@@ -35,6 +35,7 @@ interface State {
loaded: boolean;
queryUser?: UserInfo;
queryTags: string[];
requestId: string;
}
export class AnnoListPanel extends PureComponent<Props, State> {
style = getStyles(config.theme2);
@@ -49,6 +50,7 @@ export class AnnoListPanel extends PureComponent<Props, State> {
timeInfo: '',
loaded: false,
queryTags: [],
requestId: `anno-list-panel-${Math.random()}`,
};
}
@@ -126,7 +128,7 @@ export class AnnoListPanel extends PureComponent<Props, State> {
params.tags = params.tags ? [...params.tags, ...queryTags] : queryTags;
}
const annotations = await getBackendSrv().get('/api/annotations', params, `anno-list-panel-${this.props.id}`);
const annotations = await getBackendSrv().get('/api/annotations', params, this.state.requestId);
this.setState({
annotations,
@@ -180,7 +182,12 @@ export class AnnoListPanel extends PureComponent<Props, State> {
if (subtract) {
incr *= -1;
}
return t.add(incr, unit as DurationUnit).valueOf();
if (!dateMath.isDurationUnit(unit)) {
return 0;
}
return t.add(incr, unit).valueOf();
}
onTagClick = (tag: string, remove?: boolean) => {