diff options
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/commits_helper.rb | 56 | ||||
-rw-r--r-- | app/helpers/dashboard_helper.rb | 11 | ||||
-rw-r--r-- | app/helpers/groups_helper.rb | 16 | ||||
-rw-r--r-- | app/helpers/notifications_helper.rb | 11 | ||||
-rw-r--r-- | app/helpers/tree_helper.rb | 8 |
5 files changed, 22 insertions, 80 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 20a2443f523..e889b390968 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -15,61 +15,9 @@ module CommitsHelper commit_person_link(commit, options.merge(source: :committer)) end - def identification_type(line) - if line[0] == "+" - "new" - elsif line[0] == "-" - "old" - else - nil - end - end - - def build_line_anchor(diff, line_new, line_old) - "#{hexdigest(diff.new_path)}_#{line_old}_#{line_new}" - end - def each_diff_line(diff, index) - diff_arr = diff.diff.lines.to_a - - line_old = 1 - line_new = 1 - type = nil - - lines_arr = ::Gitlab::InlineDiff.processing diff_arr - lines_arr.each do |line| - next if line.match(/^\-\-\- \/dev\/null/) - next if line.match(/^\+\+\+ \/dev\/null/) - next if line.match(/^\-\-\- a/) - next if line.match(/^\+\+\+ b/) - - full_line = html_escape(line.gsub(/\n/, '')) - full_line = ::Gitlab::InlineDiff.replace_markers full_line - - if line.match(/^@@ -/) - type = "match" - - line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 - line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 - - next if line_old == 1 && line_new == 1 #top of file - yield(full_line, type, nil, nil, nil) - next - else - type = identification_type(line) - line_code = build_line_anchor(diff, line_new, line_old) - yield(full_line, type, line_code, line_new, line_old) - end - - - if line[0] == "+" - line_new += 1 - elsif line[0] == "-" - line_old += 1 - else - line_new += 1 - line_old += 1 - end + Gitlab::DiffParser.new(diff).each do |full_line, type, line_code, line_new, line_old| + yield(full_line, type, line_code, line_new, line_old) end end diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index e3be07c9fe0..35c7bcbd2cf 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -1,5 +1,5 @@ module DashboardHelper - def dashboard_filter_path(entity, options={}) + def filter_path(entity, options={}) exist_opts = { status: params[:status], project_id: params[:project_id], @@ -7,12 +7,9 @@ module DashboardHelper options = exist_opts.merge(options) - case entity - when 'issue' then - issues_dashboard_path(options) - when 'merge_request' - merge_requests_dashboard_path(options) - end + path = request.path + path << "?#{options.to_param}" + path end def entities_per_project project, entity diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 2ffbff7af8d..8573c59dc94 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -1,20 +1,4 @@ module GroupsHelper - def group_filter_path(entity, options={}) - exist_opts = { - status: params[:status], - project_id: params[:project_id], - } - - options = exist_opts.merge(options) - - case entity - when 'issue' then - issues_group_path(@group, options) - when 'merge_request' - merge_requests_group_path(@group, options) - end - end - def remove_user_from_group_message(group, user) "You are going to remove #{user.name} from #{group.name} Group. Are you sure?" end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 7342393a707..ae3402b2617 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,2 +1,13 @@ module NotificationsHelper + def notification_icon(notification) + if notification.disabled? + content_tag :i, nil, class: 'icon-circle cred' + elsif notification.participating? + content_tag :i, nil, class: 'icon-circle cblue' + elsif notification.watch? + content_tag :i, nil, class: 'icon-circle cgreen' + else + content_tag :i, nil, class: 'icon-circle-blank cblue' + end + end end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index d41f8377559..73d36d0801c 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -39,12 +39,12 @@ module TreeHelper # # Returns boolean def markup?(filename) - filename.end_with?(*%w(.textile .rdoc .org .creole - .mediawiki .rst .asciidoc .pod)) + filename.downcase.end_with?(*%w(.textile .rdoc .org .creole + .mediawiki .rst .asciidoc .pod)) end def gitlab_markdown?(filename) - filename.end_with?(*%w(.mdown .md .markdown)) + filename.downcase.end_with?(*%w(.mdown .md .markdown)) end def plain_text_readme? filename @@ -57,6 +57,8 @@ module TreeHelper end def allowed_tree_edit? + return false unless @repository.branch_names.include?(@ref) + if @project.protected_branch? @ref can?(current_user, :push_code_to_protected_branches, @project) else |