Skip to content

Commit

Permalink
Passed loading state correctly to the view layer
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-harness committed Dec 5, 2024
1 parent fef1588 commit 473c8f4
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions apps/gitness/src/pages-v2/repo/repo-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ export default function RepoSummaryPage() {
const { spaceId, repoId } = useParams<PathParams>()
const [gitRef, setGitRef] = useState<string>('')

const { data: { body: repository } = {}, refetch: refetchRepo } = useFindRepositoryQuery({ repo_ref: repoRef })
const {
data: { body: repository } = {},
refetch: refetchRepo,
isLoading: isLoadingRepository
} = useFindRepositoryQuery({ repo_ref: repoRef })

const { data: { body: branches } = {} } = useListBranchesQuery({
const { data: { body: branches } = {}, isLoading: isLoadingBranches } = useListBranchesQuery({
repo_ref: repoRef,
queryParams: { include_commit: false, sort: 'date', order: 'asc', limit: 20, page: 1, query: '' }
})
Expand Down Expand Up @@ -85,7 +89,7 @@ export default function RepoSummaryPage() {
}))
}, [branches, repository?.default_branch])

const { data: tags } = useListTagsQuery({
const { data: tags, isLoading: isLoadingTags } = useListTagsQuery({
repo_ref: repoRef,
queryParams: {
include_commit: false,
Expand Down Expand Up @@ -126,14 +130,14 @@ export default function RepoSummaryPage() {
[navigate, repoId, spaceId, branchList, tagsList]
)

const { data: { body: repoSummary } = {} } = useSummaryQuery({
const { data: { body: repoSummary } = {}, isLoading: isLoadingSummary } = useSummaryQuery({
repo_ref: repoRef,
queryParams: { include_commit: false, sort: 'date', order: 'asc', limit: 20, page: 1, query }
})

const { branch_count, default_branch_commit_count, pull_req_summary, tag_count } = repoSummary || {}

const { data: { body: readmeContent } = {} } = useGetContentQuery({
const { data: { body: readmeContent } = {}, isLoading: isLoadingReadme } = useGetContentQuery({
path: 'README.md',
repo_ref: repoRef,
queryParams: { include_commit: false, git_ref: normalizeGitRef(gitRef || selectedBranchTag.name) }
Expand All @@ -143,7 +147,7 @@ export default function RepoSummaryPage() {
return decodeGitContent(readmeContent?.content?.data)
}, [readmeContent])

const { data: { body: repoDetails } = {} } = useGetContentQuery({
const { data: { body: repoDetails } = {}, isLoading: isLoadingRepoDetails } = useGetContentQuery({
path: '',
repo_ref: repoRef,
queryParams: { include_commit: true, git_ref: normalizeGitRef(gitRef || selectedBranchTag.name) }
Expand Down Expand Up @@ -245,7 +249,7 @@ export default function RepoSummaryPage() {
})
}, [branchList])

const { data: filesData } = useListPathsQuery({
const { data: filesData, isLoading: isLoadingPaths } = useListPathsQuery({
repo_ref: repoRef,
queryParams: { git_ref: normalizeGitRef(gitRef || selectedBranchTag.name) }
})
Expand Down Expand Up @@ -279,10 +283,20 @@ export default function RepoSummaryPage() {
[default_branch_commit_count, branch_count, tag_count, pull_req_summary]
)

const isLoading =
loading ||
isLoadingBranches ||
isLoadingPaths ||
isLoadingReadme ||
isLoadingRepoDetails ||
isLoadingRepository ||
isLoadingSummary ||
isLoadingTags

return (
<>
<RepoSummaryView
loading={loading}
loading={isLoading}
selectedBranch={selectedBranchTag}
branchList={branchList}
tagList={tagsList}
Expand Down

0 comments on commit 473c8f4

Please sign in to comment.