Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
hive
Block Explorer UI
Commits
16168cc6
Commit
16168cc6
authored
3 months ago
by
Lukas
Committed by
mcfarhat
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Update comment search results component
parent
7f83c088
No related branches found
No related tags found
1 merge request
!499
#392_part2_simplify_URL_route_build
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/home/searches/searchesResults/CommentSearchResults.tsx
+31
-17
31 additions, 17 deletions
...ts/home/searches/searchesResults/CommentSearchResults.tsx
with
31 additions
and
17 deletions
components/home/searches/searchesResults/CommentSearchResults.tsx
+
31
−
17
View file @
16168cc6
import
Link
from
"
next/link
"
;
import
{
config
}
from
"
@/Config
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
{
Button
}
from
"
@/components//ui/button
"
;
import
CustomPagination
from
"
@/components//CustomPagination
"
;
import
JumpToPage
from
"
@/components//JumpToPage
"
;
import
OperationsTable
from
"
@/components//OperationsTable
"
;
import
{
convertCommentsOperationResultToTableOperations
}
from
"
@/lib/utils
"
;
import
{
cn
,
convertCommentsOperationResultToTableOperations
,
}
from
"
@/lib/utils
"
;
import
useOperationsFormatter
from
"
@/hooks/common/useOperationsFormatter
"
;
import
useCommentSearch
from
"
@/hooks/api/common/useCommentSearch
"
;
import
{
useSearchesContext
}
from
"
@/contexts/SearchesContext
"
;
import
{
getCommentPageLink
}
from
"
../utils/commentSearchHelpers
"
;
import
{
usePathname
}
from
"
next/navigation
"
;
const
CommentSearchResults
=
()
=>
{
const
{
commentSearchProps
,
lastSearchKey
,
commentPaginationPage
,
previousCommentSearchProps
,
setCommentSearchProps
,
setCommentPaginationPage
,
searchRanges
,
...
...
@@ -25,6 +26,9 @@ const CommentSearchResults = () => {
const
{
commentSearchData
}
=
useCommentSearch
(
commentSearchProps
);
const
formattedCommentOperations
=
useOperationsFormatter
(
commentSearchData
);
const
pathname
=
usePathname
();
const
isCommentsPage
=
pathname
?.
includes
(
"
/comments
"
)
??
false
;
if
(
!
commentSearchData
)
return
;
...
...
@@ -35,28 +39,38 @@ const CommentSearchResults = () => {
const
unformattedOperations
=
convertCommentsOperationResultToTableOperations
(
commentSearchData
.
operations_result
);
const
commentPageLink
=
getCommentPageLink
(
commentSearchProps
,
searchRanges
);
const
commentPageLink
=
getCommentPageLink
({
...
commentSearchProps
,
...
searchRanges
,
});
const
changeCommentSearchPagination
=
(
newPageNum
:
number
)
=>
{
if
(
previousCommentSearchProps
?.
accountName
)
{
const
newSearchProps
:
Explorer
.
CommentSearchProps
=
{
...
previousCommentSearchProps
,
pageNumber
:
newPageNum
,
};
setCommentSearchProps
(
newSearchProps
);
setCommentPaginationPage
(
newPageNum
);
}
const
newSearchProps
:
any
=
{
...
commentSearchProps
,
pageNumber
:
newPageNum
,
};
setCommentSearchProps
(
newSearchProps
);
setCommentPaginationPage
(
newPageNum
);
};
return
(
<>
{
commentSearchData
.
operations_result
.
length
?
(
<
div
>
<
Link
href
=
{
commentPageLink
}
>
<
Button
data-testid
=
"go-to-result-page"
>
Go to result page
</
Button
>
</
Link
>
{
!
isCommentsPage
&&
(
<
Link
href
=
{
commentPageLink
}
>
<
Button
data-testid
=
"go-to-result-page"
>
Go to result page
</
Button
>
</
Link
>
)
}
<
div
className
=
"flex justify-center items-center text-black dark:text-white"
>
<
div
className
=
{
cn
(
"
flex justify-center items-center text-black dark:text-white
"
,
{
"
mt-10
"
:
isCommentsPage
,
}
)
}
>
<
CustomPagination
currentPage
=
{
commentPaginationPage
}
totalCount
=
{
commentSearchData
.
total_operations
}
...
...
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