-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(ui/tasks): add pagination on tasks listing page #10293
Merged
chriscollins3456
merged 11 commits into
datahub-project:master
from
gaurav2733:feat/task-list-pagination
Apr 19, 2024
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3726f54
feat(ui/tasks): add pagination on tasks listing page
gaurav2733 6da8607
Merge branch 'master' into feat/task-list-pagination
gaurav2733 28fe1e4
add conditional pagination for tabname task
gaurav2733 d6e3f65
Merge branch 'master' into feat/task-list-pagination
gaurav2733 1e1bf15
Merge branch 'master' into feat/task-list-pagination
gaurav2733 8616b35
Merge branch 'master' into feat/task-list-pagination
gaurav2733 6850201
Revert "add conditional pagination for tabname task"
gaurav2733 da65e37
Revert "feat(ui/tasks): add pagination on tasks listing page"
gaurav2733 180a1a0
added new query getDataFlowChildJobs for DataFlowJobsTab and handle p…
gaurav2733 294e41a
fix Cypress test failure in schema blame unrelated to current feature…
gaurav2733 ba43e41
remove child jobs from dataflow query and fix css for pagination
gaurav2733 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 47 additions & 6 deletions
53
datahub-web-react/src/app/entity/shared/tabs/Entity/DataFlowJobsTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,60 @@ | ||
import React from 'react'; | ||
import { useBaseEntity } from '../../EntityContext'; | ||
import React, { useState } from 'react'; | ||
import { EntityType } from '../../../../../types.generated'; | ||
import { EntityList } from './components/EntityList'; | ||
import { useEntityRegistry } from '../../../../useEntityRegistry'; | ||
import { useGetDataFlowChildJobsQuery } from '../../../../../graphql/dataFlow.generated'; | ||
import { SearchCfg } from '../../../../../conf'; | ||
|
||
export const DataFlowJobsTab = () => { | ||
const entity = useBaseEntity() as any; | ||
const dataFlow = entity && entity.dataFlow; | ||
interface Props { | ||
properties?: { | ||
urn: string; | ||
}; | ||
} | ||
|
||
export const DataFlowJobsTab = ({ properties = { urn: '' } }: Props) => { | ||
const [page, setPage] = useState(1); | ||
const [numResultsPerPage, setNumResultsPerPage] = useState(SearchCfg.RESULTS_PER_PAGE); | ||
|
||
const start: number = (page - 1) * numResultsPerPage; | ||
|
||
const { data, loading, error } = useGetDataFlowChildJobsQuery({ | ||
variables: { | ||
urn: properties.urn, | ||
start, | ||
count: numResultsPerPage, | ||
}, | ||
}); | ||
|
||
const onChangePage = (newPage: number) => { | ||
setPage(newPage); | ||
}; | ||
|
||
const dataFlow = data && data?.dataFlow; | ||
const dataJobs = dataFlow?.childJobs?.relationships.map((relationship) => relationship.entity); | ||
const entityRegistry = useEntityRegistry(); | ||
const totalJobs = dataFlow?.childJobs?.total || 0; | ||
const pageSize = data?.dataFlow?.childJobs?.count || 0; | ||
const pageStart = data?.dataFlow?.childJobs?.start || 0; | ||
const lastResultIndex = pageStart + pageSize > totalJobs ? totalJobs : pageStart + pageSize; | ||
const title = `Contains ${totalJobs} ${ | ||
totalJobs === 1 | ||
? entityRegistry.getEntityName(EntityType.DataJob) | ||
: entityRegistry.getCollectionName(EntityType.DataJob) | ||
}`; | ||
return <EntityList title={title} type={EntityType.DataJob} entities={dataJobs || []} />; | ||
return ( | ||
<EntityList | ||
title={title} | ||
type={EntityType.DataJob} | ||
entities={dataJobs || []} | ||
showPagination | ||
loading={loading} | ||
error={error} | ||
totalAssets={totalJobs} | ||
page={page} | ||
pageSize={numResultsPerPage} | ||
lastResultIndex={lastResultIndex} | ||
onChangePage={onChangePage} | ||
setNumResultsPerPage={setNumResultsPerPage} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nice! as a followup we can actually remove the childJobs that we're currently getting in the main dataflow query since we're getting it now when you open the tab