Add SPDX licenses to license compliance - Switch hard coded list to value from Ruby
This is a subissue for #34209 (closed)
As part of the work for #34209 (closed) we want to switch from using a hard coded license list in ee/app/assets/javascripts/vue_shared/license_management/constants.js to use the dynamically updated SPDX list.
Feature Implementation Plan
We should swap out the constant in ee/app/assets/javascripts/vue_shared/license_management/components/add_license_form_dropdown.vue
data: KNOWN_LICENSES.map(license => ({ id: license, text: license })),
to use a variable passed in from the HAML template. In:
ee/app/views/projects/licenses/index.html.haml
Something like:
#js-managed-licenses{ data: { api_url: @license_management_url, license_dropdown_list: <LICENSES_FROM RUBY> } }
Then in:
ee/app/assets/javascripts/license_compliance/index.js
we do:
store.dispatch('licenseManagement/setLicenseDropDownList', el.dataset.license_dropdown_list);
We'd need to add VueX action, mutation, and store property to save this.
And then in:
ee/app/assets/javascripts/vue_shared/license_compliance/components/add_license_form.vue
We'd want to use mapState
to access that list and pass it down as a prop to
ee/app/assets/javascripts/vue_shared/license_compliance/components/add_license_form_dropdown.vue
Unit Test Implementation Plan
- Test new action, mutation, and store related to the new
setLicenseDropDownList
action - Update existing unit tests in
add_license_form.vue
to use dropdown array from the store. It currently does not use the list directly since the child component imports a static list. It will pass it down as a prop, so we need to test the property is defined withmapState
- Update
add_license_form_dropdown.vue
unit test to use the list values from a prop instead of a constant.