Skip to content

Commit aa8a219

Browse files
authored
ref(groupingInfo): Move contributing values/all values switch to section header (#97718)
1 parent 537fc7a commit aa8a219

File tree

4 files changed

+49
-52
lines changed

4 files changed

+49
-52
lines changed

static/app/components/events/groupingInfo/groupingInfo.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import {Fragment} from 'react';
1+
import {Fragment, useState} from 'react';
22
import styled from '@emotion/styled';
33

4+
import {Flex} from 'sentry/components/core/layout';
5+
import {SegmentedControl} from 'sentry/components/core/segmentedControl';
46
import {GroupInfoSummary} from 'sentry/components/events/groupingInfo/groupingSummary';
57
import {useEventGroupingInfo} from 'sentry/components/events/groupingInfo/useEventGroupingInfo';
68
import {FeatureFeedback} from 'sentry/components/featureFeedback';
79
import LoadingError from 'sentry/components/loadingError';
810
import LoadingIndicator from 'sentry/components/loadingIndicator';
911
import {t} from 'sentry/locale';
10-
import {space} from 'sentry/styles/space';
1112
import type {Event} from 'sentry/types/event';
1213
import type {Group} from 'sentry/types/group';
1314
import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
@@ -27,6 +28,8 @@ export default function GroupingInfo({
2728
showGroupingConfig,
2829
group,
2930
}: GroupingSummaryProps) {
31+
const [showNonContributing, setShowNonContributing] = useState(false);
32+
3033
const hasStreamlinedUI = useHasStreamlinedUI();
3134

3235
const {groupInfo, isPending, isError, isSuccess, hasPerformanceGrouping} =
@@ -81,12 +84,29 @@ export default function GroupingInfo({
8184
</div>
8285
)}
8386
</ConfigHeader>
87+
<ToggleContainer>
88+
<SegmentedControl
89+
aria-label={t('Filter by contribution')}
90+
size="xs"
91+
value={showNonContributing ? 'all' : 'relevant'}
92+
onChange={key => setShowNonContributing(key === 'all')}
93+
>
94+
<SegmentedControl.Item key="relevant">
95+
{t('Contributing Values')}
96+
</SegmentedControl.Item>
97+
<SegmentedControl.Item key="all">{t('All Values')}</SegmentedControl.Item>
98+
</SegmentedControl>
99+
</ToggleContainer>
84100
{isError ? <LoadingError message={t('Failed to fetch grouping info.')} /> : null}
85101
{isPending && !hasPerformanceGrouping ? <LoadingIndicator /> : null}
86102
{hasPerformanceGrouping || isSuccess
87103
? variants.map((variant, index) => (
88104
<Fragment key={variant.key}>
89-
<GroupingVariant event={event} variant={variant} />
105+
<GroupingVariant
106+
event={event}
107+
variant={variant}
108+
showNonContributing={showNonContributing}
109+
/>
90110
{index < variants.length - 1 && <VariantDivider />}
91111
</Fragment>
92112
))
@@ -98,11 +118,16 @@ export default function GroupingInfo({
98118
const ConfigHeader = styled('div')`
99119
display: flex;
100120
justify-content: space-between;
101-
gap: ${space(1)};
102-
margin-bottom: ${space(2)};
121+
gap: ${p => p.theme.space.md};
122+
margin-bottom: ${p => p.theme.space['2xs']};
123+
`;
124+
125+
const ToggleContainer = styled(Flex)`
126+
justify-content: flex-start;
127+
padding-bottom: ${p => p.theme.space.lg};
103128
`;
104129

105130
const VariantDivider = styled('hr')`
106-
padding-top: ${space(1)};
131+
padding-top: ${p => p.theme.space.md};
107132
border-top: 1px solid ${p => p.theme.border};
108133
`;

static/app/components/events/groupingInfo/groupingVariant.spec.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ describe('Grouping Variant', () => {
5252
};
5353

5454
it('renders the span hashes for performance issues from event data', () => {
55-
render(<GroupingVariant variant={performanceIssueVariant} event={event} />);
55+
render(
56+
<GroupingVariant
57+
variant={performanceIssueVariant}
58+
event={event}
59+
showNonContributing={false}
60+
/>
61+
);
5662

5763
expect(
5864
within(screen.getByText('Parent Span Hashes').closest('tr') as HTMLElement)
@@ -72,7 +78,13 @@ describe('Grouping Variant', () => {
7278
});
7379

7480
it('renders grouping details for occurrence-backed performance issues', () => {
75-
render(<GroupingVariant variant={performanceIssueVariant} event={occurrenceEvent} />);
81+
render(
82+
<GroupingVariant
83+
variant={performanceIssueVariant}
84+
event={occurrenceEvent}
85+
showNonContributing={false}
86+
/>
87+
);
7688

7789
expect(
7890
within(screen.getByText('Parent Span Hashes').closest('tr') as HTMLElement)

static/app/components/events/groupingInfo/groupingVariant.tsx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {useState} from 'react';
21
import styled from '@emotion/styled';
32

4-
import {SegmentedControl} from 'sentry/components/core/segmentedControl';
53
import {Tooltip} from 'sentry/components/core/tooltip';
64
import KeyValueList from 'sentry/components/events/interfaces/keyValueList';
75
import type {RawSpanType} from 'sentry/components/events/interfaces/spans/types';
@@ -19,10 +17,10 @@ import {EventGroupVariantType} from 'sentry/types/event';
1917
import {capitalize} from 'sentry/utils/string/capitalize';
2018

2119
import GroupingComponent from './groupingComponent';
22-
import {hasNonContributingComponent} from './utils';
2320

2421
interface GroupingVariantProps {
2522
event: Event;
23+
showNonContributing: boolean;
2624
variant: EventGroupVariant;
2725
}
2826

@@ -69,9 +67,7 @@ function addFingerprintInfo(data: VariantData, variant: EventGroupVariant) {
6967
}
7068
}
7169

72-
function GroupingVariant({event, variant}: GroupingVariantProps) {
73-
const [showNonContributing, setShowNonContributing] = useState(false);
74-
70+
function GroupingVariant({event, variant, showNonContributing}: GroupingVariantProps) {
7571
const getVariantData = (): [VariantData, EventGroupComponent | undefined] => {
7672
const data: VariantData = [];
7773
let component: EventGroupComponent | undefined;
@@ -157,22 +153,6 @@ function GroupingVariant({event, variant}: GroupingVariantProps) {
157153
return [data, component];
158154
};
159155

160-
const renderContributionToggle = () => {
161-
return (
162-
<SegmentedControl
163-
aria-label={t('Filter by contribution')}
164-
size="xs"
165-
value={showNonContributing ? 'all' : 'relevant'}
166-
onChange={key => setShowNonContributing(key === 'all')}
167-
>
168-
<SegmentedControl.Item key="relevant">
169-
{t('Contributing values')}
170-
</SegmentedControl.Item>
171-
<SegmentedControl.Item key="all">{t('All values')}</SegmentedControl.Item>
172-
</SegmentedControl>
173-
);
174-
};
175-
176156
const renderTitle = () => {
177157
const isContributing = variant.hash !== null;
178158

@@ -202,13 +182,10 @@ function GroupingVariant({event, variant}: GroupingVariantProps) {
202182
);
203183
};
204184

205-
const [data, component] = getVariantData();
185+
const [data] = getVariantData();
206186
return (
207187
<VariantWrapper>
208-
<Header>
209-
{renderTitle()}
210-
{hasNonContributingComponent(component) && renderContributionToggle()}
211-
</Header>
188+
<Header>{renderTitle()}</Header>
212189

213190
<KeyValueList
214191
data={data.map(d => ({

static/app/components/events/groupingInfo/utils.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
import type {EventGroupComponent} from 'sentry/types/event';
22

3-
export function hasNonContributingComponent(component: EventGroupComponent | undefined) {
4-
if (component === undefined) {
5-
return false;
6-
}
7-
8-
if (!component.contributes) {
9-
return true;
10-
}
11-
12-
for (const value of component.values) {
13-
if (value && typeof value === 'object' && hasNonContributingComponent(value)) {
14-
return true;
15-
}
16-
}
17-
return false;
18-
}
19-
203
export function shouldInlineComponentValue(component: EventGroupComponent) {
214
return (component.values as EventGroupComponent[]).every(
225
value => !value || typeof value !== 'object'

0 commit comments

Comments
 (0)