Skip to content

Commit

Permalink
update loading state for tables fields
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 committed Mar 19, 2024
1 parent 73899a2 commit 4f9d7b3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== '') {
Expand Down Expand Up @@ -163,6 +174,12 @@ export const CreateAcceleration = ({
}
}, [loadStatus]);

useEffect(() => {
return () => {
stopLoadingTableFields();
};
}, []);

const dataSourcesPreselected = databaseName !== undefined && tableName !== undefined;

return (
Expand Down Expand Up @@ -191,7 +208,6 @@ export const CreateAcceleration = ({
accelerationFormData={accelerationFormData}
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={initiateColumnLoad}
loading={tableFieldsLoading}
/>
<EuiSpacer size="xxl" />
<IndexSettingOptions
Expand All @@ -202,6 +218,7 @@ export const CreateAcceleration = ({
<QueryVisualEditor
accelerationFormData={accelerationFormData}
setAccelerationFormData={setAccelerationFormData}
tableFieldsLoading={tableFieldsLoading}
/>
<EuiSpacer size="xxl" />
<IndexAdvancedSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ interface IndexTypeSelectorProps {
accelerationFormData: CreateAccelerationForm;
setAccelerationFormData: React.Dispatch<React.SetStateAction<CreateAccelerationForm>>;
initiateColumnLoad: (dataSource: string, database: string, dataTable: string) => void;
loading: boolean;
}

export const IndexTypeSelector = ({
accelerationFormData,
setAccelerationFormData,
initiateColumnLoad,
loading,
}: IndexTypeSelectorProps) => {
const [value, setValue] = useState('skipping');

Expand Down Expand Up @@ -116,7 +114,6 @@ export const IndexTypeSelector = ({
onChange={onChangeSupeSelect}
itemLayoutAlign="top"
hasDividers
isLoading={loading}
/>
</EuiFormRow>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const SelectorLoadDatabases = ({
const {
loadStatus: loadDatabasesStatus,
startLoading: startDatabasesLoading,
stopLoading: _stopDatabasesLoading,
stopLoading: stopDatabasesLoading,
} = useLoadDatabasesToCache();

const onClickRefreshDatabases = () => {
Expand All @@ -62,6 +62,12 @@ export const SelectorLoadDatabases = ({
setLoadingComboBoxes({ ...loadingComboBoxes, database: isLoading });
}, [isLoading]);

useEffect(() => {
return () => {
stopDatabasesLoading();
};
}, []);

return (
<>
{isLoading ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -97,6 +97,12 @@ export const SelectorLoadObjects = ({
setLoadingComboBoxes({ ...loadingComboBoxes, dataTable: isEitherLoading });
}, [isEitherLoading]);

useEffect(() => {
return () => {
stopLoadingTables();
stopLoadingAccelerations();
};
}, []);
return (
<>
{isEitherLoading ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -13,13 +13,25 @@ import { SkippingIndexBuilder } from './skipping_index/skipping_index_builder';
interface QueryVisualEditorProps {
accelerationFormData: CreateAccelerationForm;
setAccelerationFormData: React.Dispatch<React.SetStateAction<CreateAccelerationForm>>;
tableFieldsLoading: boolean;
}

export const QueryVisualEditor = ({
accelerationFormData,
setAccelerationFormData,
tableFieldsLoading,
}: QueryVisualEditorProps) => {
return (
return tableFieldsLoading ? (
<>
<EuiFlexGroup alignItems="center" gutterSize="s" direction="column">
<EuiSpacer />
<EuiFlexItem>
<EuiLoadingSpinner size="l" />
</EuiFlexItem>
<EuiFlexItem grow={false}>Loading tables fields</EuiFlexItem>
</EuiFlexGroup>
</>
) : (
<>
<EuiSpacer size="l" />
{accelerationFormData.accelerationIndexType === 'skipping' && (
Expand Down

0 comments on commit 4f9d7b3

Please sign in to comment.