Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container 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
minerva
frontend
Merge requests
!32
feat: query parameters (
MIN-55
)
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
feat: query parameters (
MIN-55
)
feature/MIN-55-query-parameters
into
development
Overview
22
Commits
5
Pipelines
8
Changes
8
All threads resolved!
Show all comments
Merged
mateuszmiko
requested to merge
feature/MIN-55-query-parameters
into
development
1 year ago
Overview
22
Commits
5
Pipelines
8
Changes
8
All threads resolved!
Show all comments
Expand
Objective:
Add functionality to manage query parameters.
What has been done:
Added
useParamsQuery
hook to management query parameters
Added tests for the search bar
Added
next-router-mock
to jest config
Additionally:
Added tests for search reducer
0
0
Merge request reports
Compare
development
version 3
6727f261
1 year ago
version 2
cce3deb7
1 year ago
version 1
b570fe00
1 year ago
development (base)
and
latest version
latest version
8223b6f3
5 commits,
1 year ago
version 3
6727f261
4 commits,
1 year ago
version 2
cce3deb7
3 commits,
1 year ago
version 1
b570fe00
2 commits,
1 year ago
8 files
+
217
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
Search (e.g. *.vue) (Ctrl+P)
src/components/FunctionalArea/TopBar/SearchBar/hooks/useParamsQuery.ts
0 → 100644
+
38
−
0
Options
import
{
useAppDispatch
}
from
'
@/redux/hooks/useAppDispatch
'
;
import
{
getSearchData
}
from
'
@/redux/search/search.thunks
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
type
{
ParsedQuery
}
from
'
query-string
'
;
import
qs
from
'
query-string
'
;
import
{
useEffect
}
from
'
react
'
;
type
UseParamsQuery
=
{
setSearchQueryInRouter
:
(
searchValue
:
string
)
=>
void
;
searchParams
:
ParsedQuery
<
string
>
;
};
export
const
useParamsQuery
=
():
UseParamsQuery
=>
{
const
router
=
useRouter
();
const
dispatch
=
useAppDispatch
();
const
path
=
router
.
asPath
;
// The number of the character from which to cut the characters from path.
const
sliceFromCharNumber
=
2
;
// The number of the character at which to end the cut string from path.
const
sliceToCharNumber
=
path
.
length
;
const
searchParams
=
qs
.
parse
(
path
.
slice
(
sliceFromCharNumber
,
sliceToCharNumber
));
const
setSearchQueryInRouter
=
(
searchValue
:
string
):
void
=>
{
const
searchQuery
=
{
search
:
searchValue
,
};
router
.
push
(
`?
${
qs
.
stringify
(
searchQuery
)}
`
);
};
+4
useEffect
(()
=>
{
if
(
searchParams
?.
search
)
dispatch
(
getSearchData
(
searchParams
.
search
as
string
));
},
[
dispatch
]);
return
{
setSearchQueryInRouter
,
searchParams
};
};
Loading