debian-mirror-gitlab/app/controllers/projects/service_desk_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.4 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
class Projects::ServiceDeskController < Projects::ApplicationController
before_action :authorize_admin_project!
2021-01-03 14:25:43 +05:30
feature_category :service_desk
2022-04-04 11:22:00 +05:30
urgency :low
2021-01-03 14:25:43 +05:30
2020-07-28 23:09:34 +05:30
def show
json_response
end
def update
Projects::UpdateService.new(project, current_user, { service_desk_enabled: params[:service_desk_enabled] }).execute
result = ServiceDeskSettings::UpdateService.new(project, current_user, setting_params).execute
if result[:status] == :success
json_response
else
render json: { message: result[:message] }, status: :unprocessable_entity
end
end
private
def setting_params
2021-11-11 11:23:49 +05:30
params.permit(*allowed_update_attributes)
end
def allowed_update_attributes
2023-03-04 22:38:38 +05:30
%i[issue_template_key outgoing_name project_key]
2021-11-11 11:23:49 +05:30
end
def service_desk_attributes
service_desk_settings = project.service_desk_setting
{
service_desk_address: project.service_desk_address,
service_desk_enabled: project.service_desk_enabled,
issue_template_key: service_desk_settings&.issue_template_key,
template_file_missing: service_desk_settings&.issue_template_missing?,
outgoing_name: service_desk_settings&.outgoing_name,
project_key: service_desk_settings&.project_key
}
2020-07-28 23:09:34 +05:30
end
def json_response
respond_to do |format|
format.json { render json: service_desk_attributes }
end
end
end
2021-11-11 11:23:49 +05:30
Projects::ServiceDeskController.prepend_mod