mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
feat: Loading and error states for metrics dropdown (#161)
Loading state:  Error state: 
This commit is contained in:
parent
060089d3ee
commit
f65dd9bc1c
2 changed files with 21 additions and 1 deletions
5
.changeset/calm-keys-sneeze.md
Normal file
5
.changeset/calm-keys-sneeze.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@hyperdx/app': patch
|
||||
---
|
||||
|
||||
Loading and error states for metrics dropdown
|
||||
|
|
@ -176,7 +176,7 @@ export function MetricSelect({
|
|||
setMetricName: (value: string | undefined) => void;
|
||||
}) {
|
||||
// TODO: Dedup with metric rate checkbox
|
||||
const { data: metricTagsData } = api.useMetricsTags();
|
||||
const { data: metricTagsData, isLoading, isError } = api.useMetricsTags();
|
||||
|
||||
const aggFnWithMaybeRate = (aggFn: AggFn, isRate: boolean) => {
|
||||
if (isRate) {
|
||||
|
|
@ -198,6 +198,8 @@ export function MetricSelect({
|
|||
<>
|
||||
<div className="ms-3 flex-grow-1">
|
||||
<MetricNameSelect
|
||||
isLoading={isLoading}
|
||||
isError={isError}
|
||||
value={metricName}
|
||||
setValue={name => {
|
||||
const metricType = metricTagsData?.data?.find(
|
||||
|
|
@ -259,9 +261,13 @@ export function MetricRateSelect({
|
|||
export function MetricNameSelect({
|
||||
value,
|
||||
setValue,
|
||||
isLoading,
|
||||
isError,
|
||||
}: {
|
||||
value: string | undefined | null;
|
||||
setValue: (value: string | undefined) => void;
|
||||
isLoading?: boolean;
|
||||
isError?: boolean;
|
||||
}) {
|
||||
const { data: metricTagsData } = api.useMetricsTags();
|
||||
|
||||
|
|
@ -276,6 +282,15 @@ export function MetricNameSelect({
|
|||
|
||||
return (
|
||||
<AsyncSelect
|
||||
isLoading={isLoading}
|
||||
isDisabled={isError}
|
||||
placeholder={
|
||||
isLoading
|
||||
? 'Loading...'
|
||||
: isError
|
||||
? 'Unable to load metrics'
|
||||
: 'Select a metric...'
|
||||
}
|
||||
loadOptions={input => {
|
||||
return Promise.resolve(
|
||||
options.filter(v =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue