Skip to content

Commit 9994aa8

Browse files
committed
Add refresh results button to sum by
1 parent 2205569 commit 9994aa8

File tree

8 files changed

+68
-15
lines changed

8 files changed

+68
-15
lines changed

ui/packages/shared/components/src/RefreshButton/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const RefreshButton = ({
2828
disabled,
2929
title,
3030
testId,
31-
loading,
3231
sticky = false,
3332
}: RefreshButtonProps): JSX.Element => {
3433
return (

ui/packages/shared/profile/src/ProfileSelector/QueryControls.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ import {RpcError} from '@protobuf-ts/runtime-rpc';
1818
import Select, {type SelectInstance} from 'react-select';
1919

2020
import {ProfileTypesResponse, QueryServiceClient} from '@parca/client';
21-
import {Button, DateTimeRange, DateTimeRangePicker, useParcaContext} from '@parca/components';
21+
import {
22+
Button,
23+
DateTimeRange,
24+
DateTimeRangePicker,
25+
RefreshButton,
26+
useParcaContext,
27+
} from '@parca/components';
2228
import {ProfileType, Query} from '@parca/parser';
2329
import {TEST_IDS, testId} from '@parca/test-utils';
2430

@@ -65,6 +71,7 @@ interface QueryControlsProps {
6571
setUserSumBySelection: (sumBy: string[]) => void;
6672
sumByRef: React.RefObject<SelectInstance>;
6773
profileType: ProfileType;
74+
refreshLabelNames: () => void;
6875
}
6976

7077
export function QueryControls({
@@ -93,6 +100,7 @@ export function QueryControls({
93100
profileType,
94101
showSumBySelector,
95102
profileTypesError,
103+
refreshLabelNames,
96104
}: QueryControlsProps): JSX.Element {
97105
const {timezone} = useParcaContext();
98106
const [searchExecutedTimestamp, setSearchExecutedTimestamp] = useState<number>(0);
@@ -220,7 +228,16 @@ export function QueryControls({
220228
placeholder="Labels..."
221229
styles={{
222230
indicatorSeparator: () => ({display: 'none'}),
223-
menu: provided => ({...provided, width: 'max-content', zIndex: 50}), // Setting the same zIndex as drop down menus
231+
menu: provided => ({
232+
...provided,
233+
marginBottom: 0,
234+
boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
235+
marginTop: 10,
236+
zIndex: 50,
237+
minWidth: '320px',
238+
position: 'absolute',
239+
}),
240+
// menu: provided => ({...provided, width: 'max-content', zIndex: 50}), // Setting the same zIndex as drop down menus
224241
}}
225242
isLoading={sumBySelectionLoading}
226243
isDisabled={!profileType.delta}
@@ -245,6 +262,30 @@ export function QueryControls({
245262
currentRef.blur();
246263
}
247264
}}
265+
components={{
266+
// eslint-disable-next-line react/prop-types
267+
MenuList: ({children, innerProps}) => (
268+
<div className="flex flex-col" style={{maxHeight: '332px'}}>
269+
<div
270+
className="overflow-y-auto flex-1"
271+
{...testId(TEST_IDS.SUM_BY_SELECT_FLYOUT)}
272+
{...innerProps}
273+
// eslint-disable-next-line react/prop-types
274+
style={{...innerProps.style, fontSize: '14px'}}
275+
>
276+
{children}
277+
</div>
278+
{refreshLabelNames != null && (
279+
<RefreshButton
280+
onClick={() => void refreshLabelNames()}
281+
disabled={sumBySelectionLoading}
282+
title="Refresh label names"
283+
testId="sum-by-refresh-button"
284+
/>
285+
)}
286+
</div>
287+
),
288+
}}
248289
/>
249290
</div>
250291
)}

ui/packages/shared/profile/src/ProfileSelector/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,11 @@ const ProfileSelector = ({
174174
const from = timeRangeSelection.getFromMs();
175175
const to = timeRangeSelection.getToMs();
176176

177-
const {loading: labelNamesLoading, result} = useLabelNames(
178-
queryClient,
179-
profileType.toString(),
180-
from,
181-
to
182-
);
177+
const {
178+
loading: labelNamesLoading,
179+
result,
180+
refetch,
181+
} = useLabelNames(queryClient, profileType.toString(), from, to);
183182
const {loading: selectedLabelNamesLoading, result: selectedLabelNamesResult} = useLabelNames(
184183
queryClient,
185184
selectedProfileType.toString(),
@@ -329,6 +328,7 @@ const ProfileSelector = ({
329328
profileType={profileType}
330329
profileTypesError={error}
331330
viewComponent={viewComponent}
331+
refreshLabelNames={refetch}
332332
/>
333333
{comparing && (
334334
<div>

ui/packages/shared/profile/src/ProfileView/components/ActionButtons/GroupByDropdown.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ interface GroupByControlsProps {
2020
labels: string[];
2121
setGroupByLabels: (labels: string[]) => void;
2222
metadataRefetch?: () => void;
23+
metadataLoading: boolean;
2324
}
2425

2526
const GroupByControls: React.FC<GroupByControlsProps> = ({
2627
groupBy,
2728
labels,
2829
setGroupByLabels,
2930
metadataRefetch,
31+
metadataLoading,
3032
}) => {
3133
return (
3234
<div className="relative flex" id="h-group-by-controls">
@@ -35,6 +37,7 @@ const GroupByControls: React.FC<GroupByControlsProps> = ({
3537
groupBy={groupBy}
3638
setGroupByLabels={setGroupByLabels}
3739
metadataRefetch={metadataRefetch}
40+
metadataLoading={metadataLoading}
3841
/>
3942
</div>
4043
);

ui/packages/shared/profile/src/ProfileView/components/GroupByLabelsDropdown/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ interface Props {
3030
groupBy: string[];
3131
setGroupByLabels: (labels: string[]) => void;
3232
metadataRefetch?: () => void;
33+
metadataLoading: boolean;
3334
}
3435

3536
const GroupByLabelsDropdown = ({
3637
labels,
3738
groupBy,
3839
setGroupByLabels,
3940
metadataRefetch,
41+
metadataLoading,
4042
}: Props): JSX.Element => {
4143
const [isRefetching, setIsRefetching] = useState(false);
4244

@@ -98,6 +100,7 @@ const GroupByLabelsDropdown = ({
98100
setGroupByLabels(newValue.map(option => option.value));
99101
}}
100102
placeholder="Select labels..."
103+
isLoading={metadataLoading}
101104
styles={{
102105
menu: provided => ({
103106
...provided,

ui/packages/shared/profile/src/ProfileView/components/Toolbars/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export interface VisualisationToolbarProps {
4444
profileType?: ProfileType;
4545
total: bigint;
4646
filtered: bigint;
47-
groupByLabels: string[];
4847
preferencesModal?: boolean;
4948
profileViewExternalSubActions?: React.ReactNode;
5049
setGroupByLabels: (labels: string[]) => void;
@@ -54,7 +53,11 @@ export interface VisualisationToolbarProps {
5453
setAlignFunctionName: (align: string) => void;
5554
colorBy: string;
5655
setColorBy: (colorBy: string) => void;
57-
metadataRefetch?: () => void;
56+
metadata: {
57+
labels: string[];
58+
refetch?: () => void;
59+
loading: boolean;
60+
};
5861
}
5962

6063
export interface TableToolbarProps {
@@ -131,7 +134,6 @@ const Divider = (): JSX.Element => (
131134
export const VisualisationToolbar: FC<VisualisationToolbarProps> = ({
132135
groupBy,
133136
toggleGroupBy,
134-
groupByLabels,
135137
setGroupByLabels,
136138
profileType,
137139
profileSource,
@@ -148,7 +150,7 @@ export const VisualisationToolbar: FC<VisualisationToolbarProps> = ({
148150
setAlignFunctionName,
149151
colorBy,
150152
setColorBy,
151-
metadataRefetch,
153+
metadata: {labels: groupByLabels, refetch: metadataRefetch, loading: metadataLoading},
152154
}) => {
153155
const {dashboardItems} = useDashboard();
154156

@@ -175,6 +177,7 @@ export const VisualisationToolbar: FC<VisualisationToolbarProps> = ({
175177
labels={groupByLabels}
176178
setGroupByLabels={setGroupByLabels}
177179
metadataRefetch={metadataRefetch}
180+
metadataLoading={metadataLoading}
178181
/>
179182

180183
<InvertCallStack />

ui/packages/shared/profile/src/ProfileView/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ export const ProfileView = ({
145145
profileType={profileSource?.ProfileType()}
146146
total={total}
147147
filtered={filtered}
148-
groupByLabels={flamegraphData.metadataLabels ?? []}
148+
metadata={{
149+
labels: flamegraphData.metadataLabels ?? [],
150+
refetch: flamegraphData.metadataRefetch,
151+
loading: flamegraphData.metadataLoading,
152+
}}
149153
preferencesModal={preferencesModal}
150154
profileViewExternalSubActions={profileViewExternalSubActions}
151155
setGroupByLabels={setGroupByLabels}
@@ -155,7 +159,6 @@ export const ProfileView = ({
155159
setAlignFunctionName={setAlignFunctionName}
156160
colorBy={colorBy}
157161
setColorBy={setColorBy}
158-
metadataRefetch={flamegraphData.metadataRefetch}
159162
/>
160163

161164
{isColorStackLegendEnabled && (

ui/packages/shared/test-utils/src/test-ids.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const TEST_IDS = {
6060
SUM_BY_CONTAINER: 'sum-by-container',
6161
SUM_BY_LABEL: 'sum-by-label',
6262
SUM_BY_SELECT: 'sum-by-select',
63+
SUM_BY_SELECT_FLYOUT: 'sum-by-select-flyout',
6364

6465
// Date Time Range Picker
6566
DATE_TIME_RANGE_PICKER: 'date-time-range-picker',

0 commit comments

Comments
 (0)