@parca/profile 0.19.62 → 0.19.64

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.
@@ -172,6 +172,7 @@ const SimpleMatchers = ({
172
172
  },
173
173
  {meta: metadata}
174
174
  ).response;
175
+ console.log('Fetched label values:', response.labelValues);
175
176
  const sanitizedValues = sanitizeLabelValue(response.labelValues);
176
177
  return sanitizedValues;
177
178
  }
@@ -203,7 +204,12 @@ const SimpleMatchers = ({
203
204
  [setMatchersString]
204
205
  );
205
206
 
206
- const {labelNameOptions, isLoading: labelNamesLoading, refetchLabelValues} = useLabels();
207
+ const {
208
+ labelNameOptions,
209
+ isLoading: labelNamesLoading,
210
+ refetchLabelValues,
211
+ refetchLabelNames,
212
+ } = useLabels();
207
213
 
208
214
  // Helper to ensure selected label name is in the options (for page load before API returns)
209
215
  const getLabelNameOptionsWithSelected = useCallback(
@@ -451,6 +457,7 @@ const SimpleMatchers = ({
451
457
  loading={labelNamesLoading}
452
458
  searchable={true}
453
459
  {...testId(TEST_IDS.LABEL_NAME_SELECT)}
460
+ refetchValues={refetchLabelNames}
454
461
  />
455
462
  <Select
456
463
  items={operatorOptions}
@@ -478,9 +485,8 @@ const SimpleMatchers = ({
478
485
  onButtonClick={() => handleLabelValueClick(index)}
479
486
  editable={isRowRegex(row)}
480
487
  {...testId(TEST_IDS.LABEL_VALUE_SELECT)}
481
- refetchLabelValues={refetchLabelValues}
488
+ refetchValues={() => refetchLabelValues(row.labelName)}
482
489
  showLoadingInButton={true}
483
- hasRefreshButton={true}
484
490
  />
485
491
  <button
486
492
  onClick={() => removeRow(index)}
@@ -33,6 +33,7 @@ interface LabelsContextType {
33
33
  setCurrentLabelName: (name: string | null) => void;
34
34
  shouldHandlePrefixes: boolean;
35
35
  refetchLabelValues: () => void;
36
+ refetchLabelNames: () => void;
36
37
  }
37
38
 
38
39
  const LabelsContext = createContext<LabelsContextType | null>(null);
@@ -57,12 +58,11 @@ export function LabelsProvider({
57
58
  const [currentLabelName, setCurrentLabelName] = React.useState<string | null>(null);
58
59
  const utilizationLabels = useUtilizationLabels();
59
60
 
60
- const {result: labelNamesResponse, loading: isLabelNamesLoading} = useLabelNames(
61
- queryClient,
62
- profileType,
63
- start,
64
- end
65
- );
61
+ const {
62
+ result: labelNamesResponse,
63
+ loading: isLabelNamesLoading,
64
+ refetch: refetchLabelNames,
65
+ } = useLabelNames(queryClient, profileType, start, end);
66
66
 
67
67
  const labelNamesFromAPI = useMemo(() => {
68
68
  return (labelNamesResponse.error === undefined || labelNamesResponse.error == null) &&
@@ -114,6 +114,7 @@ export function LabelsProvider({
114
114
  setCurrentLabelName,
115
115
  shouldHandlePrefixes,
116
116
  refetchLabelValues,
117
+ refetchLabelNames,
117
118
  }),
118
119
  [
119
120
  labelNames,
@@ -124,6 +125,7 @@ export function LabelsProvider({
124
125
  currentLabelName,
125
126
  shouldHandlePrefixes,
126
127
  refetchLabelValues,
128
+ refetchLabelNames,
127
129
  ]
128
130
  );
129
131
 
@@ -31,7 +31,8 @@ interface LabelContextValue {
31
31
  labelNameOptions: LabelNameSection[];
32
32
  isLoading: boolean;
33
33
  error: Error | null;
34
- refetchLabelValues: () => void;
34
+ refetchLabelValues: (labelName?: string) => void;
35
+ refetchLabelNames: () => void;
35
36
  }
36
37
 
37
38
  const LabelContext = createContext<LabelContextValue | null>(null);
@@ -58,7 +59,11 @@ export function LabelProvider({
58
59
  }: LabelProviderProps): JSX.Element {
59
60
  const reactQueryClient = useQueryClient();
60
61
  const utilizationLabelResponse = useUtilizationLabels();
61
- const {loading, result} = useLabelNames(queryClient, profileType, start, end);
62
+ const {
63
+ loading,
64
+ result,
65
+ refetch: refetchLabelNamesQuery,
66
+ } = useLabelNames(queryClient, profileType, start, end);
62
67
 
63
68
  const profileValues = useMemo(() => {
64
69
  const profileLabelNames =
@@ -135,26 +140,41 @@ export function LabelProvider({
135
140
  };
136
141
  }, [profileValues, utilizationValues, labelNameFromMatchers]);
137
142
 
138
- const refetchLabelValues = useCallback(() => {
139
- void reactQueryClient.refetchQueries({
140
- predicate: query => {
141
- const key = query.queryKey;
142
- return (
143
- Array.isArray(key) &&
144
- key.length === 4 &&
145
- typeof key[0] === 'string' &&
146
- key[1] === profileType
147
- );
148
- },
149
- });
150
- }, [reactQueryClient, profileType]);
143
+ const refetchLabelValues = useCallback(
144
+ (labelName?: string) => {
145
+ void reactQueryClient.refetchQueries({
146
+ predicate: query => {
147
+ const key = query.queryKey;
148
+ const matchesStructure =
149
+ Array.isArray(key) &&
150
+ key.length === 4 &&
151
+ typeof key[0] === 'string' &&
152
+ key[1] === profileType;
153
+
154
+ if (!matchesStructure) return false;
155
+
156
+ if (labelName !== undefined && labelName !== '') {
157
+ return key[0] === labelName;
158
+ }
159
+
160
+ return true;
161
+ },
162
+ });
163
+ },
164
+ [reactQueryClient, profileType]
165
+ );
166
+
167
+ const refetchLabelNames = useCallback(() => {
168
+ refetchLabelNamesQuery();
169
+ }, [refetchLabelNamesQuery]);
151
170
 
152
171
  const contextValue = useMemo(
153
172
  () => ({
154
173
  ...value,
155
174
  refetchLabelValues,
175
+ refetchLabelNames,
156
176
  }),
157
- [value, refetchLabelValues]
177
+ [value, refetchLabelValues, refetchLabelNames]
158
178
  );
159
179
 
160
180
  return <LabelContext.Provider value={contextValue}>{children}</LabelContext.Provider>;