Skip to content
GitLab
Explore
Sign in
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
Merge requests
!494
Lbudginas/
#392
part1 reduce searches component
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Lbudginas/
#392
part1 reduce searches component
lbudginas/#392_part1_reduce_searches_component
into
develop
Overview
0
Commits
10
Pipelines
1
Changes
23
Merged
Lukas Budginas
requested to merge
lbudginas/#392_part1_reduce_searches_component
into
develop
4 months ago
Overview
0
Commits
10
Pipelines
1
Changes
23
Expand
#392 (closed)
PART 1 : Reduce searches section
Changes made:
Create context for all searches used on main page
Separate searches accordion and searches results sections
Create utility functions for each search
Make updates on other components which used updated components
Test if searches section is working as expected after changes (might need more time for testing, because of code refactoring)
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
6cc45a39
10 commits,
4 months ago
23 files
+
971
−
748
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
23
Search (e.g. *.vue) (Ctrl+P)
components/home/searches/searchesResults/AccountSearchResults.tsx
0 → 100644
+
108
−
0
Options
import
{
useEffect
}
from
"
react
"
;
import
Link
from
"
next/link
"
;
import
{
config
}
from
"
@/Config
"
;
import
{
convertOperationResultsToTableOperations
}
from
"
@/lib/utils
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
OperationsTable
from
"
@/components/OperationsTable
"
;
import
JumpToPage
from
"
@/components/JumpToPage
"
;
import
CustomPagination
from
"
@/components/CustomPagination
"
;
import
{
Button
}
from
"
@/components/ui/button
"
;
import
useOperationsFormatter
from
"
@/hooks/common/useOperationsFormatter
"
;
import
{
useSearchesContext
}
from
"
@/contexts/SearchesContext
"
;
import
useAccountOperations
from
"
@/hooks/api/accountPage/useAccountOperations
"
;
import
ErrorPage
from
"
@/pages/ErrorPage
"
;
import
{
getAccountPageLink
}
from
"
../utils/accountSearchHelpers
"
;
const
AccountSearchResults
=
()
=>
{
const
{
accountOperationsSearchProps
,
setAccountOperationsPage
,
accountOperationsPage
,
previousAccountOperationsSearchProps
,
setAccountOperationsSearchProps
,
lastSearchKey
,
searchRanges
,
}
=
useSearchesContext
();
const
{
accountOperations
,
isAccountOperationsError
}
=
useAccountOperations
(
accountOperationsSearchProps
);
const
formattedAccountOperations
=
useOperationsFormatter
(
accountOperations
);
useEffect
(()
=>
{
if
(
!
accountOperationsPage
&&
accountOperations
)
{
setAccountOperationsPage
(
accountOperations
?.
total_pages
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
accountOperations
,
accountOperationsPage
]);
if
(
isAccountOperationsError
)
{
return
<
ErrorPage
/>;
}
if
(
!
accountOperations
)
return
;
const
formattedOperations
=
convertOperationResultsToTableOperations
(
formattedAccountOperations
?.
operations_result
);
const
unformattedOperations
=
convertOperationResultsToTableOperations
(
accountOperations
.
operations_result
);
const
changeAccountOperationsPagination
=
(
newPageNum
:
number
)
=>
{
if
(
previousAccountOperationsSearchProps
?.
accountName
)
{
const
newSearchProps
:
Explorer
.
AccountSearchOperationsProps
=
{
...
previousAccountOperationsSearchProps
,
pageNumber
:
newPageNum
,
};
setAccountOperationsSearchProps
(
newSearchProps
);
setAccountOperationsPage
(
newPageNum
);
}
};
const
totalOperations
=
accountOperations
.
total_operations
;
const
accountPageLink
=
getAccountPageLink
(
accountOperationsSearchProps
,
searchRanges
);
return
(
<>
{
accountOperations
.
total_operations
>
0
?
(
<
div
data-testid
=
"operations-card"
>
<
Link
href
=
{
accountPageLink
}
>
<
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"
>
<
CustomPagination
currentPage
=
{
accountOperationsPage
||
1
}
totalCount
=
{
totalOperations
}
pageSize
=
{
config
.
standardPaginationSize
}
onPageChange
=
{
changeAccountOperationsPagination
}
isMirrored
=
{
true
}
/>
</
div
>
<
div
className
=
"flex justify-end items-center mb-4"
>
<
JumpToPage
currentPage
=
{
accountOperationsPage
||
1
}
onPageChange
=
{
changeAccountOperationsPagination
}
/>
</
div
>
<
OperationsTable
operations
=
{
formattedOperations
}
unformattedOperations
=
{
unformattedOperations
}
/>
</
div
>
)
:
(
<
div
className
=
"flex justify-center w-full text-black dark:text-white"
>
No operations matching given criteria
</
div
>
)
}
</>
);
};
export
default
AccountSearchResults
;
Loading