Skip to content

Commit 46fdb29

Browse files
committed
inline property selector with aggregate, drop add filter below
1 parent 121e3b9 commit 46fdb29

1 file changed

Lines changed: 62 additions & 67 deletions

File tree

apps/start/src/components/report/sidebar/ReportSeries.tsx

Lines changed: 62 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,40 @@ function SortableSeries({
9898
</button>
9999
);
100100

101+
const isPropertyAgg = chartEvent?.segment.startsWith('property_') ?? false;
102+
103+
const addFilterButton =
104+
chartEvent && showAddFilter ? (
105+
<PropertyPicker
106+
projectId={projectId}
107+
event={chartEvent.name}
108+
onSelect={(action) => {
109+
dispatch(
110+
changeEvent({
111+
...chartEvent,
112+
filters: [
113+
...chartEvent.filters,
114+
{
115+
id: shortId(),
116+
name: action.value,
117+
operator: action.cohortId ? 'inCohort' : 'is',
118+
value: [],
119+
cohortId: action.cohortId,
120+
},
121+
],
122+
}),
123+
);
124+
}}
125+
>
126+
<button
127+
type="button"
128+
className="flex h-8 items-center gap-1 rounded-md px-2 text-sm font-medium leading-none text-muted-foreground transition-colors hover:bg-def-200 hover:text-foreground"
129+
>
130+
<FilterIcon size={12} /> Add filter
131+
</button>
132+
</PropertyPicker>
133+
) : null;
134+
101135
return (
102136
<div ref={setNodeRef} style={style} {...attributes} {...props}>
103137
<div className="flex flex-col gap-2 p-2 group">
@@ -108,76 +142,37 @@ function SortableSeries({
108142
<FiltersList event={chartEvent} />
109143
)}
110144

111-
{/* Aggregate-by + add filter row - only for events */}
145+
{/* Aggregate-by row: the property selector sits inline with the
146+
aggregate; add filter stays here unless it drops below. */}
112147
{chartEvent && (showSegment || showAddFilter || showPerUser) && (
113-
<div className="flex flex-wrap gap-1">
114-
{showSegment && (
115-
<ReportSegment
116-
value={chartEvent.segment}
117-
onChange={(segment) => {
118-
dispatch(
119-
changeEvent({
120-
...chartEvent,
121-
segment,
122-
}),
123-
);
124-
}}
125-
/>
126-
)}
127-
{/* Per-user is only meaningful for the Distribution chart (bucket
128-
users by their per-user value); hidden everywhere else. */}
129-
{showPerUser && (
130-
<ReportPerUser
131-
event={chartEvent}
132-
onChange={(perUser) => {
133-
dispatch(
134-
changeEvent({
135-
...chartEvent,
136-
perUser,
137-
}),
138-
);
139-
}}
140-
/>
141-
)}
142-
{showAddFilter && (
143-
<PropertyPicker
144-
projectId={projectId}
145-
event={chartEvent.name}
146-
onSelect={(action) => {
147-
dispatch(
148-
changeEvent({
149-
...chartEvent,
150-
filters: [
151-
...chartEvent.filters,
152-
{
153-
id: shortId(),
154-
name: action.value,
155-
operator: action.cohortId ? 'inCohort' : 'is',
156-
value: [],
157-
cohortId: action.cohortId,
158-
},
159-
],
160-
}),
161-
);
162-
}}
163-
>
164-
<button
165-
type="button"
166-
className="flex h-8 items-center gap-1 rounded-md px-2 text-sm font-medium leading-none text-muted-foreground transition-colors hover:bg-def-200 hover:text-foreground"
167-
>
168-
<FilterIcon size={12} /> Add filter
169-
</button>
170-
</PropertyPicker>
171-
)}
148+
<div className="flex flex-col gap-1">
149+
<div className="flex flex-wrap gap-1">
150+
{showSegment && (
151+
<ReportSegment
152+
value={chartEvent.segment}
153+
onChange={(segment) => {
154+
dispatch(changeEvent({ ...chartEvent, segment }));
155+
}}
156+
/>
157+
)}
158+
{showSegment && isPropertyAgg && (
159+
<EventPropertiesCombobox event={chartEvent} />
160+
)}
161+
{/* Per-user is only meaningful for the Distribution chart. */}
162+
{showPerUser && (
163+
<ReportPerUser
164+
event={chartEvent}
165+
onChange={(perUser) => {
166+
dispatch(changeEvent({ ...chartEvent, perUser }));
167+
}}
168+
/>
169+
)}
170+
{!isPropertyAgg && addFilterButton}
171+
</div>
172+
{/* Add filter drops below when aggregating by a property */}
173+
{isPropertyAgg && addFilterButton}
172174
</div>
173175
)}
174-
175-
{/* Property selector sits below when aggregating by a property */}
176-
{chartEvent &&
177-
showSegment &&
178-
chartEvent.segment.startsWith('property_') && (
179-
<EventPropertiesCombobox event={chartEvent} />
180-
)}
181176
</div>
182177
</div>
183178
);

0 commit comments

Comments
 (0)