@parca/profile 0.19.81 → 0.19.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/MatchersInput/index.d.ts +2 -34
  3. package/dist/MatchersInput/index.d.ts.map +1 -1
  4. package/dist/MatchersInput/index.js +14 -91
  5. package/dist/MetricsGraph/index.d.ts.map +1 -1
  6. package/dist/MetricsGraph/index.js +13 -1
  7. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  8. package/dist/ProfileMetricsGraph/index.js +6 -29
  9. package/dist/ProfileSelector/MetricsGraphSection.d.ts +2 -9
  10. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  11. package/dist/ProfileSelector/MetricsGraphSection.js +3 -38
  12. package/dist/ProfileSelector/index.d.ts +1 -29
  13. package/dist/ProfileSelector/index.d.ts.map +1 -1
  14. package/dist/ProfileSelector/index.js +12 -9
  15. package/dist/QueryControls/index.d.ts +42 -0
  16. package/dist/QueryControls/index.d.ts.map +1 -0
  17. package/dist/{ProfileSelector/QueryControls.js → QueryControls/index.js} +16 -13
  18. package/dist/SimpleMatchers/Select.js +1 -1
  19. package/dist/SimpleMatchers/index.d.ts +2 -11
  20. package/dist/SimpleMatchers/index.d.ts.map +1 -1
  21. package/dist/SimpleMatchers/index.js +34 -45
  22. package/dist/ViewMatchers/index.d.ts +0 -9
  23. package/dist/ViewMatchers/index.d.ts.map +1 -1
  24. package/dist/ViewMatchers/index.js +20 -12
  25. package/dist/contexts/LabelsQueryProvider.d.ts +35 -0
  26. package/dist/contexts/LabelsQueryProvider.d.ts.map +1 -0
  27. package/dist/contexts/LabelsQueryProvider.js +70 -0
  28. package/dist/contexts/UnifiedLabelsContext.d.ts +37 -0
  29. package/dist/contexts/UnifiedLabelsContext.d.ts.map +1 -0
  30. package/dist/contexts/UnifiedLabelsContext.js +88 -0
  31. package/dist/contexts/utils.d.ts +10 -0
  32. package/dist/contexts/utils.d.ts.map +1 -0
  33. package/dist/contexts/utils.js +31 -0
  34. package/dist/hooks/useLabels.d.ts +23 -0
  35. package/dist/hooks/useLabels.d.ts.map +1 -0
  36. package/dist/hooks/useLabels.js +75 -0
  37. package/dist/hooks/useQueryState.d.ts +2 -0
  38. package/dist/hooks/useQueryState.d.ts.map +1 -1
  39. package/dist/hooks/useQueryState.js +18 -0
  40. package/dist/index.d.ts +9 -3
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +9 -3
  43. package/dist/styles.css +1 -1
  44. package/dist/useSumBy.js +1 -1
  45. package/package.json +2 -2
  46. package/src/MatchersInput/index.tsx +17 -163
  47. package/src/MetricsGraph/index.tsx +17 -1
  48. package/src/ProfileMetricsGraph/index.tsx +17 -98
  49. package/src/ProfileSelector/MetricsGraphSection.tsx +14 -115
  50. package/src/ProfileSelector/index.tsx +106 -109
  51. package/src/{ProfileSelector/QueryControls.tsx → QueryControls/index.tsx} +66 -84
  52. package/src/SimpleMatchers/Select.tsx +1 -1
  53. package/src/SimpleMatchers/index.tsx +46 -85
  54. package/src/ViewMatchers/index.tsx +22 -30
  55. package/src/contexts/LabelsQueryProvider.tsx +142 -0
  56. package/src/contexts/UnifiedLabelsContext.tsx +155 -0
  57. package/src/contexts/utils.ts +43 -0
  58. package/src/hooks/useLabels.ts +121 -0
  59. package/src/hooks/useQueryState.ts +25 -0
  60. package/src/index.tsx +29 -3
  61. package/src/useSumBy.ts +1 -1
  62. package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts +0 -29
  63. package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts.map +0 -1
  64. package/dist/MetricsGraph/UtilizationMetrics/Throughput.js +0 -175
  65. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts +0 -28
  66. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts.map +0 -1
  67. package/dist/MetricsGraph/UtilizationMetrics/index.js +0 -186
  68. package/dist/ProfileSelector/QueryControls.d.ts +0 -43
  69. package/dist/ProfileSelector/QueryControls.d.ts.map +0 -1
  70. package/dist/contexts/MatchersInputLabelsContext.d.ts +0 -29
  71. package/dist/contexts/MatchersInputLabelsContext.d.ts.map +0 -1
  72. package/dist/contexts/MatchersInputLabelsContext.js +0 -79
  73. package/dist/contexts/SimpleMatchersLabelContext.d.ts +0 -25
  74. package/dist/contexts/SimpleMatchersLabelContext.d.ts.map +0 -1
  75. package/dist/contexts/SimpleMatchersLabelContext.js +0 -115
  76. package/dist/contexts/UtilizationLabelsContext.d.ts +0 -15
  77. package/dist/contexts/UtilizationLabelsContext.d.ts.map +0 -1
  78. package/dist/contexts/UtilizationLabelsContext.js +0 -25
  79. package/src/MetricsGraph/UtilizationMetrics/Throughput.tsx +0 -405
  80. package/src/MetricsGraph/UtilizationMetrics/index.tsx +0 -426
  81. package/src/contexts/MatchersInputLabelsContext.tsx +0 -141
  82. package/src/contexts/SimpleMatchersLabelContext.tsx +0 -189
  83. package/src/contexts/UtilizationLabelsContext.tsx +0 -45
