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
228b757d
Commit
228b757d
authored
Feb 19, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor blob link methods
parent
9753396f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+11
-10
No files found.
app/helpers/blob_helper.rb
View file @
228b757d
...
...
@@ -24,19 +24,24 @@ module BlobHelper
if
!
on_top_of_branch?
(
project
,
ref
)
edit_button_tag
(
edit_text
,
common_classes
)
# This condition applies to anonymous or users who can edit directly
elsif
!
current_user
||
user_can_modify_blob
(
blob
,
project
,
ref
)
elsif
!
current_user
||
user_can_modify_blob
?
(
blob
,
project
,
ref
)
edit_link_tag
(
edit_text
,
edit_blob_path
(
project
,
ref
,
path
,
options
),
common_classes
)
elsif
user_can_fork_project
(
project
)
elsif
user_can_fork_project
?
(
project
)
edit_fork_button_tag
(
common_classes
,
project
,
edit_text
,
project
,
edit_text
,
edit_blob_fork_params
(
edit_blob_path
(
project
,
ref
,
path
,
options
)))
end
end
def
user_can_fork_project
(
project
)
def
user_can_fork_project
?
(
project
)
current_user
&&
can?
(
current_user
,
:fork_project
,
project
)
end
def
user_can_modify_blob?
(
blob
,
project
,
ref
)
current_user
&&
can_modify_blob?
(
blob
,
project
,
ref
)
end
def
ide_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
"
#{
ide_path
}
/project
#{
edit_blob_path
(
project
,
ref
,
path
,
options
)
}
"
end
...
...
@@ -59,9 +64,9 @@ module BlobHelper
edit_button_tag
(
ide_edit_text
,
common_classes
)
# This condition only applies to users who are logged in
# Web IDE (Beta) requires the user to have this feature enabled
elsif
user_can_modify_blob
(
blob
,
project
,
ref
)
elsif
user_can_modify_blob
?
(
blob
,
project
,
ref
)
edit_link_tag
(
ide_edit_text
,
ide_edit_path
(
project
,
ref
,
path
,
options
),
common_classes
)
elsif
user_can_fork_project
(
project
)
elsif
user_can_fork_project
?
(
project
)
edit_fork_button_tag
(
common_classes
,
project
,
ide_edit_text
,
...
...
@@ -69,10 +74,6 @@ module BlobHelper
end
end
def
user_can_modify_blob
(
blob
,
project
,
ref
)
current_user
&&
can_modify_blob?
(
blob
,
project
,
ref
)
end
def
modify_file_element
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
label
:,
action
:,
btn_class
:,
modal_type
:)
return
unless
current_user
...
...
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