Module: IssuableActions
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
Instance Method Details
#bulk_update ⇒ Object
111
112
113
114
115
116
117
118
119
120
|
# File 'app/controllers/concerns/issuable_actions.rb', line 111
def bulk_update
result = Issuable::BulkUpdateService.new(parent, current_user, bulk_update_params).execute(resource_name)
if result.success?
quantity = result.payload[:count]
render json: { notice: "#{quantity} #{resource_name.pluralize(quantity)} updated" }
elsif result.error?
render json: { errors: result.message }, status: result.http_status
end
end
|
#check_destroy_confirmation! ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'app/controllers/concerns/issuable_actions.rb', line 86
def check_destroy_confirmation!
return true if params[:destroy_confirm]
error_message = "Destroy confirmation not provided for #{issuable.human_class_name}"
exception = RuntimeError.new(error_message)
Gitlab::ErrorTracking.track_exception(
exception,
project_path: issuable.project.full_path,
issuable_type: issuable.class.name,
issuable_id: issuable.id
)
index_path = polymorphic_path([parent, issuable.class])
respond_to do |format|
format.html do
flash[:notice] = error_message
redirect_to index_path
end
format.json do
render json: { errors: error_message }, status: :unprocessable_entity
end
end
end
|
#destroy ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'app/controllers/concerns/issuable_actions.rb', line 69
def destroy
Issuable::DestroyService.new(issuable.project, current_user).execute(issuable)
name = issuable.human_class_name
flash[:notice] = "The #{name} was successfully deleted."
index_path = polymorphic_path([parent, issuable.class])
respond_to do |format|
format.html { redirect_to index_path }
format.json do
render json: {
web_url: index_path
}
end
end
end
|
#discussions ⇒ Object
rubocop:disable CodeReuse/ActiveRecord
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'app/controllers/concerns/issuable_actions.rb', line 123
def discussions
notes = NotesFinder.new(current_user, finder_params_for_issuable).execute
.inc_relations_for_view
.includes(:noteable)
.fresh
if notes_filter != UserPreference::NOTES_FILTERS[:only_comments]
notes = ResourceEvents::MergeIntoNotesService.new(issuable, current_user).execute(notes)
end
notes = prepare_notes_for_rendering(notes)
notes = notes.select { |n| n.readable_by?(current_user) }
discussions = Discussion.build_collection(notes, issuable)
render json: discussion_serializer.represent(discussions, context: self)
end
|
#realtime_changes ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/concerns/issuable_actions.rb', line 48
def realtime_changes
Gitlab::PollingInterval.(response, interval: 3_000)
response = {
title: view_context.markdown_field(issuable, :title),
title_text: issuable.title,
description: view_context.markdown_field(issuable, :description),
description_text: issuable.description,
task_status: issuable.task_status,
lock_version: issuable.lock_version
}
if issuable.edited?
response[:updated_at] = issuable.last_edited_at.to_time.iso8601
response[:updated_by_name] = issuable.last_edited_by.name
response[:updated_by_path] = user_path(issuable.last_edited_by)
end
render json: response
end
|
#show ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/concerns/issuable_actions.rb', line 19
def show
respond_to do |format|
format.html do
@issuable_sidebar = serializer.represent(issuable, serializer: 'sidebar') render 'show'
end
format.json do
render json: serializer.represent(issuable, serializer: params[:serializer])
end
end
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/concerns/issuable_actions.rb', line 32
def update
@issuable = update_service.execute(issuable) respond_to do |format|
format.html do
recaptcha_check_if_spammable { render :edit }
end
format.json do
recaptcha_check_if_spammable(false) { render_entity_json }
end
end
rescue ActiveRecord::StaleObjectError
render_conflict_response
end
|