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);

Check warning on line 60 in src/plugins/data/public/ui/dataset_selector/configurator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_selector/configurator.tsx#L56-L60

Added lines #L56 - L60 were not covered by tests

useEffect(() => {

Check warning on line 62 in src/plugins/data/public/ui/dataset_selector/configurator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_selector/configurator.tsx#L62

Added line #L62 was not covered by tests
setLanguages(type?.supportedLanguages(dataset) || []);
Expand All @@ -75,9 +75,9 @@ export const Configurator = ({
useEffect(() => {
const getIndexedViews = async () => {

Check warning on line 76 in src/plugins/data/public/ui/dataset_selector/configurator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_selector/configurator.tsx#L75-L76

Added lines #L75 - L76 were not covered by tests
if (indexedViewsService) {
setLoadingIndexedViews(true);
setIsLoadingIndexedViews(true);
const fetchedIndexedViews = await indexedViewsService.getIndexedViews(baseDataset);
setLoadingIndexedViews(false);
setIsLoadingIndexedViews(false);

Check warning on line 80 in src/plugins/data/public/ui/dataset_selector/configurator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_selector/configurator.tsx#L78-L80

Added lines #L78 - L80 were not covered by tests
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 }) => ({

Check warning on line 176 in src/plugins/data/public/ui/dataset_selector/configurator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_selector/configurator.tsx#L176

Added line #L176 was not covered by tests
text: name,
value: name,
Expand Down

0 comments on commit 8d7f5e5

Please sign in to comment.