Merge branch '52453-show-subgroups-in-group-create-issue' into 'master'
Resolve "Access project from descendent groups when selecting project to create new issue" Closes #47096 and #52453 See merge request gitlab-org/gitlab-ce!22612
This commit is contained in:
commit
eb3683fa65
|
@ -48,10 +48,19 @@ export default {
|
|||
selectable: true,
|
||||
data: (term, callback) => {
|
||||
this.loading = true;
|
||||
return Api.groupProjects(this.groupId, term, { with_issues_enabled: true }, projects => {
|
||||
this.loading = false;
|
||||
callback(projects);
|
||||
});
|
||||
return Api.groupProjects(
|
||||
this.groupId,
|
||||
term,
|
||||
{
|
||||
with_issues_enabled: true,
|
||||
with_shared: false,
|
||||
include_subgroups: true,
|
||||
},
|
||||
projects => {
|
||||
this.loading = false;
|
||||
callback(projects);
|
||||
},
|
||||
);
|
||||
},
|
||||
renderRow(project) {
|
||||
return `
|
||||
|
|
|
@ -14,6 +14,9 @@ export default function projectSelect() {
|
|||
this.orderBy = $(select).data('orderBy') || 'id';
|
||||
this.withIssuesEnabled = $(select).data('withIssuesEnabled');
|
||||
this.withMergeRequestsEnabled = $(select).data('withMergeRequestsEnabled');
|
||||
this.withShared =
|
||||
$(select).data('withShared') === undefined ? true : $(select).data('withShared');
|
||||
this.includeProjectsInSubgroups = $(select).data('includeProjectsInSubgroups') || false;
|
||||
this.allowClear = $(select).data('allowClear') || false;
|
||||
|
||||
placeholder = 'Search for project';
|
||||
|
@ -54,6 +57,8 @@ export default function projectSelect() {
|
|||
{
|
||||
with_issues_enabled: _this.withIssuesEnabled,
|
||||
with_merge_requests_enabled: _this.withMergeRequestsEnabled,
|
||||
with_shared: _this.withShared,
|
||||
include_subgroups: _this.includeProjectsInSubgroups,
|
||||
},
|
||||
projectsCallback,
|
||||
);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
= render 'shared/issuable/nav', type: :issues
|
||||
.nav-controls
|
||||
= render 'shared/issuable/feed_buttons'
|
||||
= render 'shared/new_project_item_select', path: 'issues/new', label: "New issue", type: :issues, with_feature_enabled: 'issues'
|
||||
= render 'shared/new_project_item_select', path: 'issues/new', label: "New issue", type: :issues, with_feature_enabled: 'issues', with_shared: false, include_projects_in_subgroups: true
|
||||
|
||||
= render 'shared/issuable/search_bar', type: :issues
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
= render 'shared/issuable/nav', type: :merge_requests
|
||||
- if current_user
|
||||
.nav-controls
|
||||
= render 'shared/new_project_item_select', path: 'merge_requests/new', label: "New merge request", type: :merge_requests, with_feature_enabled: 'merge_requests'
|
||||
= render 'shared/new_project_item_select', path: 'merge_requests/new', label: "New merge request", type: :merge_requests, with_feature_enabled: 'merge_requests', with_shared: false, include_projects_in_subgroups: true
|
||||
|
||||
= render 'shared/issuable/search_bar', type: :merge_requests
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
.project-item-select-holder.btn-group
|
||||
%a.btn.btn-success.new-project-item-link.qa-new-project-item-link{ href: '', data: { label: local_assigns[:label], type: local_assigns[:type] } }
|
||||
= icon('spinner spin')
|
||||
= project_select_tag :project_path, class: "project-item-select", data: { include_groups: local_assigns[:include_groups], order_by: 'last_activity_at', relative_path: local_assigns[:path] }, with_feature_enabled: local_assigns[:with_feature_enabled]
|
||||
= project_select_tag :project_path, class: "project-item-select", data: { include_groups: local_assigns[:include_groups], order_by: 'last_activity_at', relative_path: local_assigns[:path], with_shared: local_assigns[:with_shared], include_projects_in_subgroups: local_assigns[:include_projects_in_subgroups] }, with_feature_enabled: local_assigns[:with_feature_enabled]
|
||||
%button.btn.btn-success.new-project-item-select-button.qa-new-project-item-select-button
|
||||
= icon('caret-down')
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix project selector consistency in groups issues / MRs / boards pages
|
||||
merge_request: 22612
|
||||
author: Heinrich Lee Yu
|
||||
type: fixed
|
|
@ -152,8 +152,10 @@ Parameters:
|
|||
| `simple` | boolean | no | Return only the ID, URL, name, and path of each project |
|
||||
| `owned` | boolean | no | Limit by projects owned by the current user |
|
||||
| `starred` | boolean | no | Limit by projects starred by the current user |
|
||||
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
|
||||
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
|
||||
| `with_issues_enabled` | boolean | no | Limit by projects with issues feature enabled. Default is `false` |
|
||||
| `with_merge_requests_enabled` | boolean | no | Limit by projects with merge requests feature enabled. Default is `false` |
|
||||
| `with_shared` | boolean | no | Include projects shared to this group. Default is `true` |
|
||||
| `include_subgroups` | boolean | no | Include projects in subgroups of this group. Default is `false` |
|
||||
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
|
||||
|
||||
Example response:
|
||||
|
|
|
@ -60,7 +60,17 @@ module API
|
|||
|
||||
def find_group_projects(params)
|
||||
group = find_group!(params[:id])
|
||||
projects = GroupProjectsFinder.new(group: group, current_user: current_user, params: project_finder_params).execute
|
||||
options = {
|
||||
only_owned: !params[:with_shared],
|
||||
include_subgroups: params[:include_subgroups]
|
||||
}
|
||||
|
||||
projects = GroupProjectsFinder.new(
|
||||
group: group,
|
||||
current_user: current_user,
|
||||
params: project_finder_params,
|
||||
options: options
|
||||
).execute
|
||||
projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
|
||||
projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
|
||||
projects = reorder_projects(projects)
|
||||
|
@ -201,6 +211,8 @@ module API
|
|||
optional :starred, type: Boolean, default: false, desc: 'Limit by starred status'
|
||||
optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature'
|
||||
optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature'
|
||||
optional :with_shared, type: Boolean, default: true, desc: 'Include projects shared to this group'
|
||||
optional :include_subgroups, type: Boolean, default: false, desc: 'Includes projects in subgroups of this group'
|
||||
|
||||
use :pagination
|
||||
use :with_custom_attributes
|
||||
|
|
|
@ -490,7 +490,7 @@ describe API::Groups do
|
|||
expect(json_response.first['visibility']).not_to be_present
|
||||
end
|
||||
|
||||
it 'filters the groups projects' do
|
||||
it "filters the groups projects" do
|
||||
public_project = create(:project, :public, path: 'test1', group: group1)
|
||||
|
||||
get api("/groups/#{group1.id}/projects", user1), visibility: 'public'
|
||||
|
@ -502,6 +502,32 @@ describe API::Groups do
|
|||
expect(json_response.first['name']).to eq(public_project.name)
|
||||
end
|
||||
|
||||
it "returns projects excluding shared" do
|
||||
create(:project_group_link, project: create(:project), group: group1)
|
||||
create(:project_group_link, project: create(:project), group: group1)
|
||||
create(:project_group_link, project: create(:project), group: group1)
|
||||
|
||||
get api("/groups/#{group1.id}/projects", user1), with_shared: false
|
||||
|
||||
expect(response).to have_gitlab_http_status(200)
|
||||
expect(response).to include_pagination_headers
|
||||
expect(json_response).to be_an(Array)
|
||||
expect(json_response.length).to eq(2)
|
||||
end
|
||||
|
||||
it "returns projects including those in subgroups", :nested_groups do
|
||||
subgroup = create(:group, parent: group1)
|
||||
create(:project, group: subgroup)
|
||||
create(:project, group: subgroup)
|
||||
|
||||
get api("/groups/#{group1.id}/projects", user1), include_subgroups: true
|
||||
|
||||
expect(response).to have_gitlab_http_status(200)
|
||||
expect(response).to include_pagination_headers
|
||||
expect(json_response).to be_an(Array)
|
||||
expect(json_response.length).to eq(4)
|
||||
end
|
||||
|
||||
it "does not return a non existing group" do
|
||||
get api("/groups/1328/projects", user1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue