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
9ef2efde
Commit
9ef2efde
authored
Jul 11, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
26d8ef1e
43eeba04
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
4 deletions
+102
-4
app/assets/javascripts/filterable_list.js
app/assets/javascripts/filterable_list.js
+4
-2
app/assets/javascripts/projects/projects_filterable_list.js
app/assets/javascripts/projects/projects_filterable_list.js
+7
-0
app/assets/javascripts/projects_list.js
app/assets/javascripts/projects_list.js
+2
-2
changelogs/unreleased/62088-search-back.yml
changelogs/unreleased/62088-search-back.yml
+5
-0
spec/frontend/filterable_list_spec.js
spec/frontend/filterable_list_spec.js
+53
-0
spec/frontend/projects/projects_filterable_list_spec.js
spec/frontend/projects/projects_filterable_list_spec.js
+31
-0
No files found.
app/assets/javascripts/filterable_list.js
View file @
9ef2efde
...
...
@@ -17,11 +17,13 @@ export default class FilterableList {
}
getFilterEndpoint
()
{
return
`
${
this
.
filterForm
.
getAttribute
(
'
action
'
)}
?
${
$
(
this
.
filterForm
).
serialize
()}
`
;
return
this
.
getPagePath
()
;
}
getPagePath
()
{
return
this
.
getFilterEndpoint
();
const
action
=
this
.
filterForm
.
getAttribute
(
'
action
'
);
const
params
=
$
(
this
.
filterForm
).
serialize
();
return
`
${
action
}${
action
.
indexOf
(
'
?
'
)
>
0
?
'
&
'
:
'
?
'
}${
params
}
`
;
}
initSearch
()
{
...
...
app/assets/javascripts/projects/projects_filterable_list.js
0 → 100644
View file @
9ef2efde
import
FilterableList
from
'
~/filterable_list
'
;
export
default
class
ProjectsFilterableList
extends
FilterableList
{
getFilterEndpoint
()
{
return
this
.
getPagePath
().
replace
(
'
/projects?
'
,
'
/projects.json?
'
);
}
}
app/assets/javascripts/projects_list.js
View file @
9ef2efde
import
FilterableList
from
'
./
filterable_list
'
;
import
ProjectsFilterableList
from
'
./projects/projects_
filterable_list
'
;
/**
* Makes search request for projects when user types a value in the search input.
...
...
@@ -11,7 +11,7 @@ export default class ProjectsList {
const
holder
=
document
.
querySelector
(
'
.js-projects-list-holder
'
);
if
(
form
&&
filter
&&
holder
)
{
const
list
=
new
FilterableList
(
form
,
filter
,
holder
);
const
list
=
new
Projects
FilterableList
(
form
,
filter
,
holder
);
list
.
initSearch
();
}
}
...
...
changelogs/unreleased/62088-search-back.yml
0 → 100644
View file @
9ef2efde
---
title
:
Fixed back navigation for projects filter
merge_request
:
30373
author
:
type
:
fixed
spec/frontend/filterable_list_spec.js
0 → 100644
View file @
9ef2efde
import
FilterableList
from
'
~/filterable_list
'
;
import
{
getJSONFixture
,
setHTMLFixture
}
from
'
./helpers/fixtures
'
;
describe
(
'
FilterableList
'
,
()
=>
{
let
List
;
let
form
;
let
filter
;
let
holder
;
beforeEach
(()
=>
{
setHTMLFixture
(
`
<form id="project-filter-form">
<input name="name" class="js-projects-list-filter" />
</div>
<div class="js-projects-list-holder"></div>
`
);
getJSONFixture
(
'
static/projects.json
'
);
form
=
document
.
querySelector
(
'
form#project-filter-form
'
);
filter
=
document
.
querySelector
(
'
.js-projects-list-filter
'
);
holder
=
document
.
querySelector
(
'
.js-projects-list-holder
'
);
List
=
new
FilterableList
(
form
,
filter
,
holder
);
});
it
(
'
processes input parameters
'
,
()
=>
{
expect
(
List
.
filterForm
).
toEqual
(
form
);
expect
(
List
.
listFilterElement
).
toEqual
(
filter
);
expect
(
List
.
listHolderElement
).
toEqual
(
holder
);
});
describe
(
'
getPagePath
'
,
()
=>
{
it
(
'
returns properly constructed base endpoint
'
,
()
=>
{
List
.
filterForm
.
action
=
'
/foo/bar/
'
;
List
.
listFilterElement
.
value
=
'
blah
'
;
expect
(
List
.
getPagePath
()).
toEqual
(
'
/foo/bar/?name=blah
'
);
});
it
(
'
properly appends custom parameters to existing URL
'
,
()
=>
{
List
.
filterForm
.
action
=
'
/foo/bar?alpha=beta
'
;
List
.
listFilterElement
.
value
=
'
blah
'
;
expect
(
List
.
getPagePath
()).
toEqual
(
'
/foo/bar?alpha=beta&name=blah
'
);
});
});
describe
(
'
getFilterEndpoint
'
,
()
=>
{
it
(
'
returns getPagePath by default
'
,
()
=>
{
jest
.
spyOn
(
List
,
'
getPagePath
'
).
mockReturnValue
(
'
blah/blah/foo
'
);
expect
(
List
.
getFilterEndpoint
()).
toEqual
(
List
.
getPagePath
());
});
});
});
spec/frontend/projects/projects_filterable_list_spec.js
0 → 100644
View file @
9ef2efde
import
ProjectsFilterableList
from
'
~/projects/projects_filterable_list
'
;
import
{
getJSONFixture
,
setHTMLFixture
}
from
'
../helpers/fixtures
'
;
describe
(
'
ProjectsFilterableList
'
,
()
=>
{
let
List
;
let
form
;
let
filter
;
let
holder
;
beforeEach
(()
=>
{
setHTMLFixture
(
`
<form id="project-filter-form">
<input name="name" class="js-projects-list-filter" />
</div>
<div class="js-projects-list-holder"></div>
`
);
getJSONFixture
(
'
static/projects.json
'
);
form
=
document
.
querySelector
(
'
form#project-filter-form
'
);
filter
=
document
.
querySelector
(
'
.js-projects-list-filter
'
);
holder
=
document
.
querySelector
(
'
.js-projects-list-holder
'
);
List
=
new
ProjectsFilterableList
(
form
,
filter
,
holder
);
});
describe
(
'
getFilterEndpoint
'
,
()
=>
{
it
(
'
updates converts getPagePath for projects
'
,
()
=>
{
jest
.
spyOn
(
List
,
'
getPagePath
'
).
mockReturnValue
(
'
blah/projects?
'
);
expect
(
List
.
getFilterEndpoint
()).
toEqual
(
'
blah/projects.json?
'
);
});
});
});
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