Backport CE to changes to support group-level file templates

When the feature is available, this setting allows admins to choose a
project as a source of custom file templates. This is in addition to
any instance-wide templates, whether custom or vendored into the GitLab
codebase.
This commit is contained in:
Nick Thomas 2018-09-26 11:58:58 +01:00
parent 57b4884e62
commit 34480bb850
No known key found for this signature in database
GPG key ID: 2A313A47AFADACE9
6 changed files with 30 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import initSettingsPanels from '~/settings_panels';
import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory';
import mountBadgeSettings from '~/pages/shared/mount_badge_settings';
import { GROUP_BADGE } from '~/badges/constants';
import projectSelect from '~/project_select';
document.addEventListener('DOMContentLoaded', () => {
groupAvatar();
@ -15,4 +16,6 @@ document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.js-general-settings-form, .js-general-permissions-form'),
);
mountBadgeSettings(GROUP_BADGE);
projectSelect();
});

View file

@ -37,6 +37,8 @@
.settings-content
= render 'shared/badges/badge_settings'
= render_if_exists 'groups/templates_setting', expanded: expanded
%section.settings.gs-advanced.no-animate#js-advanced-settings{ class: ('expanded' if expanded) }
.settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only{ role: 'button' }

View file

@ -37,6 +37,7 @@ GET /groups
"request_access_enabled": false,
"full_name": "Foobar Group",
"full_path": "foo-bar",
"file_template_project_id": 1,
"parent_id": null
}
]
@ -62,6 +63,7 @@ GET /groups?statistics=true
"request_access_enabled": false,
"full_name": "Foobar Group",
"full_path": "foo-bar",
"file_template_project_id": 1,
"parent_id": null,
"statistics": {
"storage_size" : 212,
@ -122,6 +124,7 @@ GET /groups/:id/subgroups
"request_access_enabled": false,
"full_name": "Foobar Group",
"full_path": "foo-bar",
"file_template_project_id": 1,
"parent_id": 123
}
]
@ -232,6 +235,7 @@ Example response:
"request_access_enabled": false,
"full_name": "Twitter",
"full_path": "twitter",
"file_template_project_id": 1,
"parent_id": null,
"projects": [
{
@ -386,6 +390,7 @@ Example response:
"request_access_enabled": false,
"full_name": "Twitter",
"full_path": "twitter",
"file_template_project_id": 1,
"parent_id": null
}
```
@ -442,6 +447,7 @@ PUT /groups/:id
| `visibility` | string | no | The visibility level of the group. Can be `private`, `internal`, or `public`. |
| `lfs_enabled` (optional) | boolean | no | Enable/disable Large File Storage (LFS) for the projects in this group |
| `request_access_enabled` | boolean | no | Allow users to request member access. |
| `file_template_project_id` | integer | no | **(Premium)** The ID of a project to load custom file templates from |
```bash
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/5?name=Experimental"
@ -462,6 +468,7 @@ Example response:
"request_access_enabled": false,
"full_name": "Foobar Group",
"full_path": "foo-bar",
"file_template_project_id": 1,
"parent_id": null,
"projects": [
{

View file

@ -1,19 +1,23 @@
# Project templates API
This API is a project-specific implementation of these endpoints:
This API is a project-specific version of these endpoints:
- [Dockerfile templates](templates/dockerfiles.md)
- [Gitignore templates](templates/gitignores.md)
- [GitLab CI Config templates](templates/gitlab_ci_ymls.md)
- [Open source license templates](templates/licenses.md)
It deprecates those endpoints, which will be removed for API version 5.
It deprecates these endpoints, which will be removed for API version 5.
Project-specific templates will be added to this API in time. This includes, but
is not limited to:
In addition to templates common to the entire instance, project-specific
templates are also available from this API endpoint.
- [Issue and Merge Request templates](../user/project/description_templates.html)
- [Group level file templates](https://gitlab.com/gitlab-org/gitlab-ee/issues/5987) **(Premium)**
Support will be added for [Issue and Merge Request templates](../user/project/description_templates.md)
in a future release.
Support for [Group-level file templates](../user/group/index.md#group-level-file-templates-premium)
**[PREMIUM]** was [added](https://gitlab.com/gitlab-org/gitlab-ee/issues/5987)
in GitLab 11.5
## Get all templates of a particular type

View file

@ -252,6 +252,13 @@ level of members in group.
Learn more about [Member Lock](https://docs.gitlab.com/ee/user/group/index.html#member-lock).
#### Group-level file templates **[PREMIUM]**
Group-level file templates allow you to share a set of templates for common file
types with every project in a group.
Learn more about [Group-level file templates](https://docs.gitlab.com/ee/user/group/index.html#group-level-file-templates-premium).
### Advanced settings
- **Projects**: view all projects within that group, add members to each project,

View file

@ -1,7 +1,7 @@
module Gitlab
module Template
class BaseTemplate
attr_reader :category
attr_accessor :category
def initialize(path, project = nil, category: nil)
@path = path