diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/branch-graph.js.coffee | 10 | ||||
-rw-r--r-- | app/assets/stylesheets/sections/notes.scss | 12 | ||||
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 7 | ||||
-rw-r--r-- | app/helpers/notes_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 8 | ||||
-rw-r--r-- | app/models/merge_request.rb | 9 | ||||
-rw-r--r-- | app/models/project.rb | 14 | ||||
-rw-r--r-- | app/views/projects/_home_panel.html.haml | 10 | ||||
-rw-r--r-- | app/views/projects/blame/show.html.haml | 14 | ||||
-rw-r--r-- | app/views/projects/diffs/_file.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/protected_branches/index.html.haml | 12 |
11 files changed, 63 insertions, 43 deletions
diff --git a/app/assets/javascripts/branch-graph.js.coffee b/app/assets/javascripts/branch-graph.js.coffee index b8af07579f2..010a2b0e42b 100644 --- a/app/assets/javascripts/branch-graph.js.coffee +++ b/app/assets/javascripts/branch-graph.js.coffee @@ -90,11 +90,15 @@ class @BranchGraph renderPartialGraph: -> start = Math.floor((@element.scrollTop() - @offsetY) / @unitTime) - 10 - start = 0 if start < 0 + if start < 0 + isGraphEdge = true + start = 0 end = start + 40 - end = @commits.length if @commits.length < end + if @commits.length < end + isGraphEdge = true + end = @commits.length - if @prev_start == -1 or Math.abs(@prev_start - start) > 10 + if @prev_start == -1 or Math.abs(@prev_start - start) > 10 or isGraphEdge i = start @prev_start = start diff --git a/app/assets/stylesheets/sections/notes.scss b/app/assets/stylesheets/sections/notes.scss index 8df25f53762..d6a0ff3a735 100644 --- a/app/assets/stylesheets/sections/notes.scss +++ b/app/assets/stylesheets/sections/notes.scss @@ -143,8 +143,14 @@ ul.notes { */ .diff-file tr.line_holder { + @mixin show-add-diff-note { + filter: alpha(opacity=100); + opacity: 1.0; + } + .add-diff-note { background: image-url("diff_note_add.png") no-repeat left 0; + border: none; height: 22px; margin-left: -65px; position: absolute; @@ -156,8 +162,7 @@ ul.notes { filter: alpha(opacity=0); &:hover { - opacity: 1.0; - filter: alpha(opacity=100); + @include show-add-diff-note; } } @@ -166,8 +171,7 @@ ul.notes { background: $hover !important; .add-diff-note { - opacity: 1.0; - filter: alpha(opacity=100); + @include show-add-diff-note; } } } diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index d269323542f..0365681a128 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -73,7 +73,12 @@ module GitlabMarkdownHelper paths.uniq.each do |file_path| # If project does not have repository # its nothing to rebuild - if @repository.exists? && !@repository.empty? + # + # TODO: pass project variable to markdown helper instead of using + # instance variable. Right now it generates invalid path for pages out + # of project scope. Example: search results where can be rendered markdown + # from different projects + if @repository && @repository.exists? && !@repository.empty? new_path = rebuild_path(file_path) # Finds quoted path so we don't replace other mentions of the string # eg. "doc/api" will be replaced and "/home/doc/api/text" won't diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index cddcae464b0..15d4b875c4c 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -52,8 +52,8 @@ module NotesHelper discussion_id: discussion_id } - link_to "", "javascript:;", class: "add-diff-note js-add-diff-note-button", - data: data, title: "Add a comment to this line" + button_tag '', class: 'btn add-diff-note js-add-diff-note-button', + data: data, title: 'Add a comment to this line' end def link_to_reply_diff(note) @@ -67,8 +67,8 @@ module NotesHelper discussion_id: note.discussion_id } - link_to "javascript:;", class: "btn reply-btn js-discussion-reply-button", - data: data, title: "Add a reply" do + button_tag class: 'btn reply-btn js-discussion-reply-button', + data: data, title: 'Add a reply' do link_text = content_tag(:i, nil, class: 'icon-comment') link_text << ' Reply' end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index d22526947dd..f7da30bcc4b 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -156,6 +156,14 @@ module ProjectsHelper end end + def link_to_toggle_fork + out = content_tag(:i, '', class: 'icon-code-fork') + out << ' Fork' + out << content_tag(:span, class: 'count') do + @project.forks_count.to_s + end + end + private def get_project_nav_tabs(project, current_user) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 10bd76b1c35..4894c617674 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -122,9 +122,11 @@ class MergeRequest < ActiveRecord::Base if opened? || reopened? similar_mrs = self.target_project.merge_requests.where(source_branch: source_branch, target_branch: target_branch, source_project_id: source_project.id).opened similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id - if similar_mrs.any? - errors.add :base, "Cannot Create: This merge request already exists: #{similar_mrs.pluck(:title)}" + errors.add :validate_branches, + "Cannot Create: This merge request already exists: #{ + similar_mrs.pluck(:title) + }" end end end @@ -140,7 +142,8 @@ class MergeRequest < ActiveRecord::Base if source_project.forked_from?(target_project) true else - errors.add :base, "Source project is not a fork of target project" + errors.add :validate_fork, + 'Source project is not a fork of target project' end end end diff --git a/app/models/project.rb b/app/models/project.rb index 0adedaa8dcd..7edc15b7782 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -422,15 +422,19 @@ class Project < ActiveRecord::Base end # Add comment about pushing new commits to merge requests - mrs = self.merge_requests.opened.where(source_branch: branch_name).to_a + comment_mr_with_commits(branch_name, commits, user) + + true + end + + def comment_mr_with_commits(branch_name, commits, user) + mrs = self.origin_merge_requests.opened.where(source_branch: branch_name).to_a mrs += self.fork_merge_requests.opened.where(source_branch: branch_name).to_a mrs.uniq.each do |merge_request| Note.create_new_commits_note(merge_request, merge_request.project, user, commits) end - - true end def valid_repo? @@ -599,4 +603,8 @@ class Project < ActiveRecord::Base def find_label(name) labels.find_by(name: name) end + + def origin_merge_requests + merge_requests.where(source_project_id: self.id) + end end diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index 1627a61d236..2c1ac06fc90 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -18,16 +18,10 @@ - if current_user && can?(current_user, :fork_project, @project) && @project.namespace != current_user.namespace - if current_user.already_forked?(@project) = link_to project_path(current_user.fork_of(@project)), title: 'Got to my fork' do - %i.icon-code-fork - Fork - %span.count - = @project.forks_count + = link_to_toggle_fork - else = link_to fork_project_path(@project), title: "Fork project", method: "POST" do - %i.icon-code-fork - Fork - %span.count - = @project.forks_count + = link_to_toggle_fork .star-buttons %span.star.js-toggler-container{class: @show_star ? 'on' : ''} diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index 64bbd495102..464e7ca40e1 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -10,8 +10,7 @@ %span.options= render "projects/blob/actions" .file-content.blame.highlight %table - - current_line = 1 - - @blame.each do |commit, lines| + - @blame.each do |commit, lines, since| - commit = Commit.new(commit) %tr %td.blame-commit @@ -23,14 +22,9 @@ = link_to_gfm truncate(commit.title, length: 20), project_commit_path(@project, commit.id), class: "row_title" %td.lines.blame-numbers %pre - - if lines.empty? - = current_line - - current_line += 1 - - else - - lines.each do |line| - = current_line - \ - - current_line += 1 + - (since...(since + lines.count)).each do |i| + = i + \ %td.lines %pre %code{ class: highlightjs_class(@blob.name) } diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml index f2a8d148cc6..be9389172b7 100644 --- a/app/views/projects/diffs/_file.html.haml +++ b/app/views/projects/diffs/_file.html.haml @@ -12,7 +12,7 @@ - else %span= diff_file.new_path - if diff_file.mode_changed? - %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" + %span.file-mode= "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}" .diff-btn-group - unless params[:view] == 'parallel' diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml index 7925e800305..3980a6c0863 100644 --- a/app/views/projects/protected_branches/index.html.haml +++ b/app/views/projects/protected_branches/index.html.haml @@ -1,14 +1,14 @@ %h3.page-title Protected branches -%p.light This ability allows to keep stable branches secured and force code review before merge to protected branches +%p.light This ability keeps stable branches secure and forces developers to use code reviews %hr .bs-callout.bs-callout-info - %p Protected branches designed to + %p Protected branches are designed to %ul - %li prevent push for all except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"} - %li prevent branch from force push - %li prevent branch from removal - %p Read more about project permissions #{link_to "here", help_page_path("permissions", "permissions"), class: "underlined-link"} + %li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"} + %li prevents anyone from force pushing to the branch + %li prevents anyone from deleting the branch + %p Read more about #{link_to "project permissions", help_page_path("permissions", "permissions"), class: "underlined-link"} - if can? current_user, :admin_project, @project = form_for [@project, @protected_branch], html: { class: 'form-horizontal' } do |f| |