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
083b0a9b
Commit
083b0a9b
authored
Apr 06, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide file/directory creation buttons
parent
1747a573
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
59 additions
and
28 deletions
+59
-28
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+2
-2
app/views/projects/_last_push.html.haml
app/views/projects/_last_push.html.haml
+3
-2
app/views/projects/branches/_branch.html.haml
app/views/projects/branches/_branch.html.haml
+1
-1
app/views/projects/buttons/_dropdown.html.haml
app/views/projects/buttons/_dropdown.html.haml
+13
-9
app/views/projects/commit/_commit_box.html.haml
app/views/projects/commit/_commit_box.html.haml
+4
-2
app/views/projects/issues/_new_branch.html.haml
app/views/projects/issues/_new_branch.html.haml
+4
-4
app/views/projects/tree/_tree_header.html.haml
app/views/projects/tree/_tree_header.html.haml
+9
-5
spec/features/projects/branches_spec.rb
spec/features/projects/branches_spec.rb
+21
-1
spec/views/projects/buttons/_dropdown.html.haml_spec.rb
spec/views/projects/buttons/_dropdown.html.haml_spec.rb
+2
-1
spec/views/projects/tree/show.html.haml_spec.rb
spec/views/projects/tree/show.html.haml_spec.rb
+0
-1
No files found.
app/helpers/blob_helper.rb
View file @
083b0a9b
...
...
@@ -59,7 +59,7 @@ module BlobHelper
button_tag
label
,
class:
"
#{
common_classes
}
disabled has-tooltip"
,
title:
"It is not possible to
#{
action
}
files that are stored in LFS using the web interface"
,
data:
{
container:
'body'
}
elsif
can_modify_blob?
(
blob
,
project
,
ref
)
button_tag
label
,
class:
"
#{
common_classes
}
"
,
'data-target'
=>
"#modal-
#{
modal_type
}
-blob"
,
'data-toggle'
=>
'modal'
elsif
can?
(
current_user
,
:create_merge_request_in
,
project
)
elsif
can?
(
current_user
,
:
fork_project
,
project
)
&&
can?
(
current_user
,
:
create_merge_request_in
,
project
)
edit_fork_button_tag
(
common_classes
,
project
,
label
,
edit_modify_file_fork_params
(
action
),
action
)
end
end
...
...
@@ -280,7 +280,7 @@ module BlobHelper
options
<<
link_to
(
"submit an issue"
,
new_project_issue_path
(
project
))
end
merge_project
=
can?
(
current_user
,
:create_merge_request_from
,
project
)
?
project
:
(
current_user
&&
current_user
.
fork_of
(
project
)
)
merge_project
=
merge_request_source_project_for_project
(
@project
)
if
merge_project
options
<<
link_to
(
"create a merge request"
,
project_new_merge_request_path
(
project
))
end
...
...
app/views/projects/_last_push.html.haml
View file @
083b0a9b
...
...
@@ -14,5 +14,6 @@
#{
time_ago_with_tooltip
(
event
.
created_at
)
}
.flex-right
=
link_to
new_mr_path_from_push_event
(
event
),
title:
_
(
"New merge request"
),
class:
"btn btn-info btn-sm qa-create-merge-request"
do
#{
_
(
'Create merge request'
)
}
-
if
can?
(
current_user
,
:create_merge_request_in
,
@project
)
=
link_to
new_mr_path_from_push_event
(
event
),
title:
_
(
"New merge request"
),
class:
"btn btn-info btn-sm qa-create-merge-request"
do
#{
_
(
'Create merge request'
)
}
app/views/projects/branches/_branch.html.haml
View file @
083b0a9b
...
...
@@ -4,7 +4,7 @@
-
diverging_commit_counts
=
@repository
.
diverging_commit_counts
(
branch
)
-
number_commits_behind
=
diverging_commit_counts
[
:behind
]
-
number_commits_ahead
=
diverging_commit_counts
[
:ahead
]
-
merge_project
=
can?
(
current_user
,
:create_merge_request_from
,
@project
)
?
@project
:
(
current_user
&&
current_user
.
fork_of
(
@project
)
)
-
merge_project
=
merge_request_source_project_for_project
(
@project
)
%li
{
class:
"branch-item js-branch-#{branch.name}"
}
.branch-info
.branch-title
...
...
app/views/projects/buttons/_dropdown.html.haml
View file @
083b0a9b
-
if
current_user
-
can_create_issue
=
show_new_issue_link?
-
can_create_project_snippet
=
can?
(
current_user
,
:create_project_snippet
,
@project
)
-
can_push_code
=
can?
(
current_user
,
:push_code
,
@project
)
-
create_mr_from_new_fork
=
can?
(
current_user
,
:fork_project
,
@project
)
&&
can?
(
current_user
,
:create_merge_request_in
,
@project
)
-
merge_project
=
merge_request_source_project_for_project
(
@project
)
-
show_menu
=
can_create_issue
||
can_create_project_snippet
||
can_push_code
||
create_mr_from_new_fork
||
merge_project
-
if
show_menu
.project-action-button.dropdown.inline
%a
.btn.dropdown-toggle.has-tooltip
{
href:
'#'
,
title:
_
(
'Create new...'
),
'data-toggle'
=>
'dropdown'
,
'data-container'
=>
'body'
,
'aria-label'
=>
_
(
'Create new...'
)
}
=
icon
(
'plus'
)
=
icon
(
"caret-down"
)
%ul
.dropdown-menu.dropdown-menu-align-right.project-home-dropdown
-
can_create_issue
=
can?
(
current_user
,
:create_issue
,
@project
)
-
merge_project
=
can?
(
current_user
,
:create_merge_request
,
@project
)
?
@project
:
(
current_user
&&
current_user
.
fork_of
(
@project
))
-
can_create_project_snippet
=
can?
(
current_user
,
:create_project_snippet
,
@project
)
-
if
can_create_issue
||
merge_project
||
can_create_project_snippet
%li
.dropdown-header
=
_
(
'This project'
)
...
...
@@ -20,17 +24,17 @@
-
if
can_create_project_snippet
%li
=
link_to
_
(
'New snippet'
),
new_project_snippet_path
(
@project
)
-
if
can
?
(
current_user
,
:push_code
,
@project
)
-
if
can
_push_code
%li
.dropdown-header
=
_
(
'This repository'
)
-
if
can
?
(
current_user
,
:push_code
,
@project
)
-
if
can
_push_code
%li
=
link_to
_
(
'New file'
),
project_new_blob_path
(
@project
,
@project
.
default_branch
||
'master'
)
-
unless
@project
.
empty_repo?
%li
=
link_to
_
(
'New branch'
),
new_project_branch_path
(
@project
)
%li
=
link_to
_
(
'New tag'
),
new_project_tag_path
(
@project
)
-
elsif
c
urrent_user
&&
current_user
.
already_forked
?
(
@project
)
-
elsif
c
an_collaborate_with_project
?
(
@project
)
%li
=
link_to
_
(
'New file'
),
project_new_blob_path
(
@project
,
@project
.
default_branch
||
'master'
)
-
elsif
c
an?
(
current_user
,
:fork_project
,
@project
)
-
elsif
c
reate_mr_from_new_fork
-
continue_params
=
{
to:
project_new_blob_path
(
@project
,
@project
.
default_branch
||
'master'
),
notice:
edit_in_new_fork_notice
,
notice_now:
edit_in_new_fork_notice_now
}
...
...
app/views/projects/commit/_commit_box.html.haml
View file @
083b0a9b
-
can_collaborate
=
can_collaborate_with_project?
(
@project
)
.page-content-header.js-commit-box
{
'data-commit-path'
=>
branches_project_commit_path
(
@project
,
@commit
.
id
)
}
.header-main-content
=
render
partial:
'signature'
,
object:
@commit
.
signature
...
...
@@ -32,10 +34,10 @@
%li
.visible-xs-block.visible-sm-block
=
link_to
project_tree_path
(
@project
,
@commit
)
do
#{
_
(
'Browse Files'
)
}
-
unless
@commit
.
has_been_reverted?
(
current_user
)
-
if
can_collaborate
&&
!
@commit
.
has_been_reverted?
(
current_user
)
%li
.clearfix
=
revert_commit_link
(
@commit
,
project_commit_path
(
@project
,
@commit
.
id
),
has_tooltip:
false
)
-
if
can_collaborate
_with_project?
(
@project
)
-
if
can_collaborate
%li
.clearfix
=
cherry_pick_commit_link
(
@commit
,
project_commit_path
(
@project
,
@commit
.
id
),
has_tooltip:
false
)
-
if
can?
(
current_user
,
:push_code
,
@project
)
...
...
app/views/projects/issues/_new_branch.html.haml
View file @
083b0a9b
-
can_create_merge_request
=
can?
(
current_user
,
:create_merge_request_from
,
@project
)
-
data_action
=
can_create_merge_request
?
'create-mr'
:
'create-branch'
-
value
=
can_create_merge_request
?
'Create merge request'
:
'Create branch'
-
if
can?
(
current_user
,
:push_code
,
@project
)
-
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'
-
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
)
-
create_branch_path
=
project_branches_path
(
@project
,
branch_name:
@issue
.
to_branch_name
,
ref:
@project
.
default_branch
,
issue_iid:
@issue
.
iid
)
...
...
app/views/projects/tree/_tree_header.html.haml
View file @
083b0a9b
-
can_collaborate
=
can_collaborate_with_project?
(
@project
)
-
can_create_mr_from_fork
=
can?
(
current_user
,
:fork_project
,
@project
)
&&
can?
(
current_user
,
:create_merge_request_in
,
@project
)
.tree-ref-container
.tree-ref-holder
=
render
'shared/ref_switcher'
,
destination:
'tree'
,
path:
@path
,
show_create:
true
...
...
@@ -15,7 +18,7 @@
%li
=
link_to
truncate
(
title
,
length:
40
),
project_tree_path
(
@project
,
tree_join
(
@ref
,
path
))
-
if
c
urrent_user
-
if
c
an_collaborate
||
can_create_mr_from_fork
%li
%a
.btn.add-to-tree
{
addtotree_toggle_attributes
}
=
sprite_icon
(
'plus'
,
size:
16
,
css_class:
'pull-left'
)
...
...
@@ -35,7 +38,7 @@
%li
=
link_to
'#modal-create-new-dir'
,
{
'data-target'
=>
'#modal-create-new-dir'
,
'data-toggle'
=>
'modal'
}
do
#{
_
(
'New directory'
)
}
-
elsif
can?
(
current_user
,
:fork_project
,
@project
)
-
elsif
can?
(
current_user
,
:fork_project
,
@project
)
&&
can?
(
current_user
,
:create_merge_request_in
,
@project
)
%li
-
continue_params
=
{
to:
project_new_blob_path
(
@project
,
@id
),
notice:
edit_in_new_fork_notice
,
...
...
@@ -77,8 +80,9 @@
=
render
'projects/find_file_link'
=
succeed
" "
do
=
link_to
ide_edit_path
(
@project
,
@id
,
""
),
class:
'btn btn-default'
do
=
_
(
'Web IDE'
)
-
if
can_collaborate
=
succeed
" "
do
=
link_to
ide_edit_path
(
@project
,
@id
,
""
),
class:
'btn btn-default'
do
=
_
(
'Web IDE'
)
=
render
'projects/buttons/download'
,
project:
@project
,
ref:
@ref
spec/features/projects/branches_spec.rb
View file @
083b0a9b
...
...
@@ -195,6 +195,26 @@ describe 'Branches' do
expect
(
page
).
to
have_content
(
"Protected branches can be managed in project settings"
)
end
end
it
'shows the merge request button'
do
visit
project_branches_path
(
project
)
page
.
within
first
(
'.all-branches li'
)
do
expect
(
page
).
to
have_content
'Merge request'
end
end
context
'when the project is archived'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
archived:
true
)
}
it
'does not show the merge request button when the project is archived'
do
visit
project_branches_path
(
project
)
page
.
within
first
(
'.all-branches li'
)
do
expect
(
page
).
not_to
have_content
'Merge request'
end
end
end
end
context
'logged out'
do
...
...
@@ -204,7 +224,7 @@ describe 'Branches' do
it
'does not show merge request button'
do
page
.
within
first
(
'.all-branches li'
)
do
expect
(
page
).
not_to
have_content
'Merge
R
equest'
expect
(
page
).
not_to
have_content
'Merge
r
equest'
end
end
end
...
...
spec/views/projects/buttons/_dropdown.html.haml_spec.rb
View file @
083b0a9b
...
...
@@ -8,7 +8,8 @@ describe 'projects/buttons/_dropdown' do
assign
(
:project
,
project
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:can?
).
with
(
user
,
:push_code
,
project
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:can_collaborate_with_project?
).
and_return
(
true
)
end
context
'empty repository'
do
...
...
spec/views/projects/tree/show.html.haml_spec.rb
View file @
083b0a9b
...
...
@@ -12,7 +12,6 @@ describe 'projects/tree/show' do
assign
(
:lfs_blob_ids
,
[])
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:can_contribute_to_project?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:can_collaborate_with_project?
).
and_return
(
true
)
allow
(
view
).
to
receive_message_chain
(
'user_access.can_push_to_branch?'
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:current_application_settings
).
and_return
(
Gitlab
::
CurrentSettings
.
current_application_settings
)
...
...
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