mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 18:48:35 +00:00 
			
		
		
		
	ui: replace ES api with table list api in schema details page (#12355)
* ui: replace ES api with table list api in schema details page * updated url wait
This commit is contained in:
		
							parent
							
								
									ce89dbc94b
								
							
						
					
					
						commit
						c930427390
					
				| @ -117,7 +117,7 @@ describe('Restore entity functionality should work properly', () => { | |||||||
| 
 | 
 | ||||||
|     interceptURL( |     interceptURL( | ||||||
|       'GET', |       'GET', | ||||||
|       '/api/v1/search/query?q=*&index=table_search_index&from=0&size=10&deleted=true&sort_field=name.keyword&sort_order=asc', |       '/api/v1/tables?databaseSchema=sample_data.ecommerce_db.shopify&include=deleted', | ||||||
|       'queryDeletedTables' |       'queryDeletedTables' | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -45,10 +45,11 @@ import { | |||||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||||
| import { compare, Operation } from 'fast-json-patch'; | import { compare, Operation } from 'fast-json-patch'; | ||||||
|  | import { Include } from 'generated/type/include'; | ||||||
| import { TagLabel } from 'generated/type/tagLabel'; | import { TagLabel } from 'generated/type/tagLabel'; | ||||||
| import { isEmpty, isUndefined, startCase, toNumber } from 'lodash'; | import { isEmpty, isString, isUndefined, startCase } from 'lodash'; | ||||||
| import { observer } from 'mobx-react'; | import { observer } from 'mobx-react'; | ||||||
| import { EntityTags, ExtraInfo } from 'Models'; | import { EntityTags, ExtraInfo, PagingResponse } from 'Models'; | ||||||
| import React, { | import React, { | ||||||
|   FunctionComponent, |   FunctionComponent, | ||||||
|   useCallback, |   useCallback, | ||||||
| @ -65,7 +66,7 @@ import { | |||||||
|   restoreDatabaseSchema, |   restoreDatabaseSchema, | ||||||
| } from 'rest/databaseAPI'; | } from 'rest/databaseAPI'; | ||||||
| import { getFeedCount, postThread } from 'rest/feedsAPI'; | import { getFeedCount, postThread } from 'rest/feedsAPI'; | ||||||
| import { searchQuery } from 'rest/searchAPI'; | import { getTableList, TableListParams } from 'rest/tableAPI'; | ||||||
| import { default as appState } from '../../AppState'; | import { default as appState } from '../../AppState'; | ||||||
| import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants'; | import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants'; | ||||||
| import { | import { | ||||||
| @ -79,17 +80,12 @@ import { | |||||||
| import { EntityField } from '../../constants/Feeds.constants'; | import { EntityField } from '../../constants/Feeds.constants'; | ||||||
| import { GlobalSettingsMenuCategory } from '../../constants/GlobalSettings.constants'; | import { GlobalSettingsMenuCategory } from '../../constants/GlobalSettings.constants'; | ||||||
| import { EntityTabs, EntityType } from '../../enums/entity.enum'; | import { EntityTabs, EntityType } from '../../enums/entity.enum'; | ||||||
| import { SearchIndex } from '../../enums/search.enum'; |  | ||||||
| import { ServiceCategory } from '../../enums/service.enum'; | import { ServiceCategory } from '../../enums/service.enum'; | ||||||
| import { OwnerType } from '../../enums/user.enum'; | import { OwnerType } from '../../enums/user.enum'; | ||||||
| import { CreateThread } from '../../generated/api/feed/createThread'; | import { CreateThread } from '../../generated/api/feed/createThread'; | ||||||
| import { DatabaseSchema } from '../../generated/entity/data/databaseSchema'; | import { DatabaseSchema } from '../../generated/entity/data/databaseSchema'; | ||||||
| import { Table } from '../../generated/entity/data/table'; | import { Table } from '../../generated/entity/data/table'; | ||||||
| import { EntityFieldThreadCount } from '../../interface/feed.interface'; | import { EntityFieldThreadCount } from '../../interface/feed.interface'; | ||||||
| import { |  | ||||||
|   getQueryStringForSchemaTables, |  | ||||||
|   getTablesFromSearchResponse, |  | ||||||
| } from '../../utils/DatabaseSchemaDetailsUtils'; |  | ||||||
| import { getEntityFeedLink, getEntityName } from '../../utils/EntityUtils'; | import { getEntityFeedLink, getEntityName } from '../../utils/EntityUtils'; | ||||||
| import { getEntityFieldThreadCounts } from '../../utils/FeedUtils'; | import { getEntityFieldThreadCounts } from '../../utils/FeedUtils'; | ||||||
| import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils'; | import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils'; | ||||||
| @ -116,7 +112,10 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|     useParams<{ databaseSchemaFQN: string; tab: EntityTabs }>(); |     useParams<{ databaseSchemaFQN: string; tab: EntityTabs }>(); | ||||||
|   const [isLoading, setIsLoading] = useState(true); |   const [isLoading, setIsLoading] = useState(true); | ||||||
|   const [databaseSchema, setDatabaseSchema] = useState<DatabaseSchema>(); |   const [databaseSchema, setDatabaseSchema] = useState<DatabaseSchema>(); | ||||||
|   const [tableData, setTableData] = useState<Array<Table>>([]); |   const [tableData, setTableData] = useState<PagingResponse<Table[]>>({ | ||||||
|  |     data: [], | ||||||
|  |     paging: { total: 0 }, | ||||||
|  |   }); | ||||||
|   const [tableDataLoading, setTableDataLoading] = useState<boolean>(true); |   const [tableDataLoading, setTableDataLoading] = useState<boolean>(true); | ||||||
| 
 | 
 | ||||||
|   const [databaseSchemaName, setDatabaseSchemaName] = useState<string>( |   const [databaseSchemaName, setDatabaseSchemaName] = useState<string>( | ||||||
| @ -127,8 +126,6 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|   const [isEdit, setIsEdit] = useState(false); |   const [isEdit, setIsEdit] = useState(false); | ||||||
|   const [description, setDescription] = useState(''); |   const [description, setDescription] = useState(''); | ||||||
| 
 | 
 | ||||||
|   const [tableInstanceCount, setTableInstanceCount] = useState<number>(0); |  | ||||||
| 
 |  | ||||||
|   const [error, setError] = useState(''); |   const [error, setError] = useState(''); | ||||||
| 
 | 
 | ||||||
|   const [feedCount, setFeedCount] = useState<number>(0); |   const [feedCount, setFeedCount] = useState<number>(0); | ||||||
| @ -175,7 +172,7 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|     { |     { | ||||||
|       label: ( |       label: ( | ||||||
|         <TabsLabel |         <TabsLabel | ||||||
|           count={tableInstanceCount} |           count={tableData.paging.total} | ||||||
|           id={EntityTabs.TABLE} |           id={EntityTabs.TABLE} | ||||||
|           isActive={activeTab === EntityTabs.TABLE} |           isActive={activeTab === EntityTabs.TABLE} | ||||||
|           name={t('label.table-plural')} |           name={t('label.table-plural')} | ||||||
| @ -313,28 +310,15 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|       }); |       }); | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const getSchemaTables = async ( |   const getSchemaTables = async (params?: TableListParams) => { | ||||||
|     pageNumber: number, |  | ||||||
|     databaseSchema: DatabaseSchema |  | ||||||
|   ) => { |  | ||||||
|     setTableDataLoading(true); |     setTableDataLoading(true); | ||||||
|     try { |     try { | ||||||
|       setCurrentTablesPage(pageNumber); |       const res = await getTableList({ | ||||||
|       const res = await searchQuery({ |         ...params, | ||||||
|         query: getQueryStringForSchemaTables( |         databaseSchema: databaseSchemaFQN, | ||||||
|           databaseSchema.service, |         include: showDeletedTables ? Include.Deleted : Include.NonDeleted, | ||||||
|           databaseSchema.database, |  | ||||||
|           databaseSchema |  | ||||||
|         ), |  | ||||||
|         pageNumber, |  | ||||||
|         sortField: 'name.keyword', |  | ||||||
|         sortOrder: 'asc', |  | ||||||
|         pageSize: PAGE_SIZE, |  | ||||||
|         searchIndex: SearchIndex.TABLE, |  | ||||||
|         includeDeleted: showDeletedTables, |  | ||||||
|       }); |       }); | ||||||
|       setTableData(getTablesFromSearchResponse(res)); |       setTableData(res); | ||||||
|       setTableInstanceCount(res.hits.total.value); |  | ||||||
|     } catch (err) { |     } catch (err) { | ||||||
|       showErrorToast(err as AxiosError); |       showErrorToast(err as AxiosError); | ||||||
|     } finally { |     } finally { | ||||||
| @ -342,10 +326,15 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const tablePaginationHandler = (pageNumber: string | number) => { |   const tablePaginationHandler = ( | ||||||
|     if (!isUndefined(databaseSchema)) { |     cursorValue: string | number, | ||||||
|       getSchemaTables(toNumber(pageNumber), databaseSchema); |     activePage?: number | ||||||
|  |   ) => { | ||||||
|  |     if (isString(cursorValue)) { | ||||||
|  |       const { paging } = tableData; | ||||||
|  |       getSchemaTables({ [cursorValue]: paging[cursorValue] }); | ||||||
|     } |     } | ||||||
|  |     setCurrentTablesPage(activePage ?? INITIAL_PAGING_VALUE); | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const onCancel = () => { |   const onCancel = () => { | ||||||
| @ -532,7 +521,7 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|             bordered |             bordered | ||||||
|             columns={tableColumn} |             columns={tableColumn} | ||||||
|             data-testid="databaseSchema-tables" |             data-testid="databaseSchema-tables" | ||||||
|             dataSource={tableData} |             dataSource={tableData.data} | ||||||
|             locale={{ |             locale={{ | ||||||
|               emptyText: <FilterTablePlaceHolder />, |               emptyText: <FilterTablePlaceHolder />, | ||||||
|             }} |             }} | ||||||
| @ -542,16 +531,13 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|           /> |           /> | ||||||
|         )} |         )} | ||||||
| 
 | 
 | ||||||
|         {tableInstanceCount > PAGE_SIZE && tableData.length > 0 && ( |         {tableData.paging.total > PAGE_SIZE && tableData.data.length > 0 && ( | ||||||
|           <NextPrevious |           <NextPrevious | ||||||
|             isNumberBased |  | ||||||
|             currentPage={currentTablesPage} |             currentPage={currentTablesPage} | ||||||
|             pageSize={PAGE_SIZE} |             pageSize={PAGE_SIZE} | ||||||
|             paging={{ |             paging={tableData.paging} | ||||||
|               total: tableInstanceCount, |  | ||||||
|             }} |  | ||||||
|             pagingHandler={tablePaginationHandler} |             pagingHandler={tablePaginationHandler} | ||||||
|             totalCount={tableInstanceCount} |             totalCount={tableData.paging.total} | ||||||
|           /> |           /> | ||||||
|         )} |         )} | ||||||
|       </Col> |       </Col> | ||||||
| @ -589,8 +575,10 @@ const DatabaseSchemaPage: FunctionComponent = () => { | |||||||
|   }, [databaseSchemaPermission, databaseSchemaFQN]); |   }, [databaseSchemaPermission, databaseSchemaFQN]); | ||||||
| 
 | 
 | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     tablePaginationHandler(INITIAL_PAGING_VALUE); |     if (databaseSchemaFQN) { | ||||||
|   }, [showDeletedTables, databaseSchema]); |       getSchemaTables(); | ||||||
|  |     } | ||||||
|  |   }, [showDeletedTables, databaseSchemaFQN]); | ||||||
| 
 | 
 | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     fetchDatabaseSchemaPermission(); |     fetchDatabaseSchemaPermission(); | ||||||
|  | |||||||
| @ -570,7 +570,7 @@ const DatabaseDetails: FunctionComponent = () => { | |||||||
|         key: EntityTabs.SCHEMA, |         key: EntityTabs.SCHEMA, | ||||||
|         children: ( |         children: ( | ||||||
|           <Row gutter={[0, 16]} wrap={false}> |           <Row gutter={[0, 16]} wrap={false}> | ||||||
|             <Col className="p-t-sm m-l-lg" flex="auto"> |             <Col className="p-t-sm p-r-sm m-l-lg" flex="auto"> | ||||||
|               <div className="d-flex flex-col gap-4"> |               <div className="d-flex flex-col gap-4"> | ||||||
|                 <DescriptionV1 |                 <DescriptionV1 | ||||||
|                   description={description} |                   description={description} | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| 
 | 
 | ||||||
| import { AxiosResponse } from 'axios'; | import { AxiosResponse } from 'axios'; | ||||||
| import { Operation } from 'fast-json-patch'; | import { Operation } from 'fast-json-patch'; | ||||||
|  | import { Include } from 'generated/type/include'; | ||||||
| import { PagingResponse, RestoreRequestType } from 'Models'; | import { PagingResponse, RestoreRequestType } from 'Models'; | ||||||
| import { SystemProfile } from '../generated/api/data/createTableProfile'; | import { SystemProfile } from '../generated/api/data/createTableProfile'; | ||||||
| import { | import { | ||||||
| @ -27,6 +28,17 @@ import { Paging } from '../generated/type/paging'; | |||||||
| import { getURLWithQueryFields } from '../utils/APIUtils'; | import { getURLWithQueryFields } from '../utils/APIUtils'; | ||||||
| import APIClient from './index'; | import APIClient from './index'; | ||||||
| 
 | 
 | ||||||
|  | export type TableListParams = { | ||||||
|  |   fields?: string; | ||||||
|  |   database?: string; | ||||||
|  |   databaseSchema?: string; | ||||||
|  |   before?: string; | ||||||
|  |   after?: string; | ||||||
|  |   include?: Include; | ||||||
|  |   limit?: number; | ||||||
|  |   includeEmptyTestSuite?: boolean; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| export const getTableDetails = async ( | export const getTableDetails = async ( | ||||||
|   id: string, |   id: string, | ||||||
|   arrQueryFields: string | string[] |   arrQueryFields: string | string[] | ||||||
| @ -226,3 +238,11 @@ export const getLatestTableProfileByFqn = async (fqn: string) => { | |||||||
| 
 | 
 | ||||||
|   return response.data; |   return response.data; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | export const getTableList = async (params?: TableListParams) => { | ||||||
|  |   const response = await APIClient.get<PagingResponse<Table[]>>('/tables', { | ||||||
|  |     params, | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   return response.data; | ||||||
|  | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Shailesh Parmar
						Shailesh Parmar