Commit b8deafd0 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Removed merge_request/issue state_event param parent and removed issuable_path...

Removed merge_request/issue state_event param parent and removed issuable_path helpers in favour of issuable_url helpers
parent 001c904f
......@@ -271,7 +271,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def issue_params
params.require(:issue).permit(*issue_params_attributes)
params.permit(*issue_params_attributes)
end
def issue_params_attributes
......
......@@ -17,8 +17,7 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
end
def merge_request_params
params.require(:merge_request)
.permit(merge_request_params_attributes)
params.permit(merge_request_params_attributes)
end
def merge_request_params_attributes
......
......@@ -245,36 +245,30 @@ module IssuablesHelper
@counts[cache_key][state]
end
def close_issuable_path(issuable)
params = state_event_hash(issuable, :close)
params[:format] = 'json' if issuable.is_a?(Issue)
def close_issuable_url(issuable)
params = {}
params[:state_event] = :close
params[:format] = :json if issuable.is_a?(Issue)
issuable_path(issuable, params)
issuable_url(issuable, params)
end
def reopen_issuable_path(issuable)
params = state_event_hash(issuable, :reopen)
params[:format] = 'json' if issuable.is_a?(Issue)
def reopen_issuable_url(issuable)
params = {}
params[:state_event] = :reopen
params[:format] = :json if issuable.is_a?(Issue)
issuable_path(issuable, params)
issuable_url(issuable, params)
end
def close_reopen_issuable_path(issuable)
issuable.closed? ? reopen_issuable_path(issuable) : close_issuable_path(issuable)
def close_reopen_issuable_url(issuable)
issuable.closed? ? reopen_issuable_url(issuable) : close_issuable_url(issuable)
end
def issuable_path(issuable, *path_options)
def issuable_url(issuable, *options)
case issuable
when Issue then issue_path(issuable, *path_options)
when MergeRequest then merge_request_path(issuable, *path_options)
else raise 'unknown issuable type'
end
end
def issuable_url(issuable, *path_options)
case issuable
when Issue then issue_url(issuable, *path_options)
when MergeRequest then merge_request_url(issuable, *path_options)
when Issue then issue_url(issuable, *options)
when MergeRequest then merge_request_url(issuable, *options)
else raise 'unknown issuable type'
end
end
......@@ -335,11 +329,4 @@ module IssuablesHelper
container: (is_collapsed ? 'body' : nil)
}
end
def state_event_hash(issuable, event_symbol)
event_hash = {}
event_hash[:"#{issuable.class.to_s.underscore}"] = { state_event: event_symbol }
event_hash
end
end
......@@ -7,13 +7,13 @@
- button_method = issuable.is_a?(MergeRequest) ? 'put' : ''
.pull-left.btn-group.prepend-left-10.issuable-close-dropdown.droplab-dropdown.js-issuable-close-dropdown
= link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_path(issuable), { method: button_method.to_s, class: "#{button_class} btn-#{button_action}", title: "#{display_button_action} #{display_issuable_type}" }
= link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_url(issuable), { method: button_method.to_s, class: "#{button_class} btn-#{button_action}", title: "#{display_button_action} #{display_issuable_type}" }
= button_tag type: 'button', class: "#{toggle_class} btn-#{button_action}-color", data: { 'dropdown-trigger' => '#issuable-close-menu' }, 'aria-label' => 'Toggle dropdown' do
= icon('caret-down', class: 'toggle-icon icon')
%ul#issuable-close-menu.js-issuable-close-menu.dropdown-menu{ class: button_responsive_class, data: { dropdown: true } }
%li.close-item{ class: "#{issuable.closed? ? 'hidden' : 'droplab-item-selected'}", data: { text: "Close #{display_issuable_type}", url: close_issuable_path(issuable), button_class: "#{button_class} btn-close", toggle_class: "#{toggle_class} btn-close-color", method: button_method } }
%li.close-item{ class: "#{issuable.closed? ? 'hidden' : 'droplab-item-selected'}", data: { text: "Close #{display_issuable_type}", url: close_issuable_url(issuable), button_class: "#{button_class} btn-close", toggle_class: "#{toggle_class} btn-close-color", method: button_method } }
%button.btn.btn-transparent
= icon('check', class: 'icon')
.description
......@@ -22,7 +22,7 @@
= display_issuable_type
%p
%li.reopen-item{ class: "#{issuable.closed? ? 'droplab-item-selected' : 'hidden'}", data: { text: "Reopen #{display_issuable_type}", url: reopen_issuable_path(issuable), button_class: "#{button_class} btn-reopen", toggle_class: "#{toggle_class} btn-reopen-color", method: button_method } }
%li.reopen-item{ class: "#{issuable.closed? ? 'droplab-item-selected' : 'hidden'}", data: { text: "Reopen #{display_issuable_type}", url: reopen_issuable_url(issuable), button_class: "#{button_class} btn-reopen", toggle_class: "#{toggle_class} btn-reopen-color", method: button_method } }
%button.btn.btn-transparent
= icon('check', class: 'icon')
.description
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment