diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx index cd327d655..2f5895dba 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx @@ -117,9 +117,20 @@ export const CreateAcceleration = ({ }; const initiateColumnLoad = (dataSource: string, database: string, dataTable: string) => { + // All components related to table fields setAccelerationFormData({ ...accelerationFormData, dataTableFields: [], + skippingIndexQueryData: [], + coveringIndexQueryData: [], + materializedViewQueryData: { + columnsValues: [], + groupByTumbleValue: { + timeField: '', + tumbleWindow: 0, + tumbleInterval: ACCELERATION_TIME_INTERVAL[2].value, // minutes + }, + }, }); stopLoadingTableFields(); if (dataTable !== '') { @@ -163,6 +174,12 @@ export const CreateAcceleration = ({ } }, [loadStatus]); + useEffect(() => { + return () => { + stopLoadingTableFields(); + }; + }, []); + const dataSourcesPreselected = databaseName !== undefined && tableName !== undefined; return ( @@ -191,7 +208,6 @@ export const CreateAcceleration = ({ accelerationFormData={accelerationFormData} setAccelerationFormData={setAccelerationFormData} initiateColumnLoad={initiateColumnLoad} - loading={tableFieldsLoading} /> - diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx index d2bdb8e3c..64fb19e57 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx @@ -18,14 +18,12 @@ interface IndexTypeSelectorProps { accelerationFormData: CreateAccelerationForm; setAccelerationFormData: React.Dispatch>; initiateColumnLoad: (dataSource: string, database: string, dataTable: string) => void; - loading: boolean; } export const IndexTypeSelector = ({ accelerationFormData, setAccelerationFormData, initiateColumnLoad, - loading, }: IndexTypeSelectorProps) => { const [value, setValue] = useState('skipping'); @@ -116,7 +114,6 @@ export const IndexTypeSelector = ({ onChange={onChangeSupeSelect} itemLayoutAlign="top" hasDividers - isLoading={loading} /> diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx index 635cf6976..43798d715 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx @@ -37,7 +37,7 @@ export const SelectorLoadDatabases = ({ const { loadStatus: loadDatabasesStatus, startLoading: startDatabasesLoading, - stopLoading: _stopDatabasesLoading, + stopLoading: stopDatabasesLoading, } = useLoadDatabasesToCache(); const onClickRefreshDatabases = () => { @@ -62,6 +62,12 @@ export const SelectorLoadDatabases = ({ setLoadingComboBoxes({ ...loadingComboBoxes, database: isLoading }); }, [isLoading]); + useEffect(() => { + return () => { + stopDatabasesLoading(); + }; + }, []); + return ( <> {isLoading ? ( diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx index d687ef6ed..9366af2bc 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx @@ -48,12 +48,12 @@ export const SelectorLoadObjects = ({ const { loadStatus: loadTablesStatus, startLoading: startLoadingTables, - stopLoading: _stopLoadingTables, + stopLoading: stopLoadingTables, } = useLoadTablesToCache(); const { loadStatus: loadAccelerationsStatus, startLoading: startLoadingAccelerations, - stopLoading: _stopLoadingAccelerations, + stopLoading: stopLoadingAccelerations, } = useLoadAccelerationsToCache(); const onClickRefreshDatabases = () => { @@ -97,6 +97,12 @@ export const SelectorLoadObjects = ({ setLoadingComboBoxes({ ...loadingComboBoxes, dataTable: isEitherLoading }); }, [isEitherLoading]); + useEffect(() => { + return () => { + stopLoadingTables(); + stopLoadingAccelerations(); + }; + }, []); return ( <> {isEitherLoading ? ( diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/query_visual_editor.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/query_visual_editor.tsx index 6ce594ccf..5089afc2e 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/query_visual_editor.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/query_visual_editor.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { EuiSpacer } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiSpacer } from '@elastic/eui'; import React from 'react'; import { CreateAccelerationForm } from '../../../../../../../../common/types/data_connections'; import { CoveringIndexBuilder } from './covering_index/covering_index_builder'; @@ -13,13 +13,25 @@ import { SkippingIndexBuilder } from './skipping_index/skipping_index_builder'; interface QueryVisualEditorProps { accelerationFormData: CreateAccelerationForm; setAccelerationFormData: React.Dispatch>; + tableFieldsLoading: boolean; } export const QueryVisualEditor = ({ accelerationFormData, setAccelerationFormData, + tableFieldsLoading, }: QueryVisualEditorProps) => { - return ( + return tableFieldsLoading ? ( + <> + + + + + + Loading tables fields + + + ) : ( <> {accelerationFormData.accelerationIndexType === 'skipping' && (