Skip to content

Commit

Permalink
fix(gui): add progress bar to menus while loading (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 18, 2023
1 parent f336cc5 commit 0ab52f0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gui/src/components/input/QueryList.tsx
@@ -1,5 +1,5 @@
import { doesExist, mustDefault, mustExist } from '@apextoaster/js-utils';
import { Alert, FormControl, InputLabel, MenuItem, Select, Typography } from '@mui/material';
import { Alert, FormControl, FormLabel, InputLabel, LinearProgress, MenuItem, Select, Typography } from '@mui/material';
import * as React from 'react';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -50,6 +50,7 @@ export function filterQuery<T>(query: QueryListComplete | QueryListFilter<T>, sh
export function QueryList<T>(props: QueryListProps<T>) {
const { labelKey, query, showEmpty = false, value } = props;
const { result } = query;
const labelID = `query-list-${props.id}-labels`;

const { t } = useTranslation();

Expand Down Expand Up @@ -86,15 +87,17 @@ export function QueryList<T>(props: QueryListProps<T>) {
}

if (result.status === 'loading') {
return <Typography>{t('input.list.loading')}</Typography>;
return <FormControl>
<FormLabel id={labelID}>{props.name}</FormLabel>
<LinearProgress />
</FormControl>;
}

if (result.status === 'idle') {
return <Typography>{t('input.list.idle')}</Typography>;
}

// else: success
const labelID = `query-list-${props.id}-labels`;
const data = filterQuery(query, showEmpty);

return <FormControl>
Expand Down

0 comments on commit 0ab52f0

Please sign in to comment.