2021-11-11 11:23:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class JiraConnect::InstallationsController < JiraConnect::ApplicationController
|
|
|
|
def index
|
|
|
|
render json: installation_json(current_jira_installation)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2023-03-04 22:38:38 +05:30
|
|
|
result = update_installation
|
|
|
|
if result.success?
|
2021-11-11 11:23:49 +05:30
|
|
|
render json: installation_json(current_jira_installation)
|
|
|
|
else
|
|
|
|
render(
|
2023-03-04 22:38:38 +05:30
|
|
|
json: { errors: result.message },
|
2021-11-11 11:23:49 +05:30
|
|
|
status: :unprocessable_entity
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
def update_installation
|
|
|
|
JiraConnectInstallations::UpdateService.execute(
|
|
|
|
current_jira_installation,
|
|
|
|
installation_params
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
def installation_json(installation)
|
|
|
|
{
|
|
|
|
gitlab_com: installation.instance_url.blank?,
|
|
|
|
instance_url: installation.instance_url
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def installation_params
|
|
|
|
params.require(:installation).permit(:instance_url)
|
|
|
|
end
|
|
|
|
end
|