-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fixes #27162: table version history shows current datatype instead of historical one #27478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b2ee2a7
e5bb63c
3a523f0
b76028b
0bc5ac7
d4475c5
2c4882f
640ab1a
c8fc9f4
b5d3ddf
321ecb3
587d905
4cee579
5e1e688
ac888bf
d476859
8bc459a
915a833
5b3a4b7
10edf3c
e8c7731
0538240
89759d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,6 @@ import { | |
| import { Operation } from '../../../generated/entity/policies/policy'; | ||
| import { TagSource } from '../../../generated/type/tagLabel'; | ||
| import { usePaging } from '../../../hooks/paging/usePaging'; | ||
| import { useFqn } from '../../../hooks/useFqn'; | ||
| import { | ||
| getTableColumnsByFQN, | ||
| searchTableColumnsByFQN, | ||
| } from '../../../rest/tableAPI'; | ||
| import { getPartialNameFromTableFQN } from '../../../utils/CommonUtils'; | ||
| import { | ||
| getColumnsDataWithVersionChanges, | ||
|
|
@@ -45,6 +40,7 @@ import { | |
| getEntityVersionByField, | ||
| getEntityVersionTags, | ||
| } from '../../../utils/EntityVersionUtils'; | ||
| import { searchInColumns } from '../../../utils/EntityUtils'; | ||
| import { getPrioritizedViewPermission } from '../../../utils/PermissionsUtils'; | ||
| import { getVersionPath } from '../../../utils/RouterUtils'; | ||
| import { pruneEmptyChildren } from '../../../utils/TableUtils'; | ||
|
|
@@ -89,56 +85,24 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |
| paging, | ||
| handlePagingChange, | ||
| } = usePaging(PAGE_SIZE_LARGE); | ||
| const { fqn: tableFqn } = useFqn(); | ||
| const [searchText, setSearchText] = useState(''); | ||
| // Pagination state for columns | ||
| const [tableColumns, setTableColumns] = useState<Column[]>([]); | ||
| const [columnsLoading, setColumnsLoading] = useState(true); // Start with loading state | ||
| const columnsLoading = isVersionLoading; | ||
| const [changeDescription, setChangeDescription] = useState<ChangeDescription>( | ||
| currentVersionData.changeDescription as ChangeDescription | ||
| ); | ||
|
|
||
| // Function to fetch paginated columns or search results | ||
| const fetchPaginatedColumns = useCallback( | ||
| async (page = 1, searchQuery?: string) => { | ||
| if (!tableFqn) { | ||
| return; | ||
| } | ||
| const allHistoricalColumns = useMemo( | ||
| () => pruneEmptyChildren(currentVersionData.columns) ?? [], | ||
| [currentVersionData.columns] | ||
| ); | ||
|
|
||
| setColumnsLoading(true); | ||
| try { | ||
| const offset = (page - 1) * pageSize; | ||
| const filteredHistoricalColumns = useMemo(() => { | ||
| if (!searchText) { | ||
| return allHistoricalColumns; | ||
| } | ||
|
|
||
| // Use search API if there's a search query, otherwise use regular pagination | ||
| const response = searchQuery | ||
| ? await searchTableColumnsByFQN(tableFqn, { | ||
| q: searchQuery, | ||
| limit: pageSize, | ||
| offset: offset, | ||
| fields: 'tags', | ||
| }) | ||
| : await getTableColumnsByFQN(tableFqn, { | ||
| limit: pageSize, | ||
| offset: offset, | ||
| fields: 'tags', | ||
| }); | ||
|
|
||
| setTableColumns(pruneEmptyChildren(response.data) || []); | ||
| handlePagingChange(response.paging); | ||
| } catch { | ||
| // Set empty state if API fails | ||
| setTableColumns([]); | ||
| handlePagingChange({ | ||
| offset: 1, | ||
| limit: pageSize, | ||
| total: 0, | ||
| }); | ||
| } finally { | ||
| setColumnsLoading(false); | ||
| } | ||
| }, | ||
| [tableFqn, pageSize] | ||
| ); | ||
| return searchInColumns(allHistoricalColumns, searchText); | ||
| }, [allHistoricalColumns, searchText]); | ||
|
Comment on lines
+99
to
+105
|
||
|
|
||
| const handleSearchAction = useCallback( | ||
| (searchValue: string) => { | ||
|
|
@@ -150,18 +114,17 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |
|
|
||
| const handleColumnsPageChange = useCallback( | ||
| ({ currentPage }: PagingHandlerParams) => { | ||
| fetchPaginatedColumns(currentPage, searchText); | ||
| handlePageChange(currentPage); | ||
| }, | ||
| [paging, fetchPaginatedColumns, searchText] | ||
| [handlePageChange] | ||
| ); | ||
|
|
||
| const paginationProps = useMemo( | ||
| () => ({ | ||
| currentPage, | ||
| showPagination, | ||
| isLoading: columnsLoading, | ||
| isNumberBased: Boolean(searchText), | ||
| isNumberBased: true, | ||
| pageSize, | ||
| paging, | ||
| pagingHandler: handleColumnsPageChange, | ||
|
|
@@ -171,7 +134,6 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |
| currentPage, | ||
| showPagination, | ||
| columnsLoading, | ||
| searchText, | ||
| pageSize, | ||
| paging, | ||
| handleColumnsPageChange, | ||
|
|
@@ -196,10 +158,17 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |
| [changeDescription, owners, tier, domains] | ||
| ); | ||
|
|
||
| const columns = useMemo(() => { | ||
| const colList = cloneDeep(tableColumns); | ||
| const tableColumns = useMemo(() => { | ||
| const offset = (currentPage - 1) * pageSize; | ||
|
|
||
| return filteredHistoricalColumns.slice(offset, offset + pageSize); | ||
| }, [filteredHistoricalColumns, currentPage, pageSize]); | ||
|
|
||
| return getColumnsDataWithVersionChanges<Column>(changeDescription, colList); | ||
| const columns = useMemo(() => { | ||
| return getColumnsDataWithVersionChanges<Column>( | ||
| changeDescription, | ||
| cloneDeep(tableColumns) | ||
| ); | ||
| }, [tableColumns, changeDescription]); | ||
|
Comment on lines
+161
to
172
|
||
|
|
||
| const handleTabChange = (activeKey: string) => { | ||
|
|
@@ -355,20 +324,17 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |
| ] | ||
| ); | ||
|
|
||
| // Fetch columns when search changes | ||
| useEffect(() => { | ||
| if (tableFqn && !isVersionLoading) { | ||
| // Reset to first page when search changes | ||
| fetchPaginatedColumns(currentPage, searchText || undefined); | ||
| if (isVersionLoading) { | ||
| return; | ||
| } | ||
| }, [ | ||
| isVersionLoading, | ||
| tableFqn, | ||
| searchText, | ||
| fetchPaginatedColumns, | ||
| pageSize, | ||
| currentPage, | ||
| ]); | ||
| const offset = (currentPage - 1) * pageSize; | ||
| handlePagingChange({ | ||
| offset, | ||
| limit: pageSize, | ||
| total: filteredHistoricalColumns.length, | ||
| }); | ||
| }, [isVersionLoading, filteredHistoricalColumns, currentPage, pageSize, handlePagingChange]); | ||
|
Comment on lines
327
to
+337
|
||
|
|
||
| return ( | ||
| <> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,14 +58,14 @@ function VersionTable<T extends Column | SearchIndexField>({ | |
| const [expandedRowKeys, setExpandedRowKeys] = useState<string[]>([]); | ||
|
|
||
| const data = useMemo(() => { | ||
| if (searchText) { | ||
| if (searchText && !handelSearchCallback) { | ||
|
|
||
| const searchCols = searchInColumns<T>(columns, searchText); | ||
|
|
||
| return makeData<T>(searchCols); | ||
| } else { | ||
| return makeData<T>(columns); | ||
| } | ||
| }, [searchText, columns]); | ||
|
|
||
| return makeData<T>(columns); | ||
| }, [searchText, columns, handelSearchCallback]); | ||
|
Comment on lines
+61
to
+68
|
||
|
|
||
| const renderColumnName = useCallback( | ||
| (name: T['name'], record: T) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filteredHistoricalColumnsonly matches on top-levelnameanddescription, and it is not recursive. This changes search behavior vsVersionTable’ssearchInColumns(which searchesdisplayName,dataType, and children). Consider reusing the samesearchInColumnslogic (or an equivalent recursive filter) for the full historical column tree before slicing, so nested/typed matches aren’t dropped.