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
0f7d47f6
Commit
0f7d47f6
authored
Dec 20, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gitlabhq/gitlabhq
parents
5a7e3500
dc0879ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
16 deletions
+31
-16
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+26
-5
app/views/projects/blob/_actions.html.haml
app/views/projects/blob/_actions.html.haml
+1
-7
app/views/projects/blob/_blob.html.haml
app/views/projects/blob/_blob.html.haml
+1
-1
app/views/projects/diffs/_file.html.haml
app/views/projects/diffs/_file.html.haml
+3
-3
No files found.
app/helpers/tree_helper.rb
View file @
0f7d47f6
...
...
@@ -53,13 +53,34 @@ module TreeHelper
File
.
join
(
*
args
)
end
def
allowed_tree_edit?
return
false
unless
@repository
.
branch_names
.
include?
(
@ref
)
def
allowed_tree_edit?
(
project
=
nil
,
ref
=
nil
)
project
||=
@project
ref
||=
@ref
return
false
unless
project
.
repository
.
branch_names
.
include?
(
ref
)
if
@project
.
protected_branch?
@
ref
can?
(
current_user
,
:push_code_to_protected_branches
,
@
project
)
if
project
.
protected_branch?
ref
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
else
can?
(
current_user
,
:push_code
,
@project
)
can?
(
current_user
,
:push_code
,
project
)
end
end
def
edit_blob_link
(
project
,
ref
,
path
,
options
=
{})
if
project
.
repository
.
blob_at
(
ref
,
path
).
text?
text
=
'Edit'
after
=
options
[
:after
]
||
''
from_mr
=
options
[
:from_merge_request_id
]
link_opts
=
{}
link_opts
[
:from_merge_request_id
]
=
from_mr
if
from_mr
cls
=
'btn btn-small'
if
allowed_tree_edit?
(
project
,
ref
)
link_to
text
,
project_edit_tree_path
(
project
,
tree_join
(
ref
,
path
),
link_opts
),
class:
cls
else
content_tag
:span
,
text
,
class:
cls
+
' disabled'
end
+
after
.
html_safe
else
''
end
end
...
...
app/views/projects/blob/_actions.html.haml
View file @
0f7d47f6
.btn-group.tree-btn-group
-# only show edit link for text files
-
if
@blob
.
text?
-
if
allowed_tree_edit?
=
link_to
'Edit'
,
project_edit_tree_path
(
@project
,
@id
),
class:
'btn btn-small'
-
else
%span
.btn.btn-small.disabled
Edit
=
edit_blob_link
(
@project
,
@ref
,
@path
)
=
link_to
'Raw'
,
project_raw_path
(
@project
,
@id
),
class:
'btn btn-small'
,
target:
'_blank'
-# only show normal/blame view links for text files
...
...
app/views/projects/blob/_blob.html.haml
View file @
0f7d47f6
...
...
@@ -16,7 +16,7 @@
=
link_to
title
,
'#'
%ul
.blob-commit-info.bs-callout.bs-callout-info.hidden-xs
-
blob_commit
=
@repository
.
last_commit_for_path
(
@commit
.
id
,
@
blob
.
path
)
-
blob_commit
=
@repository
.
last_commit_for_path
(
@commit
.
id
,
blob
.
path
)
=
render
blob_commit
,
project:
@project
%div
#tree-content-holder
.tree-content-holder
...
...
app/views/projects/diffs/_file.html.haml
View file @
0f7d47f6
...
...
@@ -30,9 +30,9 @@
-
if
@merge_request
&&
@merge_request
.
source_project
=
link_to
project_edit_tree_path
(
@merge_request
.
source_project
,
tree_join
(
@merge_request
.
source_branch
,
diff_file
.
new_path
),
from_merge_request_id:
@merge_request
.
id
),
{
class:
'btn btn-small'
}
do
Edit
=
edit_blob_link
(
@merge_request
.
source_project
,
@merge_request
.
source_branch
,
diff_file
.
new_path
,
after:
' '
,
from_merge_request_id:
@merge_request
.
id
)
=
view_file_btn
(
@commit
.
id
,
diff_file
,
project
)
...
...
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