Skip to content

Commit

Permalink
Fix everything in mds refresh
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Jul 19, 2024
1 parent 074b959 commit 77b3d5e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,7 @@ export const useLoadToCache = (
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
pollingResult,
pollingError,
currentDataSourceName,
currentDatabaseName,
currentTableName,
loadCacheType,
stopLoading,
]);
}, [pollingResult, pollingError]);

return { loadStatus, startLoading, stopLoading };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class CatalogCacheManager {
dataSource: CachedAccelerationByDataSource,
dataSourceMDSId?: string
): void {
let index;
let index = -1;
const accCacheData = this.getAccelerationsCache();
if (dataSourceMDSId) {
index = accCacheData.dataSources.findIndex(
Expand All @@ -97,8 +97,7 @@ export class CatalogCacheManager {
);
} else {
index = accCacheData.dataSources.findIndex(
(ds: CachedAccelerationByDataSource) =>
ds.name === dataSource.name && ds.dataSourceMDSId === dataSourceMDSId
(ds: CachedAccelerationByDataSource) => ds.name === dataSource.name
);
}
if (index !== -1) {
Expand Down Expand Up @@ -128,7 +127,6 @@ export class CatalogCacheManager {
} else {
cachedDataSource = accCacheData.dataSources.find((ds) => ds.name === dataSourceName);
}

if (cachedDataSource) return cachedDataSource;
else {
let defaultDataSourceObject: CachedAccelerationByDataSource = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const AccelerationTable = ({

useEffect(() => {
const cachedDataSource = CatalogCacheManager.getOrCreateAccelerationsByDataSource(
dataSourceName
dataSourceName,
dataSourceMDSId
);
if (
cachedDataSource.status === CachedDataSourceStatus.Empty &&
Expand All @@ -102,12 +103,14 @@ export const AccelerationTable = ({
setAccelerations(cachedDataSource.accelerations);
setUpdatedTime(cachedDataSource.lastUpdated);
}
}, [accelerationsLoadStatus, dataSourceName, startLoadingAccelerations]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (accelerationsLoadStatus === DirectQueryLoadingStatus.SUCCESS) {
const cachedDataSource = CatalogCacheManager.getOrCreateAccelerationsByDataSource(
dataSourceName
dataSourceName,
dataSourceMDSId
);
setAccelerations(cachedDataSource.accelerations);
setUpdatedTime(cachedDataSource.lastUpdated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = (props)
}
const accelerationsCache = CatalogCacheManager.getOrCreateAccelerationsByDataSource(
datasource.name
// dataSourceMDSId
);
if (
(databaseCache.status === CachedDataSourceStatus.Empty ||
Expand Down Expand Up @@ -273,6 +274,7 @@ export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = (props)
const accelerationsStatus = accelerationsLoadStatus.toLowerCase();
const accelerationsCache = CatalogCacheManager.getOrCreateAccelerationsByDataSource(
datasource.name
// dataSourceMDSId
);
if (tablesStatus === DirectQueryLoadingStatus.SUCCESS) {
setCachedTables(databaseCache.tables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ export const AccessControlTab = (props: AccessControlTabProps) => {
const { http } = useOpenSearchDashboards<DataSourceManagementContext>().services;

useEffect(() => {
http!
.get(SECURITY_ROLES)
.then((data) =>
setRoles(
Object.keys(data.data).map((key) => {
return { label: key };
})
)
)
.catch((err) => setHasSecurityAccess(false));
// http!
// .get(SECURITY_ROLES)
// .then((data) =>
// setRoles(
// Object.keys(data.data).map((key) => {
// return { label: key };
// })
// )
// )
// .catch((err) => setHasSecurityAccess(false));
}, [http]);

const [selectedQueryPermissionRoles, setSelectedQueryPermissionRoles] = useState<Role[]>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,20 @@ export async function mountManagementSection(
<Route path={['/configure/:type']}>
<ConfigureDirectQueryDataSourceWithRouter notifications={notifications} />
</Route>
{featureFlagStatus && (
<Route path={['/:id']}>
<EditDataSourceWithRouter />
</Route>
)}
<Route path={['/manage/:dataSourceName']}>
<DirectQueryDataConnectionDetail
featureFlagStatus={featureFlagStatus}
http={http}
notifications={notifications}
savedObjects={savedObjects}
uiSettings={uiSettings}
setBreadcrumbs={params.setBreadcrumbs}
application={application}
/>
</Route>
{featureFlagStatus && (
<Route path={['/:id']}>
<EditDataSourceWithRouter />
</Route>
)}
<Route path={['/']}>
<DataSourceHomePanel history={params.history} featureFlagStatus={featureFlagStatus} />
</Route>
Expand Down

0 comments on commit 77b3d5e

Please sign in to comment.