BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9b03ed0a
Commit
9b03ed0a
authored
May 10, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'search-restrict-projects-to-group' into 'master'
Filter projects by group on search page Closes #29489 See merge request !11169
parents
a24e8bfc
d891e5f7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
9 deletions
+50
-9
search.js
app/assets/javascripts/search.js
+26
-8
_filter.html.haml
app/views/search/_filter.html.haml
+1
-1
search-restrict-projects-to-group.yml
changelogs/unreleased/search-restrict-projects-to-group.yml
+4
-0
search_spec.rb
spec/features/search_spec.rb
+19
-0
No files found.
app/assets/javascripts/search.js
View file @
9b03ed0a
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, object-shorthand, prefer-arrow-callback, comma-dangle, prefer-template, quotes, no-else-return, max-len */
/* global Flash */
/* global Api */
(
function
()
{
...
...
@@ -7,6 +8,7 @@
var
$groupDropdown
,
$projectDropdown
;
$groupDropdown
=
$
(
'.js-search-group-dropdown'
);
$projectDropdown
=
$
(
'.js-search-project-dropdown'
);
this
.
groupId
=
$groupDropdown
.
data
(
'group-id'
);
this
.
eventListeners
();
$groupDropdown
.
glDropdown
({
selectable
:
true
,
...
...
@@ -46,14 +48,18 @@
search
:
{
fields
:
[
'name'
]
},
data
:
function
(
term
,
callback
)
{
return
Api
.
projects
(
term
,
{
order_by
:
'id'
},
function
(
data
)
{
data
.
unshift
({
name_with_namespace
:
'Any'
});
data
.
splice
(
1
,
0
,
'divider'
);
return
callback
(
data
);
});
data
:
(
term
,
callback
)
=>
{
this
.
getProjectsData
(
term
)
.
then
((
data
)
=>
{
data
.
unshift
({
name_with_namespace
:
'Any'
});
data
.
splice
(
1
,
0
,
'divider'
);
return
data
;
})
.
then
(
data
=>
callback
(
data
))
.
catch
(()
=>
new
Flash
(
'Error fetching projects'
));
},
id
:
function
(
obj
)
{
return
obj
.
id
;
...
...
@@ -95,6 +101,18 @@
return
$
(
'.js-search-input'
).
val
(
''
).
trigger
(
'keyup'
).
focus
();
};
Search
.
prototype
.
getProjectsData
=
function
(
term
)
{
return
new
Promise
((
resolve
)
=>
{
if
(
this
.
groupId
)
{
Api
.
groupProjects
(
this
.
groupId
,
term
,
resolve
);
}
else
{
Api
.
projects
(
term
,
{
order_by
:
'id'
,
},
resolve
);
}
});
};
return
Search
;
})();
}).
call
(
window
);
app/views/search/_filter.html.haml
View file @
9b03ed0a
...
...
@@ -3,7 +3,7 @@
-
if
params
[
:project_id
].
present?
=
hidden_field_tag
:project_id
,
params
[
:project_id
]
.dropdown
%button
.dropdown-menu-toggle.js-search-group-dropdown
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
default_label:
"Group:"
}
}
%button
.dropdown-menu-toggle.js-search-group-dropdown
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
default_label:
"Group:"
,
group_id:
params
[
:group_id
]
}
}
%span
.dropdown-toggle-text
Group:
-
if
@group
.
present?
...
...
changelogs/unreleased/search-restrict-projects-to-group.yml
0 → 100644
View file @
9b03ed0a
---
title
:
Restricts search projects dropdown to group projects when group is selected
merge_request
:
author
:
spec/features/search_spec.rb
View file @
9b03ed0a
...
...
@@ -20,6 +20,7 @@ describe "Search", feature: true do
context
'search filters'
,
js:
true
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:group_project
)
{
create
(
:empty_project
,
group:
group
)
}
before
do
group
.
add_owner
(
user
)
...
...
@@ -36,6 +37,24 @@ describe "Search", feature: true do
expect
(
find
(
'.js-search-group-dropdown'
)).
to
have_content
(
group
.
name
)
end
it
'filters by group projects after filtering by group'
do
find
(
'.js-search-group-dropdown'
).
click
wait_for_ajax
page
.
within
'.search-holder'
do
click_link
group
.
name
end
expect
(
find
(
'.js-search-group-dropdown'
)).
to
have_content
(
group
.
name
)
page
.
within
(
'.project-filter'
)
do
find
(
'.js-search-project-dropdown'
).
click
wait_for_ajax
expect
(
page
).
to
have_link
(
group_project
.
name_with_namespace
)
end
end
it
'shows project name after filtering'
do
page
.
within
(
'.project-filter'
)
do
find
(
'.js-search-project-dropdown'
).
click
...
...
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