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
1ddae254
Commit
1ddae254
authored
3 months ago
by
Lukas
Browse files
Options
Downloads
Patches
Plain Diff
Update comments search url build function and create global function for all url builders
parent
e2ba46ca
No related branches found
No related tags found
1 merge request
!499
#392_part2_simplify_URL_route_build
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/home/searches/utils/commentSearchHelpers.ts
+40
-40
40 additions, 40 deletions
components/home/searches/utils/commentSearchHelpers.ts
components/home/searches/utils/globalSearchHelpers.ts
+12
-0
12 additions, 0 deletions
components/home/searches/utils/globalSearchHelpers.ts
with
52 additions
and
40 deletions
components/home/searches/utils/commentSearchHelpers.ts
+
40
−
40
View file @
1ddae254
import
{
convertBooleanArrayToIds
,
convertIdsToBooleanArray
,
getPageUrlParams
,
}
from
"
@/lib/utils
"
;
import
{
dataToURL
}
from
"
@/utils/URLutils
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
{
setParamIfPositive
}
from
"
./globalSearchHelpers
"
;
export
async
function
startCommentSearch
(
commentSearchParams
:
Explorer
.
CommentSearchParams
,
...
...
@@ -27,48 +27,48 @@ export async function startCommentSearch(
}
export
function
getCommentPageLink
(
commentSearchProps
:
Explorer
.
CommentSearchProps
|
undefined
,
searchRanges
:
any
commentSearchProps
:
Explorer
.
CommentSearchProps
|
undefined
):
string
{
if
(
!
commentSearchProps
)
return
"
#
"
;
const
urlParams
:
Explorer
.
UrlParam
[]
=
[
{
paramName
:
"
fromBlock
"
,
paramValue
:
dataToURL
(
commentSearchProps
.
fromBlock
),
},
{
paramName
:
"
toBlock
"
,
paramValue
:
dataToURL
(
commentSearchProps
.
toBlock
)
},
{
paramName
:
"
rangeSelectKey
"
,
paramValue
:
dataToURL
(
searchRanges
.
rangeSelectKey
),
},
{
paramName
:
"
lastTime
"
,
paramValue
:
dataToURL
(
searchRanges
.
lastTimeUnitValue
),
},
{
paramName
:
"
lastBlocks
"
,
paramValue
:
dataToURL
(
searchRanges
.
lastBlocksValue
),
},
{
paramName
:
"
timeUnit
"
,
paramValue
:
dataToURL
(
searchRanges
.
timeUnitSelectKey
),
},
{
paramName
:
"
permlink
"
,
paramValue
:
dataToURL
(
commentSearchProps
.
permlink
),
},
];
if
(
commentSearchProps
.
operationTypes
)
{
urlParams
.
push
({
paramName
:
"
filters
"
,
paramValue
:
dataToURL
(
convertIdsToBooleanArray
(
commentSearchProps
.
operationTypes
)
),
});
const
{
fromBlock
,
toBlock
,
permlink
,
operationTypes
,
accountName
,
rangeSelectKey
,
lastTimeUnitValue
,
lastBlocksValue
,
timeUnitSelectKey
,
}
=
commentSearchProps
;
const
searchParams
=
new
URLSearchParams
();
setParamIfPositive
(
searchParams
,
"
fromBlock
"
,
fromBlock
);
setParamIfPositive
(
searchParams
,
"
toBlock
"
,
toBlock
);
setParamIfPositive
(
searchParams
,
"
rangeSelectKey
"
,
rangeSelectKey
);
setParamIfPositive
(
searchParams
,
"
permlink
"
,
permlink
);
if
(
operationTypes
)
{
setParamIfPositive
(
searchParams
,
"
filters
"
,
convertIdsToBooleanArray
(
operationTypes
)
);
}
return
`/comments/@
${
dataToURL
(
commentSearchProps
.
accountName
)}${
getPageUrlParams
(
urlParams
)}
`
;
if
(
rangeSelectKey
===
"
lastTime
"
)
{
setParamIfPositive
(
searchParams
,
"
lastTime
"
,
lastTimeUnitValue
);
setParamIfPositive
(
searchParams
,
"
timeUnit
"
,
timeUnitSelectKey
);
}
else
if
(
rangeSelectKey
===
"
lastBlocks
"
)
{
setParamIfPositive
(
searchParams
,
"
lastBlocks
"
,
lastBlocksValue
);
}
const
queryString
=
searchParams
.
toString
();
const
urlPath
=
`/comments/@
${
dataToURL
(
accountName
)}${
queryString
?
`?
${
queryString
}
`
:
""
}
`
;
return
urlPath
;
}
This diff is collapsed.
Click to expand it.
components/home/searches/utils/globalSearchHelpers.ts
0 → 100644
+
12
−
0
View file @
1ddae254
import
{
dataToURL
}
from
"
@/utils/URLutils
"
;
export
function
setParamIfPositive
(
searchParams
:
URLSearchParams
,
key
:
string
,
value
:
any
)
{
const
encodedValue
=
dataToURL
(
value
);
if
(
!
encodedValue
)
return
;
searchParams
.
set
(
key
,
encodedValue
);
}
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