Skip to content

Commit

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

* update loading state for tables fields

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* update snapshots

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

---------

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
(cherry picked from commit cffc104)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Mar 20, 2024
1 parent cb78382 commit 97be80e
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]);

Check warning on line 175 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'accelerationFormData.dataSource', 'accelerationFormData.dataTable', 'accelerationFormData.database', and 'loadColumnsToAccelerationForm'. Either include them or remove the dependency array

useEffect(() => {
return () => {
stopLoadingTableFields();

Check warning on line 179 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx#L179

Added line #L179 was not covered by tests
};
}, []);

Check warning on line 181 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'stopLoadingTableFields'. Either include it or remove the dependency array

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

Check warning on line 63 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'loadingComboBoxes' and 'setLoadingComboBoxes'. Either include them or remove the dependency array. If 'setLoadingComboBoxes' changes too often, find the parent component that defines it and wrap that definition in useCallback

useEffect(() => {
return () => {
stopDatabasesLoading();

Check warning on line 67 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx#L67

Added line #L67 was not covered by tests
};
}, []);

Check warning on line 69 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'stopDatabasesLoading'. Either include it or remove the dependency array

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

Check warning on line 98 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'loadingComboBoxes' and 'setLoadingComboBoxes'. Either include them or remove the dependency array. If 'setLoadingComboBoxes' changes too often, find the parent component that defines it and wrap that definition in useCallback

useEffect(() => {
return () => {
stopLoadingTables();
stopLoadingAccelerations();

Check warning on line 103 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx#L102-L103

Added lines #L102 - L103 were not covered by tests
};
}, []);
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 ? (
<>

Check warning on line 25 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/query_visual_editor.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/query_visual_editor.tsx#L25

Added line #L25 was not covered by tests
<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 97be80e

Please sign in to comment.