Commit 9cfdefdc authored by Fernando's avatar Fernando

Fix broken license policy page

* Due to
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/22465

landing after changes in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24831

there was a mismatch in variable names being passed from
the controller.

* MR fixe the variable names and updates unit tests

Fix robot cop offenses

Add changelog
parent bb3ca457
---
title: Fix broken license policy page
merge_request: 25300
author:
type: fixed
...@@ -28,8 +28,8 @@ module Projects ...@@ -28,8 +28,8 @@ module Projects
def create def create
result = ::Projects::Licenses::CreatePolicyService result = ::Projects::Licenses::CreatePolicyService
.new(project, current_user, software_license_policy_params) .new(project, current_user, software_license_policy_params)
.execute .execute
if result[:status] == :success if result[:status] == :success
render json: LicenseEntity.represent(result[:software_license_policy]), status: :created render json: LicenseEntity.represent(result[:software_license_policy]), status: :created
...@@ -40,8 +40,8 @@ module Projects ...@@ -40,8 +40,8 @@ module Projects
def update def update
result = ::Projects::Licenses::UpdatePolicyService result = ::Projects::Licenses::UpdatePolicyService
.new(project, current_user, software_license_policy_params) .new(project, current_user, software_license_policy_params)
.execute(params[:id]) .execute(params[:id])
if result[:status] == :success if result[:status] == :success
render json: LicenseEntity.represent(result[:software_license_policy]), status: :ok render json: LicenseEntity.represent(result[:software_license_policy]), status: :ok
...@@ -54,7 +54,7 @@ module Projects ...@@ -54,7 +54,7 @@ module Projects
def serializer def serializer
::LicensesListSerializer.new(project: project, user: current_user) ::LicensesListSerializer.new(project: project, user: current_user)
.with_pagination(request, response) .with_pagination(request, response)
end end
def pageable(items) def pageable(items)
...@@ -85,11 +85,21 @@ module Projects ...@@ -85,11 +85,21 @@ module Projects
value.in?(%w[true 1]) value.in?(%w[true 1])
end end
def write_license_policies_endpoint
if can?(current_user, :admin_software_license_policy, @project)
api_v4_projects_managed_licenses_path(id: @project.id)
else
''
end
end
def licenses_app_data def licenses_app_data
{ {
endpoint: project_licenses_path(project, detected: true, format: :json), project_licenses_endpoint: project_licenses_path(@project, detected: true, format: :json),
documentation_path: help_page_path('user/application_security/license_compliance/index'), read_license_policies_endpoint: api_v4_projects_managed_licenses_path(id: @project.id),
empty_state_svg_path: helpers.image_path('illustrations/Dependency-list-empty-state.svg') write_license_policies_endpoint: write_license_policies_endpoint,
documentation_path: help_page_path('user/application_security/license_compliance/index'),
empty_state_svg_path: helpers.image_path('illustrations/Dependency-list-empty-state.svg')
} }
end end
end end
......
- breadcrumb_title _('License Compliance') - breadcrumb_title _('License Compliance')
- page_title _('License Compliance') - page_title _('License Compliance')
#js-licenses-app{ data: licenses_app_data } #js-licenses-app{ data: @licenses_app_data }
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