Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Štěpán Šonovský
bc
Commits
c2788b2c
There was an error fetching the commit references. Please try again later.
Commit
c2788b2c
authored
7 months ago
by
Štěpán Šonovský
Browse files
Options
Downloads
Patches
Plain Diff
fix: total pages deleted and added disability
parent
fb575dcc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/CommitList.tsx
+3
-3
3 additions, 3 deletions
src/app/components/CommitList.tsx
src/app/hooks/useCommits.ts
+4
-3
4 additions, 3 deletions
src/app/hooks/useCommits.ts
with
7 additions
and
6 deletions
src/app/components/CommitList.tsx
+
3
−
3
View file @
c2788b2c
...
...
@@ -4,7 +4,7 @@ import CsvButtons from "@/app/csvDownload/CsvButtons";
const
CommitList
=
({
projectId
,
token
,
host
,
onCommitClick
})
=>
{
const
[
page
,
setPage
]
=
useState
(
1
);
const
{
commits
,
loading
,
error
,
total
Page
s
}
=
useCommitsPagination
(
projectId
,
token
,
host
,
page
);
const
{
commits
,
loading
,
error
,
next
Page
}
=
useCommitsPagination
(
projectId
,
token
,
host
,
page
);
if
(
loading
)
return
<
p
>
Loading...
</
p
>;
if
(
error
)
return
<
p
>
Error:
{
error
.
message
}
</
p
>;
...
...
@@ -32,9 +32,9 @@ const CommitList = ({ projectId, token, host, onCommitClick }) => {
>
Previous
</
button
>
<
span
>
Page
{
page
}
of
{
totalPages
}
</
span
>
<
span
>
Page
{
page
}
</
span
>
<
button
disabled
=
{
page
>=
totalPages
}
disabled
=
{
nextPage
===
""
}
onClick
=
{
()
=>
setPage
(
page
+
1
)
}
className
=
"px-4 py-2 bg-blue-500 text-white rounded"
>
...
...
This diff is collapsed.
Click to expand it.
src/app/hooks/useCommits.ts
+
4
−
3
View file @
c2788b2c
...
...
@@ -36,7 +36,7 @@ export const useCommitsPagination = (projectId, token, host, page = 1, perPage =
const
[
commits
,
setCommits
]
=
useState
([]);
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
[
error
,
setError
]
=
useState
(
null
);
const
[
total
Page
s
,
set
Total
Page
s
]
=
useState
(
1
);
const
[
next
Page
,
set
Next
Page
]
=
useState
(
1
);
useEffect
(()
=>
{
const
fetchCommits
=
async
()
=>
{
...
...
@@ -47,7 +47,8 @@ export const useCommitsPagination = (projectId, token, host, page = 1, perPage =
params
:
{
page
,
per_page
:
perPage
}
});
setCommits
(
response
.
data
);
setTotalPages
(
parseInt
(
response
.
headers
[
'
x-total-pages
'
],
10
));
console
.
log
(
JSON
.
stringify
(
response
.
headers
))
setNextPage
(
response
.
headers
[
'
x-next-page
'
]);
}
catch
(
err
)
{
setError
(
err
);
}
finally
{
...
...
@@ -58,6 +59,6 @@ export const useCommitsPagination = (projectId, token, host, page = 1, perPage =
fetchCommits
();
},
[
host
,
projectId
,
token
,
page
,
perPage
]);
return
{
commits
,
loading
,
error
,
total
Page
s
};
return
{
commits
,
loading
,
error
,
next
Page
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment