Skip to content

Commit

Permalink
reverted commit 19d68b2
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan authored and ps48 committed Aug 26, 2024
1 parent 59100ac commit 7c916a5
Show file tree
Hide file tree
Showing 31 changed files with 501 additions and 485 deletions.
1 change: 0 additions & 1 deletion common/constants/data_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const QUERY_ALL = 'query-all';
export const DatasourceTypeToDisplayName: { [key in DatasourceType]: string } = {
PROMETHEUS: 'Prometheus',
S3GLUE: 'Amazon S3',
SECURITYLAKE: 'Amazon Security Lake',
};

export const PrometheusURL = 'Prometheus';
Expand Down
7 changes: 3 additions & 4 deletions common/types/data_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ export interface AssociatedObject {

export type Role = EuiComboBoxOptionOption;

export type DatasourceType = 'S3GLUE' | 'PROMETHEUS' | 'SECURITYLAKE';
export type DatasourceType = 'S3GLUE' | 'PROMETHEUS';

export interface S3GlueProperties {
'glue.indexstore.opensearch.uri': string;
'glue.indexstore.opensearch.region': string;
'glue.lakeformation.enabled'?: boolean;
}

export interface PrometheusProperties {
Expand Down Expand Up @@ -251,12 +252,10 @@ export interface StartLoadingParams {
dataSourceMDSId?: string;
databaseName?: string;
tableName?: string;
dataSourceType?: DatasourceType;
}

export interface RenderAccelerationFlyoutParams {
dataSource: string;
dataSourceType: DatasourceType;
dataSourceMDSId?: string;
databaseName?: string;
tableName?: string;
Expand All @@ -266,9 +265,9 @@ export interface RenderAccelerationFlyoutParams {
export interface RenderAssociatedObjectsDetailsFlyoutParams {
tableDetail: AssociatedObject;
dataSourceName: string;
dataSourceType: DatasourceType;
handleRefresh?: () => void;
dataSourceMDSId?: string;
isS3ConnectionWithLakeFormation?: boolean;
}

export interface RenderAccelerationDetailsFlyoutParams {
Expand Down
6 changes: 0 additions & 6 deletions common/types/integrations.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
>
<CreateAccelerationFlyoutButton
dataSourceName="mock_data_source"
dataSourceType="S3GLUE"
handleRefresh={[Function]}
renderCreateAccelerationFlyout={[MockFunction]}
>
Expand Down Expand Up @@ -757,9 +756,9 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
},
]
}
dataSourceType="S3GLUE"
datasourceName="mock_data_source"
handleRefresh={[Function]}
isS3ConnectionWithLakeFormation={false}
>
<EuiInMemoryTable
columns={
Expand Down Expand Up @@ -5231,7 +5230,6 @@ exports[`AssociatedObjectsTab Component renders tab with no databases or objects
>
<CreateAccelerationFlyoutButton
dataSourceName="mock_data_source"
dataSourceType="S3GLUE"
handleRefresh={[Function]}
renderCreateAccelerationFlyout={[MockFunction]}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ exports[`Installed Integrations Table test Renders the installed integrations ta
Array [
Object {
"assets": 3,
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"locator": Object {
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"name": "aws_waf-sample",
Expand Down Expand Up @@ -460,7 +459,6 @@ exports[`Installed Integrations Table test Renders the installed integrations ta
Array [
Object {
"assets": 3,
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"locator": Object {
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"name": "aws_waf-sample",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ describe('AccelerationTable Component', () => {

it('renders without crashing', () => {
const wrapper = mount(
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
);
expect(wrapper).toBeDefined();
});
Expand All @@ -115,11 +111,7 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
);
});

Expand All @@ -140,11 +132,7 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
);
});
wrapper!.update();
Expand All @@ -164,11 +152,7 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
);
await new Promise((resolve) => setTimeout(resolve, 0));
wrapper!.update();
Expand All @@ -188,11 +172,7 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
);
});
wrapper!.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import React, { useCallback, useEffect, useState } from 'react';
import {
CachedAcceleration,
CachedDataSourceStatus,
DatasourceType,
} from '../../../../../../common/types/data_connections';
import { DirectQueryLoadingStatus } from '../../../../../../common/types/explorer';
import { CatalogCacheManager } from '../../../../../framework/catalog_cache/cache_manager';
Expand All @@ -46,7 +45,7 @@ import {
interface AccelerationTableProps {
dataSourceName: string;
cacheLoadingHooks: any;
dataSourceType: DatasourceType;
isS3ConnectionWithLakeFormation: boolean;
}

interface ModalState {
Expand All @@ -57,7 +56,7 @@ interface ModalState {
export const AccelerationTable = ({
dataSourceName,
cacheLoadingHooks,
dataSourceType,
isS3ConnectionWithLakeFormation,
}: AccelerationTableProps) => {
const [accelerations, setAccelerations] = useState<CachedAcceleration[]>([]);
const [updatedTime, setUpdatedTime] = useState<string>();
Expand Down Expand Up @@ -172,7 +171,6 @@ export const AccelerationTable = ({
<EuiFlexItem grow={false}>
<CreateAccelerationFlyoutButton
dataSourceName={dataSourceName}
dataSourceType={dataSourceType}
renderCreateAccelerationFlyout={renderCreateAccelerationFlyout}
handleRefresh={handleRefresh}
/>
Expand Down Expand Up @@ -329,12 +327,11 @@ export const AccelerationTable = ({
},
};

const accelerationTableColumns =
dataSourceType.toUpperCase() === 'SECURITYLAKE'
? Object.entries(accelerationTableColumnsCollection)
.filter(([key]) => key !== 'database' && key !== 'table')
.map(([_key, val]) => val)
: Object.values(accelerationTableColumnsCollection);
const accelerationTableColumns = !isS3ConnectionWithLakeFormation
? Object.values(accelerationTableColumnsCollection)
: Object.entries(accelerationTableColumnsCollection)
.filter(([key]) => key !== 'database' && key !== 'table')
.map(([_key, val]) => val);

const pagination = {
initialPageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ describe('Create acceleration flyout components', () => {
coreStartMock.http.get = jest.fn().mockResolvedValue(mockDatasourcesQuery);

const wrapper = mount(
<CreateAcceleration
selectedDatasource={selectedDatasource}
resetFlyout={resetFlyout}
selectedDatasourceType="S3GLUE"
/>
<CreateAcceleration selectedDatasource={selectedDatasource} resetFlyout={resetFlyout} />
);
wrapper.update();
await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import {
CachedTable,
CreateAccelerationForm,
DatasourceType,
} from '../../../../../../../../common/types/data_connections';
import { DirectQueryLoadingStatus } from '../../../../../../../../common/types/explorer';
import { useLoadTableColumnsToCache } from '../../../../../../../framework/catalog_cache/cache_loader';
Expand All @@ -40,10 +39,11 @@ import { QueryVisualEditor } from '../visual_editors/query_visual_editor';
import { CreateAccelerationButton } from './create_acceleration_button';
import { CreateAccelerationHeader } from './create_acceleration_header';
import { hasError } from './utils';
import { DATACONNECTIONS_BASE } from '../../../../../../../../common/constants/shared';
import { checkIsConnectionWithLakeFormation } from '../../../../../utils/helpers';

export interface CreateAccelerationProps {
selectedDatasource: string;
selectedDatasourceType: DatasourceType;
resetFlyout: () => void;
databaseName?: string;
tableName?: string;
Expand All @@ -53,7 +53,6 @@ export interface CreateAccelerationProps {

export const CreateAcceleration = ({
selectedDatasource,
selectedDatasourceType,
resetFlyout,
databaseName,
tableName,
Expand All @@ -62,12 +61,13 @@ export const CreateAcceleration = ({
}: CreateAccelerationProps) => {
const { setToast } = useToast();
const http = coreRefs!.http;
const [isS3ConnectionWithLakeFormation, setIsS3ConnectionWithLakeFormation] = useState(false);
const [accelerationFormData, setAccelerationFormData] = useState<CreateAccelerationForm>({
dataSource: selectedDatasource,
database: databaseName ?? '',
dataTable: tableName ?? '',
dataTableFields: [],
accelerationIndexType: selectedDatasourceType === 'SECURITYLAKE' ? 'materialized' : 'skipping',
accelerationIndexType: 'skipping',
skippingIndexQueryData: [],
coveringIndexQueryData: [],
materializedViewQueryData: {
Expand Down Expand Up @@ -170,6 +170,16 @@ export const CreateAcceleration = ({
}
};

const updateDataSourceConnectionInfo = () => {
coreRefs.http!.get(`${DATACONNECTIONS_BASE}/${selectedDatasource}`).then((data: any) => {
setIsS3ConnectionWithLakeFormation(checkIsConnectionWithLakeFormation(data));
});
};

useEffect(() => {
updateDataSourceConnectionInfo();
}, [selectedDatasource]);

useEffect(() => {
if (databaseName !== undefined && tableName !== undefined) {
initiateColumnLoad(
Expand Down Expand Up @@ -235,15 +245,14 @@ export const CreateAcceleration = ({
setDataSourceFormData: setAccelerationFormData,
}}
selectedDatasource={selectedDatasource}
selectedDataSourceType={selectedDatasourceType}
dataSourcesPreselected={dataSourcesPreselected}
tableFieldsLoading={tableFieldsLoading}
dataSourceMDSId={dataSourceMDSId}
/>
<EuiSpacer size="xxl" />
<IndexTypeSelector
accelerationFormData={accelerationFormData}
dataSourceType={selectedDatasourceType}
isS3ConnectionWithLakeFormation={isS3ConnectionWithLakeFormation}
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={initiateColumnLoad}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('Index type selector components', () => {
const wrapper = mount(
<IndexTypeSelector
accelerationFormData={accelerationFormData}
dataSourceType="S3GLUE"
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={jest.fn()}
loading={false}
/>
);
wrapper.update();
Expand All @@ -46,9 +46,9 @@ describe('Index type selector components', () => {
const wrapper = mount(
<IndexTypeSelector
accelerationFormData={accelerationFormData}
dataSourceType="S3GLUE"
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={jest.fn()}
loading={true}
/>
);
wrapper.update();
Expand Down
Loading

0 comments on commit 7c916a5

Please sign in to comment.