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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
db587ae3
Commit
db587ae3
authored
Feb 23, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code based on feedback
parent
0767861b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+26
-25
No files found.
app/helpers/blob_helper.rb
View file @
db587ae3
...
@@ -21,25 +21,20 @@ module BlobHelper
...
@@ -21,25 +21,20 @@ module BlobHelper
common_classes
=
"btn js-edit-blob
#{
options
[
:extra_class
]
}
"
common_classes
=
"btn js-edit-blob
#{
options
[
:extra_class
]
}
"
if
!
on_top_of_branch?
(
project
,
ref
)
edit_button_tag
(
blob
,
edit_disabled_button_tag
(
edit_text
,
common_classes
)
common_classes
,
# This condition applies to anonymous or users who can edit directly
edit_text
,
elsif
!
current_user
||
user_can_modify_blob?
(
blob
,
project
,
ref
)
edit_blob_path
(
project
,
ref
,
path
,
options
),
edit_link_tag
(
edit_text
,
edit_blob_path
(
project
,
ref
,
path
,
options
),
common_classes
)
project
,
elsif
user_can_fork_project?
(
project
)
ref
)
edit_fork_button_tag
(
common_classes
,
project
,
edit_text
,
edit_blob_fork_params
(
edit_blob_path
(
project
,
ref
,
path
,
options
)))
end
end
end
def
user_can_fork_project?
(
project
)
def
user_can_fork_project?
(
project
)
current_user
&&
can?
(
current_user
,
:fork_project
,
project
)
current_user
&&
can?
(
current_user
,
:fork_project
,
project
)
end
end
def
user_can
_modify_blob?
(
blob
,
project
,
ref
)
def
display
_modify_blob?
(
blob
,
project
,
ref
)
current_user
&&
can_modify_blob?
(
blob
,
project
,
ref
)
!
current_user
||
(
current_user
&&
can_modify_blob?
(
blob
,
project
,
ref
)
)
end
end
def
ide_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
def
ide_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
...
@@ -60,18 +55,12 @@ module BlobHelper
...
@@ -60,18 +55,12 @@ module BlobHelper
common_classes
=
"btn js-edit-ide
#{
options
[
:extra_class
]
}
"
common_classes
=
"btn js-edit-ide
#{
options
[
:extra_class
]
}
"
if
!
on_top_of_branch?
(
project
,
ref
)
edit_button_tag
(
blob
,
edit_disabled_button_tag
(
ide_edit_text
,
common_classes
)
common_classes
,
# This condition only applies to users who are logged in
ide_edit_text
,
# Web IDE (Beta) requires the user to have this feature enabled
ide_edit_path
(
project
,
ref
,
path
,
options
),
elsif
user_can_modify_blob?
(
blob
,
project
,
ref
)
project
,
edit_link_tag
(
ide_edit_text
,
ide_edit_path
(
project
,
ref
,
path
,
options
),
common_classes
)
ref
)
elsif
user_can_fork_project?
(
project
)
edit_fork_button_tag
(
common_classes
,
project
,
ide_edit_text
,
edit_blob_fork_params
(
ide_edit_path
(
project
,
ref
,
path
,
options
)))
end
end
end
def
modify_file_element
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
label
:,
action
:,
btn_class
:,
modal_type
:)
def
modify_file_element
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
label
:,
action
:,
btn_class
:,
modal_type
:)
...
@@ -356,4 +345,16 @@ module BlobHelper
...
@@ -356,4 +345,16 @@ module BlobHelper
def
edit_link_tag
(
link_text
,
edit_path
,
common_classes
)
def
edit_link_tag
(
link_text
,
edit_path
,
common_classes
)
link_to
link_text
,
edit_path
,
class:
"
#{
common_classes
}
btn-sm"
link_to
link_text
,
edit_path
,
class:
"
#{
common_classes
}
btn-sm"
end
end
def
edit_button_tag
(
blob
,
common_classes
,
text
,
edit_path
,
project
,
ref
)
if
!
on_top_of_branch?
(
project
,
ref
)
edit_disabled_button_tag
(
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
display_modify_blob?
(
blob
,
project
,
ref
)
edit_link_tag
(
text
,
edit_path
,
common_classes
)
elsif
user_can_fork_project?
(
project
)
edit_fork_button_tag
(
common_classes
,
project
,
text
,
edit_path
)
end
end
end
end
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