Skip to content

Commit

Permalink
addressed PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan committed Oct 30, 2024
1 parent 93ae981 commit 8d7f5e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/plugins/data/common/datasets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,26 @@ export interface DatasetField {
// TODO: osdFieldType?
}

export type CanvasBannerProps =
export enum DatasetCanvasBannerComponentType {
Callout = 'callout',
Custom = 'custom',
}

export type DatasetCanvasBannerProps =
| {
componentType: 'callout';
componentType: DatasetCanvasBannerComponentType.Callout;
title: string;
iconType?: string;
content?: React.ReactNode;
}
| {
componentType: 'callout';
componentType: DatasetCanvasBannerComponentType.Callout;
title?: string;
iconType?: string;
content: React.ReactNode;
}
| {
componentType: 'custom';
componentType: DatasetCanvasBannerComponentType.Custom;
content: React.ReactNode;
};

Expand Down
19 changes: 13 additions & 6 deletions src/plugins/data/public/ui/dataset_selector/configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const Configurator = ({
const indexedViewsService = type?.indexedViewsService;
const [selectedIndexedView, setSelectedIndexedView] = useState<string | undefined>();
const [indexedViews, setIndexedViews] = useState<IndexedView[]>([]);
const [loadingIndexedViews, setLoadingIndexedViews] = useState(false);
const [isLoadingIndexedViews, setIsLoadingIndexedViews] = useState(false);

useEffect(() => {
setLanguages(type?.supportedLanguages(dataset) || []);
Expand All @@ -75,9 +75,9 @@ export const Configurator = ({
useEffect(() => {
const getIndexedViews = async () => {
if (indexedViewsService) {
setLoadingIndexedViews(true);
setIsLoadingIndexedViews(true);
const fetchedIndexedViews = await indexedViewsService.getIndexedViews(baseDataset);
setLoadingIndexedViews(false);
setIsLoadingIndexedViews(false);
setIndexedViews(fetchedIndexedViews || []);
}
};
Expand All @@ -87,7 +87,7 @@ export const Configurator = ({

const submitDisabled = useMemo(() => {
return (
loadingIndexedViews ||
isLoadingIndexedViews ||
(timeFieldName === undefined &&
!(
languageService.getLanguage(selectedLanguage)?.hideDatePicker ||
Expand All @@ -96,7 +96,14 @@ export const Configurator = ({
timeFields &&
timeFields.length > 0)
);
}, [dataset, selectedLanguage, timeFieldName, timeFields, languageService, loadingIndexedViews]);
}, [
dataset,
selectedLanguage,
timeFieldName,
timeFields,
languageService,
isLoadingIndexedViews,
]);

useEffect(() => {
const fetchFields = async () => {
Expand Down Expand Up @@ -165,7 +172,7 @@ export const Configurator = ({
)}
>
<EuiSelect
isLoading={loadingIndexedViews}
isLoading={isLoadingIndexedViews}
options={indexedViews.map(({ name }) => ({
text: name,
value: name,
Expand Down

0 comments on commit 8d7f5e5

Please sign in to comment.