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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
d6450bb2
Commit
d6450bb2
authored
Jan 30, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dz-nested-groups-improvements-2' into 'master'
Nested groups improvements pt 2 See merge request !8827
parents
4468104f
ba2d7eda
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
64 additions
and
9 deletions
+64
-9
app/assets/javascripts/groups_select.js
app/assets/javascripts/groups_select.js
+2
-2
app/assets/javascripts/search.js
app/assets/javascripts/search.js
+4
-4
app/helpers/search_helper.rb
app/helpers/search_helper.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-0
app/services/search/global_service.rb
app/services/search/global_service.rb
+4
-1
changelogs/unreleased/dz-nested-groups-improvements-2.yml
changelogs/unreleased/dz-nested-groups-improvements-2.yml
+4
-0
doc/api/groups.md
doc/api/groups.md
+12
-1
lib/api/entities.rb
lib/api/entities.rb
+1
-0
spec/helpers/search_helper_spec.rb
spec/helpers/search_helper_spec.rb
+5
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+8
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+3
-0
spec/services/search_service_spec.rb
spec/services/search_service_spec.rb
+19
-0
No files found.
app/assets/javascripts/groups_select.js
View file @
d6450bb2
...
@@ -59,11 +59,11 @@
...
@@ -59,11 +59,11 @@
}
else
{
}
else
{
avatar
=
gon
.
default_avatar_url
;
avatar
=
gon
.
default_avatar_url
;
}
}
return
"
<div class='group-result'> <div class='group-name'>
"
+
group
.
name
+
"
</div> <div class='group-path'>
"
+
group
.
path
+
"
</div> </div>
"
;
return
"
<div class='group-result'> <div class='group-name'>
"
+
group
.
full_name
+
"
</div> <div class='group-path'>
"
+
group
.
full_
path
+
"
</div> </div>
"
;
};
};
GroupsSelect
.
prototype
.
formatSelection
=
function
(
group
)
{
GroupsSelect
.
prototype
.
formatSelection
=
function
(
group
)
{
return
group
.
name
;
return
group
.
full_
name
;
};
};
return
GroupsSelect
;
return
GroupsSelect
;
...
...
app/assets/javascripts/search.js
View file @
d6450bb2
...
@@ -13,12 +13,12 @@
...
@@ -13,12 +13,12 @@
filterable
:
true
,
filterable
:
true
,
fieldName
:
'
group_id
'
,
fieldName
:
'
group_id
'
,
search
:
{
search
:
{
fields
:
[
'
name
'
]
fields
:
[
'
full_
name
'
]
},
},
data
:
function
(
term
,
callback
)
{
data
:
function
(
term
,
callback
)
{
return
Api
.
groups
(
term
,
{},
function
(
data
)
{
return
Api
.
groups
(
term
,
{},
function
(
data
)
{
data
.
unshift
({
data
.
unshift
({
name
:
'
Any
'
full_
name
:
'
Any
'
});
});
data
.
splice
(
1
,
0
,
'
divider
'
);
data
.
splice
(
1
,
0
,
'
divider
'
);
return
callback
(
data
);
return
callback
(
data
);
...
@@ -28,10 +28,10 @@
...
@@ -28,10 +28,10 @@
return
obj
.
id
;
return
obj
.
id
;
},
},
text
:
function
(
obj
)
{
text
:
function
(
obj
)
{
return
obj
.
name
;
return
obj
.
full_
name
;
},
},
toggleLabel
:
function
(
obj
)
{
toggleLabel
:
function
(
obj
)
{
return
(
$groupDropdown
.
data
(
'
default-label
'
))
+
"
"
+
obj
.
name
;
return
(
$groupDropdown
.
data
(
'
default-label
'
))
+
"
"
+
obj
.
full_
name
;
},
},
clicked
:
(
function
(
_this
)
{
clicked
:
(
function
(
_this
)
{
return
function
()
{
return
function
()
{
...
...
app/helpers/search_helper.rb
View file @
d6450bb2
...
@@ -89,7 +89,7 @@ module SearchHelper
...
@@ -89,7 +89,7 @@ module SearchHelper
{
{
category:
"Groups"
,
category:
"Groups"
,
id:
group
.
id
,
id:
group
.
id
,
label:
"
#{
search_result_sanitize
(
group
.
name
)
}
"
,
label:
"
#{
search_result_sanitize
(
group
.
full_
name
)
}
"
,
url:
group_path
(
group
)
url:
group_path
(
group
)
}
}
end
end
...
...
app/models/project.rb
View file @
d6450bb2
...
@@ -225,6 +225,7 @@ class Project < ActiveRecord::Base
...
@@ -225,6 +225,7 @@ class Project < ActiveRecord::Base
scope
:with_project_feature
,
->
{
joins
(
'LEFT JOIN project_features ON projects.id = project_features.project_id'
)
}
scope
:with_project_feature
,
->
{
joins
(
'LEFT JOIN project_features ON projects.id = project_features.project_id'
)
}
scope
:with_statistics
,
->
{
includes
(
:statistics
)
}
scope
:with_statistics
,
->
{
includes
(
:statistics
)
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
scope
:inside_path
,
->
(
path
)
{
joins
(
:route
).
where
(
'routes.path LIKE ?'
,
"
#{
path
}
/%"
)
}
# "enabled" here means "not disabled". It includes private features!
# "enabled" here means "not disabled". It includes private features!
scope
:with_feature_enabled
,
->
(
feature
)
{
scope
:with_feature_enabled
,
->
(
feature
)
{
...
...
app/services/search/global_service.rb
View file @
d6450bb2
...
@@ -9,7 +9,10 @@ module Search
...
@@ -9,7 +9,10 @@ module Search
def
execute
def
execute
group
=
Group
.
find_by
(
id:
params
[
:group_id
])
if
params
[
:group_id
].
present?
group
=
Group
.
find_by
(
id:
params
[
:group_id
])
if
params
[
:group_id
].
present?
projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
projects
=
projects
.
in_namespace
(
group
.
id
)
if
group
if
group
projects
=
projects
.
inside_path
(
group
.
full_path
)
end
Gitlab
::
SearchResults
.
new
(
current_user
,
projects
,
params
[
:search
])
Gitlab
::
SearchResults
.
new
(
current_user
,
projects
,
params
[
:search
])
end
end
...
...
changelogs/unreleased/dz-nested-groups-improvements-2.yml
0 → 100644
View file @
d6450bb2
---
title
:
Add read-only full_path and full_name attributes to Group API
merge_request
:
8827
author
:
doc/api/groups.md
View file @
d6450bb2
...
@@ -25,7 +25,14 @@ GET /groups
...
@@ -25,7 +25,14 @@ GET /groups
"id"
:
1
,
"id"
:
1
,
"name"
:
"Foobar Group"
,
"name"
:
"Foobar Group"
,
"path"
:
"foo-bar"
,
"path"
:
"foo-bar"
,
"description"
:
"An interesting group"
"description"
:
"An interesting group"
,
"visibility_level"
:
20
,
"lfs_enabled"
:
true
,
"avatar_url"
:
"http://localhost:3000/uploads/group/avatar/1/foo.jpg"
,
"web_url"
:
"http://localhost:3000/groups/foo-bar"
,
"request_access_enabled"
:
false
,
"full_name"
:
"Foobar Group"
,
"full_path"
:
"foo-bar"
}
}
]
]
```
```
...
@@ -149,6 +156,8 @@ Example response:
...
@@ -149,6 +156,8 @@ Example response:
"avatar_url"
:
null
,
"avatar_url"
:
null
,
"web_url"
:
"https://gitlab.example.com/groups/twitter"
,
"web_url"
:
"https://gitlab.example.com/groups/twitter"
,
"request_access_enabled"
:
false
,
"request_access_enabled"
:
false
,
"full_name"
:
"Foobar Group"
,
"full_path"
:
"foo-bar"
,
"projects"
:
[
"projects"
:
[
{
{
"id"
:
7
,
"id"
:
7
,
...
@@ -372,6 +381,8 @@ Example response:
...
@@ -372,6 +381,8 @@ Example response:
"avatar_url"
:
null
,
"avatar_url"
:
null
,
"web_url"
:
"http://gitlab.example.com/groups/h5bp"
,
"web_url"
:
"http://gitlab.example.com/groups/h5bp"
,
"request_access_enabled"
:
false
,
"request_access_enabled"
:
false
,
"full_name"
:
"Foobar Group"
,
"full_path"
:
"foo-bar"
,
"projects"
:
[
"projects"
:
[
{
{
"id"
:
9
,
"id"
:
9
,
...
...
lib/api/entities.rb
View file @
d6450bb2
...
@@ -137,6 +137,7 @@ module API
...
@@ -137,6 +137,7 @@ module API
expose
:avatar_url
expose
:avatar_url
expose
:web_url
expose
:web_url
expose
:request_access_enabled
expose
:request_access_enabled
expose
:full_name
,
:full_path
expose
:statistics
,
if: :statistics
do
expose
:statistics
,
if: :statistics
do
with_options
format_with:
->
(
value
)
{
value
.
to_i
}
do
with_options
format_with:
->
(
value
)
{
value
.
to_i
}
do
...
...
spec/helpers/search_helper_spec.rb
View file @
d6450bb2
...
@@ -41,6 +41,11 @@ describe SearchHelper do
...
@@ -41,6 +41,11 @@ describe SearchHelper do
expect
(
search_autocomplete_opts
(
"gro"
).
size
).
to
eq
(
1
)
expect
(
search_autocomplete_opts
(
"gro"
).
size
).
to
eq
(
1
)
end
end
it
"includes nested group"
do
create
(
:group
,
:nested
,
name:
'foo'
).
add_owner
(
user
)
expect
(
search_autocomplete_opts
(
'foo'
).
size
).
to
eq
(
1
)
end
it
"includes the user's projects"
do
it
"includes the user's projects"
do
project
=
create
(
:empty_project
,
namespace:
create
(
:namespace
,
owner:
user
))
project
=
create
(
:empty_project
,
namespace:
create
(
:namespace
,
owner:
user
))
expect
(
search_autocomplete_opts
(
project
.
name
).
size
).
to
eq
(
1
)
expect
(
search_autocomplete_opts
(
project
.
name
).
size
).
to
eq
(
1
)
...
...
spec/models/project_spec.rb
View file @
d6450bb2
...
@@ -1833,6 +1833,14 @@ describe Project, models: true do
...
@@ -1833,6 +1833,14 @@ describe Project, models: true do
end
end
end
end
describe
'inside_path'
do
let!
(
:project1
)
{
create
(
:empty_project
)
}
let!
(
:project2
)
{
create
(
:empty_project
)
}
let!
(
:path
)
{
project1
.
namespace
.
path
}
it
{
expect
(
Project
.
inside_path
(
path
)).
to
eq
([
project1
])
}
end
def
enable_lfs
def
enable_lfs
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
end
end
...
...
spec/requests/api/groups_spec.rb
View file @
d6450bb2
...
@@ -176,6 +176,9 @@ describe API::Groups, api: true do
...
@@ -176,6 +176,9 @@ describe API::Groups, api: true do
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
group1
.
visibility_level
)
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
group1
.
visibility_level
)
expect
(
json_response
[
'avatar_url'
]).
to
eq
(
group1
.
avatar_url
)
expect
(
json_response
[
'avatar_url'
]).
to
eq
(
group1
.
avatar_url
)
expect
(
json_response
[
'web_url'
]).
to
eq
(
group1
.
web_url
)
expect
(
json_response
[
'web_url'
]).
to
eq
(
group1
.
web_url
)
expect
(
json_response
[
'request_access_enabled'
]).
to
eq
(
group1
.
request_access_enabled
)
expect
(
json_response
[
'full_name'
]).
to
eq
(
group1
.
full_name
)
expect
(
json_response
[
'full_path'
]).
to
eq
(
group1
.
full_path
)
expect
(
json_response
[
'projects'
]).
to
be_an
Array
expect
(
json_response
[
'projects'
]).
to
be_an
Array
expect
(
json_response
[
'projects'
].
length
).
to
eq
(
2
)
expect
(
json_response
[
'projects'
].
length
).
to
eq
(
2
)
expect
(
json_response
[
'shared_projects'
]).
to
be_an
Array
expect
(
json_response
[
'shared_projects'
]).
to
be_an
Array
...
...
spec/services/search_service_spec.rb
View file @
d6450bb2
...
@@ -41,6 +41,25 @@ describe 'Search::GlobalService', services: true do
...
@@ -41,6 +41,25 @@ describe 'Search::GlobalService', services: true do
results
=
context
.
execute
results
=
context
.
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
found_project
]
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
found_project
]
end
end
context
'nested group'
do
let!
(
:nested_group
)
{
create
(
:group
,
:nested
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
nested_group
)
}
before
{
project
.
add_master
(
user
)
}
it
'returns result from nested group'
do
context
=
Search
::
GlobalService
.
new
(
user
,
search:
project
.
path
)
results
=
context
.
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
project
]
end
it
'returns result from descendants when search inside group'
do
context
=
Search
::
GlobalService
.
new
(
user
,
search:
project
.
path
,
group_id:
nested_group
.
parent
)
results
=
context
.
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
project
]
end
end
end
end
end
end
end
end
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