Skip to content

Commit

Permalink
Update loading state for tables fields in create acceleration flyout (o…
Browse files Browse the repository at this point in the history
…pensearch-project#1576) (opensearch-project#1578)

* update loading state for tables fields



* update snapshots



---------


(cherry picked from commit cffc104)

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 88a58e6 commit d969106
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 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 @@ -244,7 +244,7 @@ Array [
aria-describedby="random_html_id-help-0"
aria-haspopup="true"
aria-labelledby="random_html_id random_html_id"
className="euiSuperSelectControl euiSuperSelectControl-isLoading"
className="euiSuperSelectControl"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
Expand All @@ -256,9 +256,6 @@ Array [
<div
className="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<span
className="euiLoadingSpinner euiLoadingSpinner--medium"
/>
<span
className="euiFormControlLayoutCustomIcon"
>
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 d969106

Please sign in to comment.