summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-03-15 14:43:40 +0000
committerPhil Hughes <me@iamphill.com>2016-04-06 11:08:40 +0100
commitc5c05f6a04ab3c791bc7c34dc74925731cf2ff94 (patch)
tree358d49e1fbbf02500113a2c9c251165e191efd43
parentf76bfed9fc3e52c7b3b731dbb311b6b394d9af62 (diff)
downloadgitlab-ce-c5c05f6a04ab3c791bc7c34dc74925731cf2ff94.tar.gz
Updated UI for new merge request
Closes #2540
-rw-r--r--app/assets/javascripts/compare.js.coffee61
-rw-r--r--app/assets/stylesheets/pages/merge_requests.scss51
-rw-r--r--app/controllers/projects/merge_requests_controller.rb2
-rw-r--r--app/helpers/commits_helper.rb4
-rw-r--r--app/views/projects/commits/_commit.html.haml2
-rw-r--r--app/views/projects/merge_requests/_new_compare.html.haml71
-rw-r--r--app/views/projects/merge_requests/branch_from.html.haml1
-rw-r--r--app/views/projects/merge_requests/branch_from.js.haml3
-rw-r--r--app/views/projects/merge_requests/branch_to.html.haml1
-rw-r--r--app/views/projects/merge_requests/branch_to.js.haml3
10 files changed, 138 insertions, 61 deletions
diff --git a/app/assets/javascripts/compare.js.coffee b/app/assets/javascripts/compare.js.coffee
new file mode 100644
index 00000000000..c13744ebc62
--- /dev/null
+++ b/app/assets/javascripts/compare.js.coffee
@@ -0,0 +1,61 @@
+class @Compare
+ constructor: (@opts) ->
+ @source_loading = $ ".js-source-loading"
+ @target_loading = $ ".js-target-loading"
+ @source_branch = $ "#merge_request_source_branch"
+ @target_branch = $ "#merge_request_target_branch"
+ @target_project = $ "#merge_request_target_project_id"
+
+ @initialState()
+ @cleanBinding()
+ @addBinding()
+
+ cleanBinding: ->
+ @source_branch.off "change"
+ @target_branch.off "change"
+ @target_project.off "change"
+
+ addBinding: ->
+ @source_branch.on "change", =>
+ @getSourceHtml()
+ @target_branch.on "change", =>
+ @getTargetHtml()
+ @target_project.on "change", =>
+ @getTargetProject()
+
+ initialState: ->
+ @getSourceHtml()
+ @getTargetHtml()
+
+ getTargetProject: ->
+ $.get @opts.targetProjectUrl,
+ target_project_id: @target_project.val()
+
+ getSourceHtml: ->
+ $.ajax(
+ url: @opts.sourceBranchUrl
+ data:
+ ref: @source_branch.val()
+ beforeSend: =>
+ @source_loading.show()
+ $(".mr_source_commit").html ""
+ success: (html) =>
+ @source_loading.hide()
+ $(".mr_source_commit").html html
+ $(".mr_source_commit .js-timeago").timeago()
+ )
+
+ getTargetHtml: ->
+ $.ajax(
+ url: @opts.targetBranchUrl
+ data:
+ target_project_id: @target_project.val()
+ ref: @target_branch.val()
+ beforeSend: =>
+ @target_loading.show()
+ $(".mr_target_commit").html ""
+ success: (html) =>
+ @target_loading.hide()
+ $(".mr_target_commit").html html
+ $(".mr_target_commit .js-timeago").timeago()
+ )
diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss
index 1c6a4208974..7bc1f58471f 100644
--- a/app/assets/stylesheets/pages/merge_requests.scss
+++ b/app/assets/stylesheets/pages/merge_requests.scss
@@ -123,6 +123,8 @@
.mr_source_commit,
.mr_target_commit {
+ margin-bottom: 0;
+
.commit {
margin: 0;
padding: 2px 0;
@@ -174,10 +176,6 @@
display: none;
}
-.merge-request-form .select2-container {
- width: 250px !important;
-}
-
#modal_merge_info .modal-dialog {
width: 600px;
@@ -200,3 +198,48 @@
overflow-x: scroll;
}
}
+
+.panel-new-merge-request {
+ .panel-heading {
+ padding: 5px 10px;
+ font-weight: 600;
+ line-height: 25px;
+ }
+
+ .panel-body {
+ padding: 10px 5px;
+ }
+
+ .panel-footer {
+ padding: 10px 10px;
+ }
+
+ .commit {
+ .commit-row-title {
+ margin-bottom: 4px;
+ }
+
+ .avatar {
+ width: 20px;
+ height: 20px;
+ margin-right: 5px;
+ }
+
+ .commit-row-info {
+ line-height: 20px;
+ }
+ }
+
+ .btn-clipboard {
+ margin-right: 5px;
+ padding: 0;
+ background: transparent;
+ }
+}
+
+.merge-request-select {
+ float: left;
+ width: 50%;
+ padding-left: 5px;
+ padding-right: 5px;
+}
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 49064f5d505..ca6cfc99143 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -207,11 +207,13 @@ class Projects::MergeRequestsController < Projects::ApplicationController
#This is always source
@source_project = @merge_request.nil? ? @project : @merge_request.source_project
@commit = @repository.commit(params[:ref]) if params[:ref].present?
+ render layout: false
end
def branch_to
@target_project = selected_target_project
@commit = @target_project.commit(params[:ref]) if params[:ref].present?
+ render layout: false
end
def update_branches
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index bde0799f3de..a65e2e5cb8f 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -28,7 +28,7 @@ module CommitsHelper
def commit_to_html(commit, project, inline = true)
template = inline ? "inline_commit" : "commit"
- escape_javascript(render "projects/commits/#{template}", commit: commit, project: project) unless commit.nil?
+ render "projects/commits/#{template}", commit: commit, project: project unless commit.nil?
end
# Breadcrumb links for a Project and, if applicable, a tree path
@@ -117,7 +117,7 @@ module CommitsHelper
end
end
link_to(
- "Browse Files ยป",
+ "Browse Files",
namespace_project_tree_path(project.namespace, project, commit),
class: "pull-right"
)
diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml
index 7f2903589a9..b55fe510f70 100644
--- a/app/views/projects/commits/_commit.html.haml
+++ b/app/views/projects/commits/_commit.html.haml
@@ -35,8 +35,8 @@
= preserve(markdown(escape_once(commit.description), pipeline: :single_line))
.commit-row-info
+ by
= commit_author_link(commit, avatar: true, size: 24)
- authored
.committed_ago
#{time_ago_with_tooltip(commit.committed_date, skip_js: true)} &nbsp;
= link_to_browse_code(project, commit)
diff --git a/app/views/projects/merge_requests/_new_compare.html.haml b/app/views/projects/merge_requests/_new_compare.html.haml
index 01dc7519bee..4fc74dfcf45 100644
--- a/app/views/projects/merge_requests/_new_compare.html.haml
+++ b/app/views/projects/merge_requests/_new_compare.html.haml
@@ -5,27 +5,31 @@
.hide.alert.alert-danger.mr-compare-errors
.merge-request-branches.row
.col-md-6
- .panel.panel-default
+ .panel.panel-default.panel-new-merge-request
.panel-heading
- %strong Source branch
- .panel-body
- = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted?, required: true })
- &nbsp;
- = f.select(:source_branch, @merge_request.source_branches, { include_blank: true }, { class: 'source_branch select2 span2', required: true, data: { placeholder: "Select source branch" } })
+ Source branch
+ .panel-body.clearfix
+ .merge-request-select
+ = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2', disabled: @merge_request.persisted?, required: true })
+ .merge-request-select
+ = f.select(:source_branch, @merge_request.source_branches, { include_blank: true }, { class: 'source_branch select2', required: true, data: { placeholder: "Select source branch" } })
.panel-footer
- .mr_source_commit
+ = icon('spinner spin', class: "js-source-loading")
+ %ul.list-unstyled.mr_source_commit
.col-md-6
- .panel.panel-default
+ .panel.panel-default.panel-new-merge-request
.panel-heading
- %strong Target branch
- .panel-body
+ Target branch
+ .panel-body.clearfix
- projects = @project.forked_from_project.nil? ? [@project] : [@project, @project.forked_from_project]
- = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace', f.object.target_project_id), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted?, required: true })
- &nbsp;
- = f.select(:target_branch, @merge_request.target_branches, { include_blank: true }, { class: 'target_branch select2 span2', required: true, data: { placeholder: "Select target branch" } })
+ .merge-request-select
+ = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace', f.object.target_project_id), {}, { class: 'target_project select2', disabled: @merge_request.persisted?, required: true })
+ .merge-request-select
+ = f.select(:target_branch, @merge_request.target_branches, { include_blank: true }, { class: 'target_branch select2', required: true, data: { placeholder: "Select target branch" } })
.panel-footer
- .mr_target_commit
+ = icon('spinner spin', class: "js-target-loading")
+ %ul.list-unstyled.mr_target_commit
- if @merge_request.errors.any?
.alert.alert-danger
@@ -45,40 +49,11 @@
and
%span.label-branch #{@merge_request.target_branch}
are the same.
-
-
- .form-actions
- = f.submit 'Compare branches and continue', class: "btn btn-new mr-compare-btn"
-
-:javascript
- var source_branch = $("#merge_request_source_branch")
- , target_branch = $("#merge_request_target_branch")
- , target_project = $("#merge_request_target_project_id");
-
- $.get("#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {ref: source_branch.val() });
- $.get("#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() });
-
- target_project.on("change", function() {
- $.get("#{update_branches_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {target_project_id: $(this).val() });
- });
- source_branch.on("change", function() {
- $.get("#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {ref: $(this).val() });
- $(".mr-compare-errors").fadeOut();
- $(".mr-compare-btn").enable();
- });
- target_branch.on("change", function() {
- $.get("#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
- $(".mr-compare-errors").fadeOut();
- $(".mr-compare-btn").enable();
- });
-
+ = f.submit 'Compare branches and continue', class: "btn btn-new mr-compare-btn"
:javascript
- $(".merge-request-form").on('submit', function () {
- if ($("#merge_request_source_branch").val() === "" || $('#merge_request_target_branch').val() === "") {
- $(".mr-compare-errors").html("You must select source and target branch to proceed");
- $(".mr-compare-errors").fadeIn();
- event.preventDefault();
- return;
- }
+ new Compare({
+ targetProjectUrl: "#{update_branches_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}",
+ sourceBranchUrl: "#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}",
+ targetBranchUrl: "#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}"
});
diff --git a/app/views/projects/merge_requests/branch_from.html.haml b/app/views/projects/merge_requests/branch_from.html.haml
new file mode 100644
index 00000000000..4f90dde6fa8
--- /dev/null
+++ b/app/views/projects/merge_requests/branch_from.html.haml
@@ -0,0 +1 @@
+= commit_to_html(@commit, @source_project, false)
diff --git a/app/views/projects/merge_requests/branch_from.js.haml b/app/views/projects/merge_requests/branch_from.js.haml
deleted file mode 100644
index 9210798f39c..00000000000
--- a/app/views/projects/merge_requests/branch_from.js.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-:plain
- $(".mr_source_commit").html("#{commit_to_html(@commit, @source_project, false)}");
- $('.js-timeago').timeago()
diff --git a/app/views/projects/merge_requests/branch_to.html.haml b/app/views/projects/merge_requests/branch_to.html.haml
new file mode 100644
index 00000000000..67a7a6bcec9
--- /dev/null
+++ b/app/views/projects/merge_requests/branch_to.html.haml
@@ -0,0 +1 @@
+= commit_to_html(@commit, @target_project, false)
diff --git a/app/views/projects/merge_requests/branch_to.js.haml b/app/views/projects/merge_requests/branch_to.js.haml
deleted file mode 100644
index 32fe2d535f3..00000000000
--- a/app/views/projects/merge_requests/branch_to.js.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-:plain
- $(".mr_target_commit").html("#{commit_to_html(@commit, @target_project, false)}");
- $('.js-timeago').timeago()