Tempo: Reset metrics summary tag when scope changes (#74028)

Reset tag when scope changes
This commit is contained in:
Joey 2023-08-30 11:26:09 +01:00 committed by GitHub
parent 2cf4f641f2
commit dc26cdf6c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 17 deletions

View File

@ -63,6 +63,7 @@ describe('GroupByField', () => {
const groupByFilter = query.groupBy?.find((f) => f.id === 'group-by-id');
expect(groupByFilter).not.toBeNull();
expect(groupByFilter?.scope).toBe('resource');
expect(groupByFilter?.tag).toBe('');
}
});

View File

@ -78,44 +78,45 @@ export const GroupByField = (props: Props) => {
<div key={f.id}>
<HorizontalGroup spacing={'none'} width={'auto'}>
<Select
options={scopeOptions}
value={f.scope}
onChange={(v) => {
updateFilter({ ...f, scope: v?.value });
}}
placeholder="Select scope"
aria-label={`Select scope for filter ${i + 1}`}
onChange={(v) => {
updateFilter({ ...f, scope: v?.value, tag: '' });
}}
options={scopeOptions}
placeholder="Select scope"
value={f.scope}
/>
<Select
aria-label={`Select tag for filter ${i + 1}`}
isClearable
isLoading={isTagsLoading}
key={f.tag}
onChange={(v) => {
updateFilter({ ...f, tag: v?.value });
}}
options={getTags(f)?.map((t) => ({
label: t,
value: t,
}))}
value={f.tag || ''}
onChange={(v) => {
updateFilter({ ...f, tag: v?.value });
}}
placeholder="Select tag"
aria-label={`Select tag for filter ${i + 1}`}
isLoading={isTagsLoading}
isClearable
value={f.tag || ''}
/>
<AccessoryButton
variant="secondary"
aria-label={`Remove tag for filter ${i + 1}`}
icon="times"
onClick={() => removeFilter(f)}
tooltip="Remove tag"
aria-label={`Remove tag for filter ${i + 1}`}
variant="secondary"
/>
{i === (query.groupBy?.length ?? 0) - 1 && (
<span className={styles.addFilter}>
<AccessoryButton
variant="secondary"
aria-label="Add tag"
icon="plus"
onClick={() => addFilter()}
tooltip="Add tag"
aria-label="Add tag"
variant="secondary"
/>
</span>
)}