Skip to content

Commit 59f0d57

Browse files
authored
Bug fix for data-sources page (#1830)
* added fix for failing data-sources page Signed-off-by: sumukhswamy <[email protected]> * added change for job with the id Signed-off-by: sumukhswamy <[email protected]> * addressed pr comments Signed-off-by: sumukhswamy <[email protected]> * added fix for flyput Signed-off-by: sumukhswamy <[email protected]> * added fix for flyout Signed-off-by: sumukhswamy <[email protected]> * refactored the flyout objects with an interface Signed-off-by: sumukhswamy <[email protected]> --------- Signed-off-by: sumukhswamy <[email protected]>
1 parent 4ae9b2d commit 59f0d57

File tree

16 files changed

+193
-131
lines changed

16 files changed

+193
-131
lines changed

common/types/data_connections.ts

+22
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,25 @@ export interface StartLoadingParams {
252252
databaseName?: string;
253253
tableName?: string;
254254
}
255+
256+
export interface RenderAccelerationFlyoutParams {
257+
dataSource: string;
258+
dataSourceMDSId?: string;
259+
databaseName?: string;
260+
tableName?: string;
261+
handleRefresh?: () => void;
262+
}
263+
264+
export interface RenderAssociatedObjectsDetailsFlyoutParams {
265+
tableDetail: AssociatedObject;
266+
dataSourceName: string;
267+
handleRefresh?: () => void;
268+
dataSourceMDSId?: string;
269+
}
270+
271+
export interface RenderAccelerationDetailsFlyoutParams {
272+
acceleration: CachedAcceleration;
273+
dataSourceName: string;
274+
handleRefresh?: () => void;
275+
dataSourceMDSId?: string;
276+
}

public/components/datasources/components/manage/accelerations/acceleration_table.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const AccelerationTable = ({
134134
const handleRefresh = useCallback(() => {
135135
if (!isCatalogCacheFetching(accelerationsLoadStatus)) {
136136
setIsRefreshing(true);
137-
startLoadingAccelerations(dataSourceName);
137+
startLoadingAccelerations({ dataSourceName });
138138
}
139139
}, [accelerationsLoadStatus]);
140140

@@ -246,7 +246,11 @@ export const AccelerationTable = ({
246246
return (
247247
<EuiLink
248248
onClick={() => {
249-
renderAccelerationDetailsFlyout(acceleration, dataSourceName, handleRefresh);
249+
renderAccelerationDetailsFlyout({
250+
acceleration,
251+
dataSourceName,
252+
handleRefresh,
253+
});
250254
}}
251255
>
252256
{displayName}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface SelectorLoadDatabasesProps {
2424
}>
2525
>;
2626
tableFieldsLoading: boolean;
27+
dataSourceMDSId?: string;
2728
}
2829

2930
export const SelectorLoadDatabases = ({
@@ -32,6 +33,7 @@ export const SelectorLoadDatabases = ({
3233
loadingComboBoxes,
3334
setLoadingComboBoxes,
3435
tableFieldsLoading,
36+
dataSourceMDSId,
3537
}: SelectorLoadDatabasesProps) => {
3638
const [isLoading, setIsLoading] = useState(false);
3739
const {
@@ -42,7 +44,7 @@ export const SelectorLoadDatabases = ({
4244

4345
const onClickRefreshDatabases = () => {
4446
setIsLoading(true);
45-
startDatabasesLoading({ dataSourceName });
47+
startDatabasesLoading({ dataSourceName, dataSourceMDSId });
4648
};
4749

4850
useEffect(() => {

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface SelectorLoadDatabasesProps {
2929
}>
3030
>;
3131
tableFieldsLoading: boolean;
32+
dataSourceMDSId?: string;
3233
}
3334

3435
export const SelectorLoadObjects = ({
@@ -38,6 +39,7 @@ export const SelectorLoadObjects = ({
3839
loadingComboBoxes,
3940
setLoadingComboBoxes,
4041
tableFieldsLoading,
42+
dataSourceMDSId,
4143
}: SelectorLoadDatabasesProps) => {
4244
const { setToast } = useToast();
4345
const [isLoading, setIsLoading] = useState({
@@ -65,8 +67,8 @@ export const SelectorLoadObjects = ({
6567
tableStatus: true,
6668
accelerationsStatus: true,
6769
});
68-
startLoadingTables({ dataSourceName, databaseName });
69-
startLoadingAccelerations({ dataSourceName });
70+
startLoadingTables({ dataSourceName, databaseName, dataSourceMDSId });
71+
startLoadingAccelerations({ dataSourceName, dataSourceMDSId });
7072
};
7173

7274
useEffect(() => {

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const AccelerationDataSourceSelector = ({
7474
const loadDataSource = () => {
7575
setLoadingComboBoxes({ ...loadingComboBoxes, dataSource: true });
7676
http
77-
.get(DATACONNECTIONS_BASE + `/dataSourceMDSId=${dataSourceMDSId}`)
77+
.get(`${DATACONNECTIONS_BASE}/dataSourceMDSId=${dataSourceMDSId ?? ''}`)
7878
.then((res) => {
7979
const isValidDataSource = res.some(
8080
(connection: any) =>
@@ -232,6 +232,7 @@ export const AccelerationDataSourceSelector = ({
232232
loadingComboBoxes={loadingComboBoxes}
233233
setLoadingComboBoxes={setLoadingComboBoxes}
234234
tableFieldsLoading={tableFieldsLoading}
235+
dataSourceMDSId={dataSourceMDSId}
235236
/>
236237
</EuiFlexItem>
237238
</EuiFlexGroup>
@@ -281,6 +282,7 @@ export const AccelerationDataSourceSelector = ({
281282
loadingComboBoxes={loadingComboBoxes}
282283
setLoadingComboBoxes={setLoadingComboBoxes}
283284
tableFieldsLoading={tableFieldsLoading}
285+
dataSourceMDSId={dataSourceMDSId}
284286
/>
285287
</EuiFlexItem>
286288
</EuiFlexGroup>

public/components/datasources/components/manage/accelerations/utils/acceleration_utils.tsx

+15-16
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import { EuiButton, EuiHealth } from '@elastic/eui';
77
import React from 'react';
88
import { DATA_SOURCE_TYPES } from '../../../../../../../common/constants/data_sources';
9-
import { CachedAcceleration } from '../../../../../../../common/types/data_connections';
9+
import {
10+
CachedAcceleration,
11+
RenderAccelerationFlyoutParams,
12+
} from '../../../../../../../common/types/data_connections';
1013
import {
1114
redirectToExplorerOSIdx,
1215
redirectToExplorerWithDataSrc,
1316
} from '../../associated_objects/utils/associated_objects_tab_utils';
14-
1517
export const ACC_PANEL_TITLE = 'Accelerations';
1618
export const ACC_PANEL_DESC =
1719
'Accelerations optimize query performance by indexing external data into OpenSearch.';
@@ -91,26 +93,23 @@ export const CreateAccelerationFlyoutButton = ({
9193
handleRefresh,
9294
}: {
9395
dataSourceName: string;
94-
renderCreateAccelerationFlyout: (
95-
dataSource: string,
96-
dataSourceMDSId?: string,
97-
databaseName?: string,
98-
tableName?: string,
99-
handleRefresh?: () => void
100-
) => void;
96+
renderCreateAccelerationFlyout: ({
97+
dataSource,
98+
databaseName,
99+
tableName,
100+
handleRefresh,
101+
dataSourceMDSId,
102+
}: RenderAccelerationFlyoutParams) => void;
101103
handleRefresh: () => void;
102104
}) => {
103105
return (
104106
<>
105107
<EuiButton
106108
onClick={() =>
107-
renderCreateAccelerationFlyout(
108-
dataSourceName,
109-
undefined,
110-
undefined,
111-
undefined,
112-
handleRefresh
113-
)
109+
renderCreateAccelerationFlyout({
110+
dataSource: dataSourceName,
111+
handleRefresh,
112+
})
114113
}
115114
fill
116115
>

public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx

+18-15
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ export const AssociatedObjectsDetailsFlyout = ({
9393
return (
9494
<EuiButtonEmpty
9595
onClick={() =>
96-
renderCreateAccelerationFlyout(
97-
datasourceName,
98-
'',
99-
tableDetail.database,
100-
tableDetail.name,
101-
handleRefresh
102-
)
96+
renderCreateAccelerationFlyout({
97+
dataSource: datasourceName,
98+
databaseName: tableDetail.database,
99+
tableName: tableDetail.name,
100+
handleRefresh,
101+
})
103102
}
104103
>
105104
<EuiIcon type={'bolt'} size="m" />
@@ -156,7 +155,12 @@ export const AssociatedObjectsDetailsFlyout = ({
156155
return (
157156
<EuiLink
158157
onClick={() =>
159-
renderAccelerationDetailsFlyout(item, datasourceName, handleRefresh, dataSourceMDSId)
158+
renderAccelerationDetailsFlyout({
159+
acceleration: item,
160+
dataSourceName: datasourceName,
161+
handleRefresh,
162+
dataSourceMDSId,
163+
})
160164
}
161165
>
162166
{name}
@@ -196,13 +200,12 @@ export const AssociatedObjectsDetailsFlyout = ({
196200
color="primary"
197201
fill
198202
onClick={() =>
199-
renderCreateAccelerationFlyout(
200-
datasourceName,
201-
'',
202-
tableDetail.database,
203-
tableDetail.name,
204-
handleRefresh
205-
)
203+
renderCreateAccelerationFlyout({
204+
dataSource: datasourceName,
205+
databaseName: tableDetail.database,
206+
tableName: tableDetail.name,
207+
handleRefresh,
208+
})
206209
}
207210
iconType="popout"
208211
iconSide="left"

public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = (props)
100100

101101
const onRefreshButtonClick = () => {
102102
if (!isCatalogCacheFetching(databasesLoadStatus, tablesLoadStatus, accelerationsLoadStatus)) {
103-
startLoadingDatabases({ databaseName: datasource.name });
103+
startLoadingDatabases({ dataSourceName: datasource.name });
104104
setIsRefreshing(true);
105105
}
106106
};
@@ -167,7 +167,7 @@ export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = (props)
167167
datasourceCache.status === CachedDataSourceStatus.Failed) &&
168168
!isCatalogCacheFetching(databasesLoadStatus)
169169
) {
170-
startLoadingDatabases(datasource.name);
170+
startLoadingDatabases({ dataSourceName: datasource.name });
171171
} else if (datasourceCache.status === CachedDataSourceStatus.Updated) {
172172
setCachedDatabases(datasourceCache.databases);
173173
setIsFirstTimeLoading(false);
@@ -224,7 +224,7 @@ export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = (props)
224224
databaseCache.status === CachedDataSourceStatus.Failed) &&
225225
!isCatalogCacheFetching(tablesLoadStatus)
226226
) {
227-
startLoadingTables(datasource.name, selectedDatabase);
227+
startLoadingTables({ dataSourceName: datasource.name, databaseName: selectedDatabase });
228228
setIsObjectsLoading(true);
229229
} else if (databaseCache.status === CachedDataSourceStatus.Updated) {
230230
setCachedTables(databaseCache.tables);
@@ -235,7 +235,7 @@ export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = (props)
235235
isRefreshing) &&
236236
!isCatalogCacheFetching(accelerationsLoadStatus)
237237
) {
238-
startLoadingAccelerations(datasource.name);
238+
startLoadingAccelerations({ dataSourceName: datasource.name });
239239
setIsObjectsLoading(true);
240240
} else if (accelerationsCache.status === CachedDataSourceStatus.Updated) {
241241
setCachedAccelerations(accelerationsCache.accelerations);

public/components/datasources/components/manage/associated_objects/modules/associated_objects_table.tsx

+37-13
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import React, { useEffect, useState } from 'react';
76
import {
87
EuiInMemoryTable,
98
EuiLink,
10-
SearchFilterConfig,
119
EuiTableFieldDataColumnType,
10+
SearchFilterConfig,
1211
} from '@elastic/eui';
1312
import { i18n } from '@osd/i18n';
13+
import React, { useEffect, useState } from 'react';
14+
import {
15+
ACCELERATION_INDEX_TYPES,
16+
DATA_SOURCE_TYPES,
17+
} from '../../../../../../../common/constants/data_sources';
1418
import {
1519
AssociatedObject,
1620
CachedAcceleration,
@@ -20,18 +24,14 @@ import {
2024
getRenderAssociatedObjectsDetailsFlyout,
2125
getRenderCreateAccelerationFlyout,
2226
} from '../../../../../../plugin';
27+
import { getAccelerationName } from '../../accelerations/utils/acceleration_utils';
2328
import {
2429
ASSC_OBJ_TABLE_ACC_COLUMN_NAME,
2530
ASSC_OBJ_TABLE_SEARCH_HINT,
2631
ASSC_OBJ_TABLE_SUBJ,
2732
redirectToExplorerOSIdx,
2833
redirectToExplorerWithDataSrc,
2934
} from '../utils/associated_objects_tab_utils';
30-
import { getAccelerationName } from '../../accelerations/utils/acceleration_utils';
31-
import {
32-
ACCELERATION_INDEX_TYPES,
33-
DATA_SOURCE_TYPES,
34-
} from '../../../../../../../common/constants/data_sources';
3535

3636
interface AssociatedObjectsTableProps {
3737
datasourceName: string;
@@ -69,11 +69,18 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => {
6969
<EuiLink
7070
onClick={() => {
7171
if (item.type === 'table') {
72-
renderAssociatedObjectsDetailsFlyout(item, datasourceName, handleRefresh);
72+
renderAssociatedObjectsDetailsFlyout({
73+
tableDetail: item,
74+
dataSourceName: datasourceName,
75+
handleRefresh,
76+
});
7377
} else {
7478
const acceleration = cachedAccelerations.find((acc) => acc.indexName === item.id);
7579
if (acceleration) {
76-
renderAccelerationDetailsFlyout(acceleration, datasourceName);
80+
renderAccelerationDetailsFlyout({
81+
acceleration,
82+
dataSourceName: datasourceName,
83+
});
7784
}
7885
}
7986
}}
@@ -108,7 +115,11 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => {
108115
return (
109116
<EuiLink
110117
onClick={() =>
111-
renderAccelerationDetailsFlyout(accelerations[0], datasourceName, handleRefresh)
118+
renderAccelerationDetailsFlyout({
119+
acceleration: accelerations[0],
120+
dataSourceName: datasourceName,
121+
handleRefresh,
122+
})
112123
}
113124
>
114125
{name}
@@ -118,7 +129,11 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => {
118129
return (
119130
<EuiLink
120131
onClick={() =>
121-
renderAssociatedObjectsDetailsFlyout(obj, datasourceName, handleRefresh)
132+
renderAssociatedObjectsDetailsFlyout({
133+
tableDetail: obj,
134+
dataSourceName: datasourceName,
135+
handleRefresh,
136+
})
122137
}
123138
>
124139
View all {accelerations.length}
@@ -128,7 +143,11 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => {
128143
return (
129144
<EuiLink
130145
onClick={() =>
131-
renderAssociatedObjectsDetailsFlyout(accelerations, datasourceName, handleRefresh)
146+
renderAssociatedObjectsDetailsFlyout({
147+
tableDetail: accelerations,
148+
dataSourceName: datasourceName,
149+
handleRefresh,
150+
})
132151
}
133152
>
134153
{accelerations.name}
@@ -185,7 +204,12 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => {
185204
icon: 'bolt',
186205
available: (item: AssociatedObject) => item.type === 'table',
187206
onClick: (item: AssociatedObject) =>
188-
renderCreateAccelerationFlyout(datasourceName, item.database, item.name, handleRefresh),
207+
renderCreateAccelerationFlyout({
208+
dataSource: datasourceName,
209+
databaseName: item.database,
210+
tableName: item.tableName,
211+
handleRefresh,
212+
}),
189213
},
190214
],
191215
},

0 commit comments

Comments
 (0)