@@ -29,13 +29,14 @@ import {Query} from '@parca/parser';
29
29
  import {TEST_IDS, testId} from '@parca/test-utils';
30
30
  import {millisToProtoTimestamp, type NavigateFunction} from '@parca/utilities';
31
31
 
32
- import {useLabelNames} from '../MatchersInput/index';
33
32
  import {useMetricsGraphDimensions} from '../MetricsGraph/useMetricsGraphDimensions';
34
- import {UtilizationLabelsProvider} from '../contexts/UtilizationLabelsContext';
33
+ import {QueryControls} from '../QueryControls';
34
+ import {LabelsQueryProvider, useLabelsQueryProvider} from '../contexts/LabelsQueryProvider';
35
+ import {UnifiedLabelsProvider} from '../contexts/UnifiedLabelsContext';
36
+ import {useLabelNames} from '../hooks/useLabels';
35
37
  import {useQueryState} from '../hooks/useQueryState';
36
38
  import useGrpcQuery from '../useGrpcQuery';
37
39
  import {MetricsGraphSection} from './MetricsGraphSection';
38
- import {QueryControls} from './QueryControls';
39
40
  import {useAutoQuerySelector} from './useAutoQuerySelector';
40
41
 
41
42
  export interface QuerySelection {
@@ -52,31 +53,9 @@ interface ProfileSelectorFeatures {
52
53
  showMetricsGraph: boolean;
53
54
  showSumBySelector?: boolean;
54
55
  showProfileTypeSelector?: boolean;
55
- disableExplorativeQuerying?: boolean;
56
56
  disableProfileTypesDropdown?: boolean;
57
57
  }
58
58
 
59
- export interface UtilizationMetrics {
60
- isSelected: boolean;
61
- labelset: {
62
- labels: Array<{
63
- name: string;
64
- value: string;
65
- }>;
66
- };
67
- samples: Array<{
68
- timestamp: number;
69
- value: number;
70
- }>;
71
- }
72
-
73
- export interface UtilizationLabels {
74
- utilizationLabelNames?: string[];
75
- utilizationFetchLabelValues?: (key: string) => Promise<string[]>;
76
- utilizationLabelValues?: string[];
77
- utilizationLabelNamesLoading?: boolean;
78
- }
79
-
80
59
  interface ProfileSelectorProps extends ProfileSelectorFeatures {
81
60
  queryClient: QueryServiceClient;
82
61
  closeProfile: () => void;
@@ -85,14 +64,6 @@ interface ProfileSelectorProps extends ProfileSelectorFeatures {
85
64
  navigateTo: NavigateFunction;
86
65
  setDisplayHideMetricsGraphButton?: Dispatch<SetStateAction<boolean>>;
87
66
  suffix?: '_a' | '_b'; // For comparison mode
88
- utilizationMetrics?: Array<{
89
- name: string;
90
- humanReadableName: string;
91
- data: UtilizationMetrics[];
92
- }>;
93
- utilizationMetricsLoading?: boolean;
94
- utilizationLabels?: UtilizationLabels;
95
- onUtilizationSeriesSelect?: (name: string, seriesIndex: number) => void;
96
67
  onSearchHook?: () => void;
97
68
  }
98
69
 
@@ -139,16 +110,11 @@ const ProfileSelector = ({
139
110
  showMetricsGraph = true,
140
111
  showSumBySelector = true,
141
112
  showProfileTypeSelector = true,
142
- disableExplorativeQuerying = false,
143
113
  setDisplayHideMetricsGraphButton,
144
114
  suffix,
145
- utilizationMetrics,
146
- utilizationMetricsLoading,
147
- utilizationLabels,
148
- onUtilizationSeriesSelect,
149
115
  onSearchHook,
150
116
  }: ProfileSelectorProps): JSX.Element => {
151
- const {heightStyle} = useMetricsGraphDimensions(comparing, utilizationMetrics != null);
117
+ const {heightStyle} = useMetricsGraphDimensions(comparing, false);
152
118
  const {viewComponent} = useParcaContext();
153
119
  const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');
154
120
  const batchUpdates = useURLStateBatch();
@@ -201,7 +167,7 @@ const ProfileSelector = ({
201
167
  error,
202
168
  } = useProfileTypes(queryClient, from, to);
203
169
 
204
- const {result, refetch} = useLabelNames(queryClient, profileType.toString(), from, to);
170
+ const {result} = useLabelNames(queryClient, profileType.toString(), from, to);
205
171
 
206
172
  const labels = useMemo(() => {
207
173
  return result.response?.labelNames === undefined ? [] : result.response.labelNames;
@@ -298,77 +264,108 @@ const ProfileSelector = ({
298
264
  const sumByRef = useRef(null);
299
265
 
300
266
  return (
301
- <UtilizationLabelsProvider value={{...utilizationLabels}}>
302
- <>
303
- <div className="mb-2 flex">
304
- <QueryControls
305
- showProfileTypeSelector={showProfileTypeSelector}
306
- showSumBySelector={showSumBySelector}
307
- disableExplorativeQuerying={disableExplorativeQuerying}
308
- profileTypesData={profileTypesData}
309
- profileTypesLoading={profileTypesLoading}
310
- selectedProfileName={selectedProfileName}
311
- setProfileName={setProfileName}
312
- setMatchersString={setMatchersString}
313
- setQueryExpression={setQueryExpression}
314
- query={query}
315
- queryBrowserRef={queryBrowserRef}
316
- timeRangeSelection={timeRangeSelection}
317
- setTimeRangeSelection={handleTimeRangeChange}
318
- searchDisabled={searchDisabled}
319
- queryBrowserMode={queryBrowserMode as string}
320
- setQueryBrowserMode={setQueryBrowserMode}
321
- advancedModeForQueryBrowser={advancedModeForQueryBrowser}
322
- setAdvancedModeForQueryBrowser={setAdvancedModeForQueryBrowser}
323
- queryClient={queryClient}
324
- sumByRef={sumByRef}
325
- labels={labels}
326
- sumBySelection={draftSelection.sumBy ?? []}
327
- sumBySelectionLoading={sumByLoading}
328
- setUserSumBySelection={setDraftSumBy}
329
- profileType={profileType}
330
- profileTypesError={error}
331
- viewComponent={viewComponent}
332
- refreshLabelNames={refetch}
333
- />
334
- {comparing && (
335
- <div>
336
- <IconButton
337
- onClick={() => closeProfile()}
338
- icon={<CloseIcon />}
339
- {...testId(TEST_IDS.COMPARE_CLOSE_BUTTON)}
340
- />
341
- </div>
342
- )}
343
- </div>
344
- <MetricsGraphSection
345
- showMetricsGraph={showMetricsGraph}
346
- setDisplayHideMetricsGraphButton={setDisplayHideMetricsGraphButton}
347
- heightStyle={
348
- utilizationMetrics !== undefined && utilizationMetrics?.length > 0
349
- ? 'auto'
350
- : heightStyle
351
- }
352
- querySelection={querySelection}
353
- profileSelection={profileSelection}
354
- comparing={comparing}
355
- sumBy={querySelection.sumBy ?? []}
356
- defaultSumByLoading={sumByLoading}
267
+ <>
268
+ <div className="mb-2 flex">
269
+ <LabelsQueryProvider
270
+ setMatchersString={setMatchersString}
271
+ runQuery={setQueryExpression}
272
+ currentQuery={query}
273
+ profileType={selectedProfileName ?? profileType.toString()}
357
274
  queryClient={queryClient}
358
- queryExpressionString={queryExpressionString}
359
- setTimeRangeSelection={handleTimeRangeChange}
360
- selectQuery={commitDraft}
361
- setProfileSelection={setProfileSelection}
362
- query={query}
363
- setQueryExpression={setQueryExpression}
364
- setNewQueryExpression={setDraftExpression}
365
- utilizationMetrics={utilizationMetrics}
366
- utilizationMetricsLoading={utilizationMetricsLoading}
367
- onUtilizationSeriesSelect={onUtilizationSeriesSelect}
368
- />
369
- </>
370
- </UtilizationLabelsProvider>
275
+ start={timeRangeSelection.getFromMs()}
276
+ end={timeRangeSelection.getToMs()}
277
+ suffix={suffix}
278
+ >
279
+ <LabelsSource>
280
+ <QueryControls
281
+ showProfileTypeSelector={showProfileTypeSelector}
282
+ showSumBySelector={showSumBySelector}
283
+ profileTypesData={profileTypesData}
284
+ profileTypesLoading={profileTypesLoading}
285
+ selectedProfileName={selectedProfileName}
286
+ setProfileName={setProfileName}
287
+ setMatchersString={setMatchersString}
288
+ setQueryExpression={setQueryExpression}
289
+ query={query}
290
+ queryBrowserRef={queryBrowserRef}
291
+ timeRangeSelection={timeRangeSelection}
292
+ setTimeRangeSelection={handleTimeRangeChange}
293
+ searchDisabled={searchDisabled}
294
+ setQueryBrowserMode={setQueryBrowserMode}
295
+ advancedModeForQueryBrowser={advancedModeForQueryBrowser}
296
+ setAdvancedModeForQueryBrowser={setAdvancedModeForQueryBrowser}
297
+ queryClient={queryClient}
298
+ sumByRef={sumByRef}
299
+ labels={labels}
300
+ sumBySelection={draftSelection.sumBy ?? []}
301
+ sumBySelectionLoading={sumByLoading}
302
+ setUserSumBySelection={setDraftSumBy}
303
+ profileType={profileType}
304
+ profileTypesError={error}
305
+ viewComponent={viewComponent}
306
+ />
307
+ </LabelsSource>
308
+ </LabelsQueryProvider>
309
+ {comparing && (
310
+ <div>
311
+ <IconButton
312
+ onClick={() => closeProfile()}
313
+ icon={<CloseIcon />}
314
+ {...testId(TEST_IDS.COMPARE_CLOSE_BUTTON)}
315
+ />
316
+ </div>
317
+ )}
318
+ </div>
319
+ <MetricsGraphSection
320
+ showMetricsGraph={showMetricsGraph}
321
+ setDisplayHideMetricsGraphButton={setDisplayHideMetricsGraphButton}
322
+ heightStyle={heightStyle}
323
+ querySelection={querySelection}
324
+ profileSelection={profileSelection}
325
+ comparing={comparing}
326
+ sumBy={querySelection.sumBy ?? []}
327
+ defaultSumByLoading={sumByLoading}
328
+ queryClient={queryClient}
329
+ queryExpressionString={queryExpressionString}
330
+ setTimeRangeSelection={handleTimeRangeChange}
331
+ selectQuery={commitDraft}
332
+ setProfileSelection={setProfileSelection}
333
+ query={query}
334
+ setQueryExpression={setQueryExpression}
335
+ setNewQueryExpression={setDraftExpression}
336
+ />
337
+ </>
371
338
  );
372
339
  };
373
340
 
374
341
  export default ProfileSelector;
342
+
343
+ const LabelsSource = ({children}: {children: React.ReactNode}): JSX.Element => {
344
+ const {
345
+ labelNames,
346
+ labelValues,
347
+ isLabelNamesLoading,
348
+ isLabelValuesLoading,
349
+ refetchLabelValues,
350
+ refetchLabelNames,
351
+ currentLabelName,
352
+ setCurrentLabelName,
353
+ suffix,
354
+ } = useLabelsQueryProvider();
355
+
356
+ return (
357
+ <UnifiedLabelsProvider
358
+ labelNames={labelNames}
359
+ labelValues={labelValues}
360
+ isLabelNamesLoading={isLabelNamesLoading}
361
+ isLabelValuesLoading={isLabelValuesLoading}
362
+ refetchLabelValues={refetchLabelValues}
363
+ refetchLabelNames={refetchLabelNames}
364
+ currentLabelName={currentLabelName}
365
+ setCurrentLabelName={setCurrentLabelName}
366
+ suffix={suffix}
367
+ >
368
+ {children}
369
+ </UnifiedLabelsProvider>
370
+ );
371
+ };
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
 
14
- import {useState} from 'react';
14
+ import {useRef, useState} from 'react';
15
15
 
16
16
  import {Switch} from '@headlessui/react';
17
17
  import {RpcError} from '@protobuf-ts/runtime-rpc';
@@ -24,9 +24,10 @@ import {TEST_IDS, testId} from '@parca/test-utils';
24
24
 
25
25
  import MatchersInput from '../MatchersInput';
26
26
  import ProfileTypeSelector from '../ProfileTypeSelector';
27
- import SelectWithRefresh from '../SelectWithRefresh';
28
- import SimpleMatchers from '../SimpleMatchers';
27
+ import {SelectWithRefresh} from '../SelectWithRefresh';
28
+ import SimpleMatchers from '../SimpleMatchers/';
29
29
  import ViewMatchers from '../ViewMatchers';
30
+ import {useLabelNames} from '../hooks/useLabels';
30
31
 
31
32
  interface SelectOption {
32
33
  label: string;
@@ -34,13 +35,22 @@ interface SelectOption {
34
35
  }
35
36
 
36
37
  interface QueryControlsProps {
37
- showProfileTypeSelector: boolean;
38
- showSumBySelector: boolean;
39
- disableExplorativeQuerying: boolean;
38
+ queryClient: QueryServiceClient;
39
+ query: Query;
40
+ profileType: string | ProfileType;
41
+ timeRangeSelection: DateTimeRange;
42
+ setTimeRangeSelection: (range: DateTimeRange) => void;
43
+ setMatchersString: (matchers: string) => void;
44
+ setQueryExpression: (updateTs?: boolean) => void;
45
+ searchDisabled: boolean;
46
+ showProfileTypeSelector?: boolean;
47
+ showSumBySelector?: boolean;
48
+ showAdvancedMode?: boolean;
49
+ disableExplorativeQuerying?: boolean;
40
50
  profileTypesData?: ProfileTypesResponse;
41
- profileTypesLoading: boolean;
42
- selectedProfileName: string;
43
- setProfileName: (name: string | undefined) => void;
51
+ profileTypesLoading?: boolean;
52
+ selectedProfileName?: string;
53
+ setProfileName?: (name: string | undefined) => void;
44
54
  profileTypesError?: RpcError;
45
55
  viewComponent?: {
46
56
  disableProfileTypesDropdown?: boolean;
@@ -48,58 +58,55 @@ interface QueryControlsProps {
48
58
  labelnames?: string[];
49
59
  createViewComponent?: React.ReactNode;
50
60
  };
51
- queryBrowserMode: string;
52
- setQueryBrowserMode: (mode: string) => void;
53
- advancedModeForQueryBrowser: boolean;
54
- setAdvancedModeForQueryBrowser: (mode: boolean) => void;
55
- setMatchersString: (matchers: string) => void;
56
- setQueryExpression: (updateTs?: boolean) => void;
57
- query: Query;
58
- queryBrowserRef: React.RefObject<HTMLDivElement>;
59
- timeRangeSelection: DateTimeRange;
60
- setTimeRangeSelection: (range: DateTimeRange) => void;
61
- searchDisabled: boolean;
62
- queryClient: QueryServiceClient;
63
- labels: string[];
64
- sumBySelection: string[];
65
- sumBySelectionLoading: boolean;
66
- setUserSumBySelection: (sumBy: string[]) => void;
67
- sumByRef: React.RefObject<SelectInstance>;
68
- profileType: ProfileType;
69
- refreshLabelNames: () => Promise<void>;
61
+ setQueryBrowserMode?: (mode: string) => void;
62
+ advancedModeForQueryBrowser?: boolean;
63
+ setAdvancedModeForQueryBrowser?: (mode: boolean) => void;
64
+ queryBrowserRef?: React.RefObject<HTMLDivElement>;
65
+ labels?: string[];
66
+ sumBySelection?: string[];
67
+ sumBySelectionLoading?: boolean;
68
+ setUserSumBySelection?: (sumBy: string[]) => void;
69
+ sumByRef?: React.RefObject<SelectInstance>;
70
70
  }
71
71
 
72
72
  export function QueryControls({
73
- showProfileTypeSelector,
73
+ profileType,
74
+ timeRangeSelection,
75
+ setTimeRangeSelection,
76
+ setQueryExpression,
77
+ searchDisabled,
78
+ showProfileTypeSelector = false,
79
+ showSumBySelector = false,
80
+ showAdvancedMode = true,
74
81
  profileTypesData,
75
- profileTypesLoading,
82
+ profileTypesLoading = false,
76
83
  selectedProfileName,
77
84
  setProfileName,
85
+ profileTypesError,
78
86
  viewComponent,
79
87
  setQueryBrowserMode,
80
- advancedModeForQueryBrowser,
88
+ advancedModeForQueryBrowser = false,
81
89
  setAdvancedModeForQueryBrowser,
82
- setMatchersString,
83
- setQueryExpression,
84
- query,
85
90
  queryBrowserRef,
86
- timeRangeSelection,
87
- setTimeRangeSelection,
88
- searchDisabled,
89
- queryClient,
90
- labels,
91
- sumBySelection,
92
- sumBySelectionLoading,
91
+ labels = [],
92
+ sumBySelection = [],
93
+ sumBySelectionLoading = false,
93
94
  setUserSumBySelection,
94
95
  sumByRef,
95
- profileType,
96
- showSumBySelector,
97
- profileTypesError,
98
- refreshLabelNames,
96
+ queryClient,
99
97
  }: QueryControlsProps): JSX.Element {
100
98
  const {timezone} = useParcaContext();
99
+ const defaultQueryBrowserRef = useRef<HTMLDivElement>(null);
100
+ const actualQueryBrowserRef = queryBrowserRef ?? defaultQueryBrowserRef;
101
101
  const [searchExecutedTimestamp, setSearchExecutedTimestamp] = useState<number>(0);
102
102
 
103
+ const {refetch: refetchLabelNames} = useLabelNames(
104
+ queryClient,
105
+ profileType as string,
106
+ timeRangeSelection.getFromMs(),
107
+ timeRangeSelection.getToMs()
108
+ );
109
+
103
110
  return (
104
111
  <div
105
112
  className="flex w-full flex-wrap items-start gap-2"
@@ -114,7 +121,7 @@ export function QueryControls({
114
121
  profileTypesData={profileTypesData}
115
122
  loading={profileTypesLoading}
116
123
  selectedKey={selectedProfileName}
117
- onSelection={setProfileName}
124
+ onSelection={setProfileName ?? (() => {})}
118
125
  error={profileTypesError}
119
126
  disabled={viewComponent?.disableProfileTypesDropdown}
120
127
  />
@@ -123,7 +130,7 @@ export function QueryControls({
123
130
 
124
131
  <div
125
132
  className="w-full flex-1 flex flex-col gap-1 mt-auto"
126
- ref={queryBrowserRef}
133
+ ref={actualQueryBrowserRef}
127
134
  {...testId(TEST_IDS.QUERY_BROWSER_CONTAINER)}
128
135
  >
129
136
  <div className="flex items-center justify-between">
@@ -131,13 +138,13 @@ export function QueryControls({
131
138
  <label className="text-xs" {...testId(TEST_IDS.QUERY_LABEL)}>
132
139
  Query
133
140
  </label>
134
- {viewComponent?.disableExplorativeQuerying !== true && (
141
+ {showAdvancedMode && viewComponent?.disableExplorativeQuerying !== true && (
135
142
  <>
136
143
  <Switch
137
144
  checked={advancedModeForQueryBrowser}
138
145
  onChange={() => {
139
- setAdvancedModeForQueryBrowser(!advancedModeForQueryBrowser);
140
- setQueryBrowserMode(advancedModeForQueryBrowser ? 'simple' : 'advanced');
146
+ setAdvancedModeForQueryBrowser?.(!advancedModeForQueryBrowser);
147
+ setQueryBrowserMode?.(advancedModeForQueryBrowser ? 'simple' : 'advanced');
141
148
  }}
142
149
  className={`${
143
150
  advancedModeForQueryBrowser ? 'bg-indigo-600' : 'bg-gray-400 dark:bg-gray-800'
@@ -164,36 +171,12 @@ export function QueryControls({
164
171
  {viewComponent?.disableExplorativeQuerying === true &&
165
172
  viewComponent?.labelnames !== undefined &&
166
173
  viewComponent?.labelnames.length >= 1 ? (
167
- <ViewMatchers
168
- labelNames={viewComponent.labelnames}
169
- setMatchersString={setMatchersString}
170
- profileType={selectedProfileName}
171
- runQuery={setQueryExpression}
172
- currentQuery={query}
173
- queryClient={queryClient}
174
- start={timeRangeSelection.getFromMs()}
175
- end={timeRangeSelection.getToMs()}
176
- />
177
- ) : advancedModeForQueryBrowser ? (
178
- <MatchersInput
179
- setMatchersString={setMatchersString}
180
- runQuery={setQueryExpression}
181
- currentQuery={query}
182
- profileType={selectedProfileName}
183
- queryClient={queryClient}
184
- start={timeRangeSelection.getFromMs()}
185
- end={timeRangeSelection.getToMs()}
186
- />
174
+ <ViewMatchers labelNames={viewComponent.labelnames} />
175
+ ) : showAdvancedMode && advancedModeForQueryBrowser ? (
176
+ <MatchersInput />
187
177
  ) : (
188
178
  <SimpleMatchers
189
- setMatchersString={setMatchersString}
190
- runQuery={setQueryExpression}
191
- currentQuery={query}
192
- profileType={selectedProfileName}
193
- queryBrowserRef={queryBrowserRef}
194
- queryClient={queryClient}
195
- start={timeRangeSelection.getFromMs()}
196
- end={timeRangeSelection.getToMs()}
179
+ queryBrowserRef={actualQueryBrowserRef}
197
180
  searchExecutedTimestamp={searchExecutedTimestamp}
198
181
  />
199
182
  )}
@@ -216,9 +199,9 @@ export function QueryControls({
216
199
  options={labels.map(label => ({label, value: label}))}
217
200
  className="parca-select-container text-sm w-full max-w-80"
218
201
  classNamePrefix="parca-select"
219
- value={(sumBySelection ?? []).map(sumBy => ({label: sumBy, value: sumBy}))}
202
+ value={sumBySelection.map(sumBy => ({label: sumBy, value: sumBy}))}
220
203
  onChange={newValue => {
221
- setUserSumBySelection(newValue.map(option => option.value));
204
+ setUserSumBySelection?.(newValue.map(option => option.value));
222
205
  }}
223
206
  placeholder="Labels..."
224
207
  styles={{
@@ -232,14 +215,13 @@ export function QueryControls({
232
215
  minWidth: '320px',
233
216
  position: 'absolute',
234
217
  }),
235
- // menu: provided => ({...provided, width: 'max-content', zIndex: 50}), // Setting the same zIndex as drop down menus
236
218
  }}
237
219
  isLoading={sumBySelectionLoading}
238
- isDisabled={!profileType.delta}
220
+ isDisabled={!(profileType as ProfileType)?.delta}
239
221
  // @ts-expect-error
240
222
  ref={sumByRef}
241
223
  onKeyDown={e => {
242
- const currentRef = sumByRef.current as unknown as SelectInstance | null;
224
+ const currentRef = sumByRef?.current as unknown as SelectInstance | null;
243
225
  if (currentRef == null) {
244
226
  return;
245
227
  }
@@ -257,7 +239,7 @@ export function QueryControls({
257
239
  currentRef.blur();
258
240
  }
259
241
  }}
260
- onRefresh={refreshLabelNames}
242
+ onRefresh={refetchLabelNames}
261
243
  refreshTitle="Refresh label names"
262
244
  refreshTestId="sum-by-refresh-button"
263
245
  menuTestId={TEST_IDS.SUM_BY_SELECT_FLYOUT}
@@ -377,7 +377,7 @@ const CustomSelect: React.FC<CustomSelectProps & Record<string, any>> = ({
377
377
  <RefreshButton
378
378
  onClick={() => void handleRefetch()}
379
379
  disabled={isRefetching}
380
- title="Refresh label values"
380
+ title="Refresh results"
381
381
  testId={TEST_IDS.LABEL_VALUE_REFRESH_BUTTON}
382
382
  sticky={true}
383
383
  loading={isRefetching}