summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-25 16:04:50 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-25 16:04:50 +0200
commit2d31568b27d60b2868d60da905018bdcba862c59 (patch)
treeb914671c3e95ff67ea81cdf3a23605edc44eec45 /app
parentd315d1eba4f45c4c4f0417fbdcd3eaf69e102282 (diff)
downloadgitlab-ce-2d31568b27d60b2868d60da905018bdcba862c59.tar.gz
Refactor issue and merge request sidebar
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee2
-rw-r--r--app/assets/javascripts/issuable_context.js.coffee22
-rw-r--r--app/assets/javascripts/issue.js.coffee17
-rw-r--r--app/assets/javascripts/merge_request.js.coffee18
-rw-r--r--app/helpers/gitlab_routing_helper.rb8
-rw-r--r--app/views/projects/issues/_discussion.html.haml2
-rw-r--r--app/views/projects/issues/_issue_context.html.haml47
-rw-r--r--app/views/projects/issues/show.html.haml2
-rw-r--r--app/views/projects/issues/update.js.haml18
-rw-r--r--app/views/projects/merge_requests/_discussion.html.haml2
-rw-r--r--app/views/projects/merge_requests/_show.html.haml2
-rw-r--r--app/views/projects/merge_requests/show/_context.html.haml49
-rw-r--r--app/views/projects/merge_requests/update.js.haml11
-rw-r--r--app/views/shared/issuable/_context.html.haml50
14 files changed, 89 insertions, 161 deletions
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
index 84873e389ea..45383fc96aa 100644
--- a/app/assets/javascripts/dispatcher.js.coffee
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -135,8 +135,6 @@ class Dispatcher
new ProjectNew()
when 'show'
new ProjectShow()
- when 'issues', 'merge_requests'
- new UsersSelect()
when 'wikis'
new Wikis()
shortcut_handler = new ShortcutsNavigation()
diff --git a/app/assets/javascripts/issuable_context.js.coffee b/app/assets/javascripts/issuable_context.js.coffee
new file mode 100644
index 00000000000..176d9cabefa
--- /dev/null
+++ b/app/assets/javascripts/issuable_context.js.coffee
@@ -0,0 +1,22 @@
+#= require jquery.waitforimages
+
+class @IssuableContext
+ constructor: ->
+ new UsersSelect()
+ $('select.select2').select2({width: 'resolve', dropdownAutoWidth: true})
+
+ $(".context .inline-update").on "change", "select", ->
+ $(this).submit()
+ $(".context .inline-update").on "change", ".js-assignee", ->
+ $(this).submit()
+
+ $('.issuable-details').waitForImages ->
+ $('.issuable-affix').affix offset:
+ top: ->
+ @top = ($('.issuable-affix').offset().top - 70)
+ bottom: ->
+ @bottom = $('.footer').outerHeight(true)
+ $('.issuable-affix').on 'affix.bs.affix', ->
+ $(@).width($(@).outerWidth())
+ .on 'affixed-top.bs.affix affixed-bottom.bs.affix', ->
+ $(@).width('')
diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee
index 74d6b80be5e..9bb85300848 100644
--- a/app/assets/javascripts/issue.js.coffee
+++ b/app/assets/javascripts/issue.js.coffee
@@ -3,29 +3,12 @@
class @Issue
constructor: ->
- $('.edit-issue.inline-update input[type="submit"]').hide()
- $(".context .inline-update").on "change", "select", ->
- $(this).submit()
- $(".context .inline-update").on "change", "#issue_assignee_id", ->
- $(this).submit()
-
# Prevent duplicate event bindings
@disableTaskList()
if $("a.btn-close").length
@initTaskList()
- $('.issue-details').waitForImages ->
- $('.issuable-affix').affix offset:
- top: ->
- @top = ($('.issuable-affix').offset().top - 70)
- bottom: ->
- @bottom = $('.footer').outerHeight(true)
- $('.issuable-affix').on 'affix.bs.affix', ->
- $(@).width($(@).outerWidth())
- .on 'affixed-top.bs.affix affixed-bottom.bs.affix', ->
- $(@).width('')
-
initTaskList: ->
$('.issue-details .js-task-list-container').taskList('enable')
$(document).on 'tasklist:changed', '.issue-details .js-task-list-container', @updateTaskList
diff --git a/app/assets/javascripts/merge_request.js.coffee b/app/assets/javascripts/merge_request.js.coffee
index 5c0bc686111..ac5471702f3 100644
--- a/app/assets/javascripts/merge_request.js.coffee
+++ b/app/assets/javascripts/merge_request.js.coffee
@@ -26,28 +26,10 @@ class @MergeRequest
if $("a.btn-close").length
@initTaskList()
- $('.merge-request-details').waitForImages ->
- $('.issuable-affix').affix offset:
- top: ->
- @top = ($('.issuable-affix').offset().top - 70)
- bottom: ->
- @bottom = $('.footer').outerHeight(true)
- $('.issuable-affix').on 'affix.bs.affix', ->
- $(@).width($(@).outerWidth())
- .on 'affixed-top.bs.affix affixed-bottom.bs.affix', ->
- $(@).width('')
-
# Local jQuery finder
$: (selector) ->
this.$el.find(selector)
- initContextWidget: ->
- $('.edit-merge_request.inline-update input[type="submit"]').hide()
- $(".context .inline-update").on "change", "select", ->
- $(this).submit()
- $(".context .inline-update").on "change", "#merge_request_assignee_id", ->
- $(this).submit()
-
showAllCommits: ->
this.$('.first-commits').remove()
this.$('.all-commits').removeClass 'hide'
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index 9703c8d9e9c..9d072f81092 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -52,4 +52,12 @@ module GitlabRoutingHelper
def project_snippet_url(entity, *args)
namespace_project_snippet_url(entity.project.namespace, entity.project, entity, *args)
end
+
+ def toggle_subscription_path(entity, *args)
+ if entity.is_a?(Issue)
+ toggle_subscription_namespace_project_issue_path(entity.project.namespace, entity.project, entity)
+ else
+ toggle_subscription_namespace_project_merge_request_path(entity.project.namespace, entity.project, entity)
+ end
+ end
end
diff --git a/app/views/projects/issues/_discussion.html.haml b/app/views/projects/issues/_discussion.html.haml
index 656e06ca105..a099e597294 100644
--- a/app/views/projects/issues/_discussion.html.haml
+++ b/app/views/projects/issues/_discussion.html.haml
@@ -23,7 +23,7 @@
= cross_project_reference(@project, @issue)
%hr
.context
- = render partial: 'issue_context', locals: { issue: @issue }
+ = render 'shared/issuable/context', issuable: @issue
- if @issue.labels.any?
.issuable-context-title
diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml
deleted file mode 100644
index 88b63946905..00000000000
--- a/app/views/projects/issues/_issue_context.html.haml
+++ /dev/null
@@ -1,47 +0,0 @@
-= form_for [@project.namespace.becomes(Namespace), @project, @issue], remote: true, html: {class: 'edit-issue inline-update js-issue-update'} do |f|
- %div.prepend-top-20
- .issuable-context-title
- %label
- Assignee:
- - if issue.assignee
- %strong= link_to_member(@project, @issue.assignee, size: 24)
- - else
- none
- - if can?(current_user, :modify_issue, @issue)
- = users_select_tag('issue[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @issue.assignee_id, null_user: true, first_user: true)
-
- %div.prepend-top-20.clearfix
- .issuable-context-title
- %label
- Milestone:
- - if issue.milestone
- %span.back-to-milestone
- = link_to namespace_project_milestone_path(@project.namespace, @project, @issue.milestone) do
- %strong
- %i.fa.fa-clock-o
- = @issue.milestone.title
- - else
- none
- - if can?(current_user, :modify_issue, @issue)
- = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2 select2-compact js-select2 js-milestone'})
- = hidden_field_tag :issue_context
- = f.submit class: 'btn'
-
- - if current_user
- - subscribed = @issue.subscribed?(current_user)
- %div.prepend-top-20.clearfix
- .issuable-context-title
- %label
- Subscription:
- %button.btn.btn-block.subscribe-button{:type => 'button'}
- %i.fa.fa-eye
- %span= subscribed ? "Unsubscribe" : "Subscribe"
- - subscribtion_status = subscribed ? "subscribed" : "unsubscribed"
- .subscription-status{"data-status" => subscribtion_status}
- .description-block.unsubscribed{class: ( "hidden" if subscribed )}
- You're not receiving notifications from this thread.
- .description-block.subscribed{class: ( "hidden" unless subscribed )}
- You're receiving notifications because you're subscribed to this thread.
-
-:coffeescript
- new Subscription("#{toggle_subscription_namespace_project_issue_path(@issue.project.namespace, @project, @issue)}")
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index ee1b2a08bc4..5bbb1fd4e92 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -1,6 +1,6 @@
- page_title "#{@issue.title} (##{@issue.iid})", "Issues"
.issue
- .issue-details
+ .issue-details.issuable-details
%h4.page-title
.issue-box{ class: issue_box_class(@issue) }
- if @issue.closed?
diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml
index 1d38662bff8..b7735aaf3c1 100644
--- a/app/views/projects/issues/update.js.haml
+++ b/app/views/projects/issues/update.js.haml
@@ -1,17 +1,3 @@
-- if params[:status_only]
- - if @issue.valid?
- :plain
- $("##{dom_id(@issue)}").fadeOut();
-- elsif params[:issue_context]
- $('.context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}");
- $('.context').effect('highlight');
- - if @issue.milestone
- $('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, namespace_project_milestone_path(@issue.project.namespace, @issue.project, @issue.milestone))}</span>")
- - else
- $('.milestone-nav-link').html('')
-
-
-$('select.select2').select2({width: 'resolve', dropdownAutoWidth: true})
-$('.edit-issue.inline-update input[type="submit"]').hide();
-new UsersSelect()
+$('.context').html("#{escape_javascript(render 'shared/issuable/context', issuable: @issue)}");
+$('.context').effect('highlight')
new Issue();
diff --git a/app/views/projects/merge_requests/_discussion.html.haml b/app/views/projects/merge_requests/_discussion.html.haml
index eb3dba6858d..76088b9c862 100644
--- a/app/views/projects/merge_requests/_discussion.html.haml
+++ b/app/views/projects/merge_requests/_discussion.html.haml
@@ -20,7 +20,7 @@
= cross_project_reference(@project, @merge_request)
%hr
.context
- = render partial: 'projects/merge_requests/show/context', locals: { merge_request: @merge_request }
+ = render 'shared/issuable/context', issuable: @merge_request
- if @merge_request.labels.any?
.issuable-context-title
diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml
index 9dc4a47258e..b6d9b135c70 100644
--- a/app/views/projects/merge_requests/_show.html.haml
+++ b/app/views/projects/merge_requests/_show.html.haml
@@ -1,6 +1,6 @@
- page_title "#{@merge_request.title} (##{@merge_request.iid})", "Merge Requests"
.merge-request{'data-url' => merge_request_path(@merge_request)}
- .merge-request-details
+ .merge-request-details.issuable-details
= render "projects/merge_requests/show/mr_title"
%hr
= render "projects/merge_requests/show/mr_box"
diff --git a/app/views/projects/merge_requests/show/_context.html.haml b/app/views/projects/merge_requests/show/_context.html.haml
deleted file mode 100644
index 5f2f65e0087..00000000000
--- a/app/views/projects/merge_requests/show/_context.html.haml
+++ /dev/null
@@ -1,49 +0,0 @@
-= form_for [@project.namespace.becomes(Namespace), @project, @merge_request], remote: true, html: {class: 'edit-merge_request inline-update js-merge-request-update'} do |f|
- %div.prepend-top-20
- .issuable-context-title
- %label
- Assignee:
- - if @merge_request.assignee
- %strong= link_to_member(@project, @merge_request.assignee, size: 24)
- - else
- none
- .issuable-context-selectbox
- - if can?(current_user, :modify_merge_request, @merge_request)
- = users_select_tag('merge_request[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @merge_request.assignee_id, project: @target_project, null_user: true)
-
- %div.prepend-top-20.clearfix
- .issuable-context-title
- %label
- Milestone:
- - if @merge_request.milestone
- %span.back-to-milestone
- = link_to namespace_project_milestone_path(@project.namespace, @project, @merge_request.milestone) do
- %strong
- = icon('clock-o')
- = @merge_request.milestone.title
- - else
- none
- .issuable-context-selectbox
- - if can?(current_user, :modify_merge_request, @merge_request)
- = f.select(:milestone_id, milestone_options(@merge_request), { include_blank: 'Select milestone' }, {class: 'select2 select2-compact js-select2 js-milestone'})
- = hidden_field_tag :merge_request_context
- = f.submit class: 'btn'
-
- - if current_user
- - subscribed = @merge_request.subscribed?(current_user)
- %div.prepend-top-20.clearfix
- .issuable-context-title
- %label
- Subscription:
- %button.btn.btn-block.subscribe-button{:type => 'button'}
- = icon('eye')
- %span= subscribed ? 'Unsubscribe' : 'Subscribe'
- - subscribtion_status = subscribed ? 'subscribed' : 'unsubscribed'
- .subscription-status{data: {status: subscribtion_status}}
- .description-block.unsubscribed{class: ( 'hidden' if subscribed )}
- You're not receiving notifications from this thread.
- .description-block.subscribed{class: ( 'hidden' unless subscribed )}
- You're receiving notifications because you're subscribed to this thread.
-
-:coffeescript
- new Subscription("#{toggle_subscription_namespace_project_merge_request_path(@merge_request.project.namespace, @project, @merge_request)}")
diff --git a/app/views/projects/merge_requests/update.js.haml b/app/views/projects/merge_requests/update.js.haml
index b4df1d20737..25583b2cc6f 100644
--- a/app/views/projects/merge_requests/update.js.haml
+++ b/app/views/projects/merge_requests/update.js.haml
@@ -1,8 +1,3 @@
-- if params[:merge_request_context]
- $('.context').html("#{escape_javascript(render partial: 'projects/merge_requests/show/context', locals: { issue: @issue })}");
- $('.context').effect('highlight');
-
- new UsersSelect()
-
- $('select.select2').select2({width: 'resolve', dropdownAutoWidth: true});
- merge_request = new MergeRequest();
+$('.context').html("#{escape_javascript(render 'shared/issuable/context', issuable: @merge_request)}");
+$('.context').effect('highlight')
+merge_request = new MergeRequest();
diff --git a/app/views/shared/issuable/_context.html.haml b/app/views/shared/issuable/_context.html.haml
new file mode 100644
index 00000000000..2a41448bb04
--- /dev/null
+++ b/app/views/shared/issuable/_context.html.haml
@@ -0,0 +1,50 @@
+= form_for [@project.namespace.becomes(Namespace), @project, issuable], remote: true, html: {class: 'issuable-context-form inline-update js-merge-request-update'} do |f|
+ %div.prepend-top-20
+ .issuable-context-title
+ %label
+ Assignee:
+ - if issuable.assignee
+ %strong= link_to_member(@project, issuable.assignee, size: 24)
+ - else
+ none
+ .issuable-context-selectbox
+ - if can?(current_user, :set_assignee, @project)
+ = users_select_tag("#{issuable.class.table_name.singularize}[assignee_id]", placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: issuable.assignee_id, project: @target_project, null_user: true)
+
+ %div.prepend-top-20.clearfix
+ .issuable-context-title
+ %label
+ Milestone:
+ - if issuable.milestone
+ %span.back-to-milestone
+ = link_to namespace_project_milestone_path(@project.namespace, @project, issuable.milestone) do
+ %strong
+ = icon('clock-o')
+ = issuable.milestone.title
+ - else
+ none
+ .issuable-context-selectbox
+ - if can?(current_user, :set_milestone, @project)
+ = f.select(:milestone_id, milestone_options(issuable), { include_blank: 'Select milestone' }, {class: 'select2 select2-compact js-select2 js-milestone'})
+ = hidden_field_tag :issuable_context
+ = f.submit class: 'btn hide'
+
+ - if current_user
+ - subscribed = issuable.subscribed?(current_user)
+ %div.prepend-top-20.clearfix
+ .issuable-context-title
+ %label
+ Subscription:
+ %button.btn.btn-block.subscribe-button{:type => 'button'}
+ = icon('eye')
+ %span= subscribed ? 'Unsubscribe' : 'Subscribe'
+ - subscribtion_status = subscribed ? 'subscribed' : 'unsubscribed'
+ .subscription-status{data: {status: subscribtion_status}}
+ .description-block.unsubscribed{class: ( 'hidden' if subscribed )}
+ You're not receiving notifications from this thread.
+ .description-block.subscribed{class: ( 'hidden' unless subscribed )}
+ You're receiving notifications because you're subscribed to this thread.
+
+:coffeescript
+ new Subscription("#{toggle_subscription_path(issuable)}")
+ new IssuableContext()