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
Boxiang Sun
gitlab-ce
Commits
d9242f20
Commit
d9242f20
authored
Jun 20, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show create merge request button on confidential issues
https://gitlab.com/gitlab-org/gitlab-ce/issues/58583
parent
733f384b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
4 deletions
+39
-4
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+14
-0
app/views/projects/issues/_new_branch.html.haml
app/views/projects/issues/_new_branch.html.haml
+6
-2
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/features/issues/user_creates_branch_and_merge_request_spec.rb
...ures/issues/user_creates_branch_and_merge_request_spec.rb
+12
-1
No files found.
app/helpers/issues_helper.rb
View file @
d9242f20
...
...
@@ -135,6 +135,20 @@ module IssuesHelper
can?
(
current_user
,
:create_issue
,
project
)
end
def
create_confidential_merge_request_enabled?
Feature
.
enabled?
(
:create_confidential_merge_request
,
@project
)
end
def
show_new_branch_button?
can_create_confidential_merge_request?
||
!
@issue
.
confidential?
end
def
can_create_confidential_merge_request?
@issue
.
confidential?
&&
!
@project
.
private?
&&
create_confidential_merge_request_enabled?
&&
can?
(
current_user
,
:create_merge_request_in
,
@project
)
end
# Required for Banzai::Filter::IssueReferenceFilter
module_function
:url_for_issue
module_function
:url_for_internal_issue
...
...
app/views/projects/issues/_new_branch.html.haml
View file @
d9242f20
...
...
@@ -2,6 +2,7 @@
-
can_create_merge_request
=
can?
(
current_user
,
:create_merge_request_in
,
@project
)
-
data_action
=
can_create_merge_request
?
'create-mr'
:
'create-branch'
-
value
=
can_create_merge_request
?
'Create merge request'
:
'Create branch'
-
value
=
can_create_confidential_merge_request?
?
_
(
'Create confidential merge request'
)
:
value
-
can_create_path
=
can_create_branch_project_issue_path
(
@project
,
@issue
)
-
create_mr_path
=
create_merge_request_project_issue_path
(
@project
,
@issue
,
branch_name:
@issue
.
to_branch_name
,
ref:
@project
.
default_branch
)
...
...
@@ -23,12 +24,15 @@
=
icon
(
'caret-down'
)
.droplab-dropdown
%ul
#create-merge-request-dropdown
.create-merge-request-dropdown-menu.dropdown-menu.dropdown-menu-right.gl-show-field-errors
{
data:
{
dropdown:
true
}
}
%ul
#create-merge-request-dropdown
.create-merge-request-dropdown-menu.dropdown-menu.dropdown-menu-right.gl-show-field-errors
{
class:
(
"create-confidential-merge-request-dropdown-menu"
if
can_create_confidential_merge_request?
),
data:
{
dropdown:
true
}
}
-
if
can_create_merge_request
%li
.droplab-item-selected
{
role:
'button'
,
data:
{
value:
'create-mr'
,
text:
_
(
'Create merge request'
)
}
}
.menu-item
=
icon
(
'check'
,
class:
'icon'
)
=
_
(
'Create merge request and branch'
)
-
if
can_create_confidential_merge_request?
=
_
(
'Create confidential merge request and branch'
)
-
else
=
_
(
'Create merge request and branch'
)
%li
{
class:
[
!
can_create_merge_request
&&
'droplab-item-selected'
],
role:
'button'
,
data:
{
value:
'create-branch'
,
text:
_
(
'Create branch'
)
}
}
.menu-item
...
...
app/views/projects/issues/show.html.haml
View file @
d9242f20
...
...
@@ -91,7 +91,7 @@
=
render
'award_emoji/awards_block'
,
awardable:
@issue
,
inline:
true
.col-md-12.col-lg-6.new-branch-col
#js-vue-discussion-filter
{
data:
{
default_filter:
current_user
&
.
notes_filter_for
(
@issue
),
notes_filters:
UserPreference
.
notes_filters
.
to_json
}
}
=
render
'new_branch'
unless
@issue
.
confidential
?
=
render
'new_branch'
if
show_new_branch_button
?
=
render_if_exists
'projects/issues/discussion'
...
...
locale/gitlab.pot
View file @
d9242f20
...
...
@@ -3056,6 +3056,12 @@ msgstr ""
msgid "Create commit"
msgstr ""
msgid "Create confidential merge request"
msgstr ""
msgid "Create confidential merge request and branch"
msgstr ""
msgid "Create directory"
msgstr ""
...
...
spec/features/issues/user_creates_branch_and_merge_request_spec.rb
View file @
d9242f20
...
...
@@ -3,7 +3,7 @@ require 'rails_helper'
describe
'User creates branch and merge request on issue page'
,
:js
do
let
(
:membership_level
)
{
:developer
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
title:
'Cherry-Coloured Funk'
)
}
context
'when signed out'
do
...
...
@@ -163,10 +163,21 @@ describe 'User creates branch and merge request on issue page', :js do
let
(
:issue
)
{
create
(
:issue
,
:confidential
,
project:
project
)
}
it
'disables the create branch button'
do
stub_feature_flags
(
create_confidential_merge_request:
false
)
visit
project_issue_path
(
project
,
issue
)
expect
(
page
).
not_to
have_css
(
'.create-mr-dropdown-wrap'
)
end
it
'enables the create branch button when feature flag is enabled'
do
stub_feature_flags
(
create_confidential_merge_request:
true
)
visit
project_issue_path
(
project
,
issue
)
expect
(
page
).
to
have_css
(
'.create-mr-dropdown-wrap'
)
expect
(
page
).
to
have_button
(
'Create confidential merge request'
)
end
end
context
'when related branch exists'
do
...
...
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