Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4e07370f
Commit
4e07370f
authored
Mar 23, 2021
by
Samantha Ming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure search param is kept in scrolled commit
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/24551
parent
2054a1e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
28 deletions
+53
-28
app/assets/javascripts/pager.js
app/assets/javascripts/pager.js
+3
-2
changelogs/unreleased/24551-keep-search-param-in-commit-scroll.yml
...s/unreleased/24551-keep-search-param-in-commit-scroll.yml
+5
-0
spec/frontend/pager_spec.js
spec/frontend/pager_spec.js
+45
-26
No files found.
app/assets/javascripts/pager.js
View file @
4e07370f
...
...
@@ -16,7 +16,6 @@ export default {
callback
=
$
.
noop
,
container
=
''
,
)
{
this
.
url
=
$
(
'
.content_list
'
).
data
(
'
href
'
)
||
removeParams
([
'
limit
'
,
'
offset
'
]);
this
.
limit
=
limit
;
this
.
offset
=
parseInt
(
getParameterByName
(
'
offset
'
),
10
)
||
this
.
limit
;
this
.
disable
=
disable
;
...
...
@@ -32,8 +31,10 @@ export default {
getOld
()
{
this
.
loading
.
show
();
const
url
=
$
(
'
.content_list
'
).
data
(
'
href
'
)
||
removeParams
([
'
limit
'
,
'
offset
'
]);
axios
.
get
(
this
.
url
,
{
.
get
(
url
,
{
params
:
{
limit
:
this
.
limit
,
offset
:
this
.
offset
,
...
...
changelogs/unreleased/24551-keep-search-param-in-commit-scroll.yml
0 → 100644
View file @
4e07370f
---
title
:
Ensure search param is kept in scrolled commit
merge_request
:
57307
author
:
type
:
fixed
spec/frontend/pager_spec.js
View file @
4e07370f
...
...
@@ -32,38 +32,12 @@ describe('pager', () => {
window
.
history
.
replaceState
({},
null
,
originalHref
);
});
it
(
'
should use data-href attribute from list element
'
,
()
=>
{
const
href
=
`
${
TEST_HOST
}
/some_list.json`
;
setFixtures
(
`<div class="content_list" data-href="
${
href
}
"></div>`
);
Pager
.
init
();
expect
(
Pager
.
url
).
toBe
(
href
);
});
it
(
'
should use current url if data-href attribute not provided
'
,
()
=>
{
const
href
=
`
${
TEST_HOST
}
/some_list`
;
removeParams
.
mockReturnValue
(
href
);
Pager
.
init
();
expect
(
Pager
.
url
).
toBe
(
href
);
});
it
(
'
should get initial offset from query parameter
'
,
()
=>
{
window
.
history
.
replaceState
({},
null
,
'
?offset=100
'
);
Pager
.
init
();
expect
(
Pager
.
offset
).
toBe
(
100
);
});
it
(
'
keeps extra query parameters from url
'
,
()
=>
{
window
.
history
.
replaceState
({},
null
,
'
?filter=test&offset=100
'
);
const
href
=
`
${
TEST_HOST
}
/some_list?filter=test`
;
removeParams
.
mockReturnValue
(
href
);
Pager
.
init
();
expect
(
removeParams
).
toHaveBeenCalledWith
([
'
limit
'
,
'
offset
'
]);
expect
(
Pager
.
url
).
toEqual
(
href
);
});
});
describe
(
'
getOld
'
,
()
=>
{
...
...
@@ -164,5 +138,50 @@ describe('pager', () => {
done
();
});
});
describe
(
'
has data-href attribute from list element
'
,
()
=>
{
const
href
=
`
${
TEST_HOST
}
/some_list.json`
;
beforeEach
(()
=>
{
setFixtures
(
`<div class="content_list" data-href="
${
href
}
"></div>`
);
});
it
(
'
should use data-href attribute
'
,
()
=>
{
Pager
.
getOld
();
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
href
,
expect
.
any
(
Object
));
});
it
(
'
should not use current url
'
,
()
=>
{
Pager
.
getOld
();
expect
(
removeParams
).
not
.
toHaveBeenCalled
();
expect
(
removeParams
).
not
.
toHaveBeenCalledWith
(
href
);
});
});
describe
(
'
no data-href attribute attribute provided from list element
'
,
()
=>
{
beforeEach
(()
=>
{
setFixtures
(
`<div class="content_list"></div>`
);
});
it
(
'
should use current url
'
,
()
=>
{
const
href
=
`
${
TEST_HOST
}
/some_list`
;
removeParams
.
mockReturnValue
(
href
);
Pager
.
getOld
();
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
href
,
expect
.
any
(
Object
));
});
it
(
'
keeps extra query parameters from url
'
,
()
=>
{
window
.
history
.
replaceState
({},
null
,
'
?filter=test&offset=100
'
);
const
href
=
`
${
TEST_HOST
}
/some_list?filter=test`
;
removeParams
.
mockReturnValue
(
href
);
Pager
.
getOld
();
expect
(
removeParams
).
toHaveBeenCalledWith
([
'
limit
'
,
'
offset
'
]);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
href
,
expect
.
any
(
Object
));
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment