Skip to content

Commit 208939e

Browse files
authored
ui: Fix loading state for inactive projects (#6199)
1 parent 532b9bc commit 208939e

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ interface MetricsGraphSectionProps {
4343
refreshedTimeRange?: {from: number; to: number; timeSelection: string},
4444
expression?: string
4545
) => void;
46+
profileTypesLoading?: boolean;
47+
hasNoProfileTypes?: boolean;
4648
}
4749

4850
export function MetricsGraphSection({
@@ -62,6 +64,8 @@ export function MetricsGraphSection({
6264
query,
6365
setNewQueryExpression,
6466
commitDraft,
67+
profileTypesLoading = false,
68+
hasNoProfileTypes = false,
6569
}: MetricsGraphSectionProps): JSX.Element {
6670
const resetStateOnSeriesChange = useResetStateOnSeriesChange();
6771
const batchUpdates = useURLStateBatch();
@@ -177,13 +181,15 @@ export function MetricsGraphSection({
177181
onPointClick={handlePointClick}
178182
/>
179183
</>
180-
) : (
181-
profileSelection === null && (
182-
<div className="p-2">
184+
) : profileSelection === null && !profileTypesLoading ? (
185+
<div className="p-2">
186+
{hasNoProfileTypes ? (
187+
<ProfileMetricsEmptyState message="No profiling data found in the selected time range. Try selecting a longer time range." />
188+
) : (
183189
<ProfileMetricsEmptyState message="Please select a profile type and click 'Search' to begin." />
184-
</div>
185-
)
186-
)}
190+
)}
191+
</div>
192+
) : null}
187193
</div>
188194
</>
189195
)}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ const ProfileSelector = ({
363363
setQueryExpression={setQueryExpression}
364364
setNewQueryExpression={setDraftExpression}
365365
commitDraft={commitDraft}
366+
profileTypesLoading={profileTypesLoading}
367+
hasNoProfileTypes={
368+
!profileTypesLoading &&
369+
(profileTypesData?.types == null || profileTypesData.types.length === 0)
370+
}
366371
/>
367372
</>
368373
);

ui/packages/shared/profile/src/hooks/useLabels.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const useLabelNames = (
4747
match?: string[]
4848
): UseLabelNames => {
4949
const metadata = useGrpcMetadata();
50+
const enabled = profileType !== undefined && profileType !== '';
5051

5152
const {data, isLoading, error, refetch} = useGrpcQuery<LabelsResponse>({
5253
key: ['labelNames', profileType, match?.join(','), start, end],
@@ -63,14 +64,14 @@ export const useLabelNames = (
6364
return response;
6465
},
6566
options: {
66-
enabled: profileType !== undefined && profileType !== '',
67+
enabled,
6768
keepPreviousData: false,
6869
},
6970
});
7071

7172
return {
7273
result: {response: data, error: error as Error},
73-
loading: isLoading,
74+
loading: enabled && isLoading,
7475
refetch: async () => {
7576
await refetch();
7677
},

0 commit comments

Comments
 (0)