Core backports from the Premium license templates feature
What does this MR do?
Backports a number of changes to license template handling from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6631
Chiefly, since license templates may now come from a range of sources, we introduce our own model (::LicenseTemplate
), and a finder (::LicenseTemplateFinder
), which work together to query all those sources. Two sites are then changed to use these finders instead of Licensee::License
:
- Helper method:
licenses_for_select
- API endpoint:
/api/v4/templates/licenses[/:name]
In Core, the only source is the existing Licensee::License.all
set of licenses. So this is a re-organisation, but effectively a no-operation.
In Premium, we add an instance-wide "custom file templates project" setting, which can hold additional license templates that operate instance-wide.
In the future, we may wish to add group license templates or further sources of licenses. Keeping all the logic for that in a Finder means we don't have to repeat it across the various sites that need to display licenses.
There are also a number of preparatory commits:
-
ffd164d2 fixes a number of small bugs preventing
Gitlab::Template::BaseTemplate.all
from building instances that can read template content -
b68d6470 enhances
project_select_tag
with functionality used in the EE admin panel -
239b7843 adds the necessary JS to
/admin/application_settings
forproject_select_tag
to work, along with arender_if_exists
for EE-specific template settings. It's used in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6631
What are the relevant issue numbers?
Does this MR meet the acceptance criteria?
- [-] Changelog entry added, if necessary
- [-] Documentation created/updated
-
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides - [-] Conforms to the database guides