Commit b12fa022 authored by Jake Lear's avatar Jake Lear

Revert "Merge branch '2557-select-default-template-from-gitlab-folder' into 'master'"

This reverts merge request !76326
parent 5e6413e3
...@@ -38,8 +38,7 @@ module IssuablesDescriptionTemplatesHelper ...@@ -38,8 +38,7 @@ module IssuablesDescriptionTemplatesHelper
# Only local templates will be listed if licenses for inherited templates are not present # Only local templates will be listed if licenses for inherited templates are not present
all_templates = all_templates.values.flatten.map { |tpl| tpl[:name] }.compact.uniq all_templates = all_templates.values.flatten.map { |tpl| tpl[:name] }.compact.uniq
template = all_templates.find { |tmpl_name| tmpl_name == params[:issuable_template] } all_templates.find { |tmpl_name| tmpl_name == params[:issuable_template] }
template || all_templates.find { |tmpl_name| tmpl_name.casecmp?('default') }
end end
def available_service_desk_templates_for(project) def available_service_desk_templates_for(project)
......
...@@ -116,8 +116,6 @@ You might also be interested in templates for various ...@@ -116,8 +116,6 @@ You might also be interested in templates for various
### Set a default template for merge requests and issues **(PREMIUM)** ### Set a default template for merge requests and issues **(PREMIUM)**
> The `default.md` template becoming the default [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76326) in GitLab 14.7.
In a project, you can choose a default description template for new issues and merge requests. In a project, you can choose a default description template for new issues and merge requests.
As a result, every time a new merge request or issue is created, it's pre-filled with the text you As a result, every time a new merge request or issue is created, it's pre-filled with the text you
entered in the template. entered in the template.
...@@ -127,29 +125,17 @@ Prerequisites: ...@@ -127,29 +125,17 @@ Prerequisites:
- On your project's left sidebar, select **Settings > General** and expand **Visibility, project features, permissions**. - On your project's left sidebar, select **Settings > General** and expand **Visibility, project features, permissions**.
Ensure issues or merge requests are set to either **Everyone with access** or **Only Project Members**. Ensure issues or merge requests are set to either **Everyone with access** or **Only Project Members**.
To set a default description template for merge requests, either: To set a default description template for merge requests:
- [Create a merge request template](#create-a-merge-request-template) named `default.md` and save it in `.gitlab/merge_request_templates/`.
**If a `default.md` file exists, it's used as the default template even if you select another one in the project settings.**
- Select the default template in project settings:
1. On the top bar, select **Menu > Projects** and find your project. 1. Go to your project's **Settings**.
1. On the left sidebar, select **Settings**. 1. Select **Expand** under the **Merge requests** header.
1. Expand **Merge requests**. 1. Fill in the **Default description template for merge requests** text area.
1. Fill in the **Default description template for merge requests** text area. 1. Select **Save changes**.
1. Select **Save changes**.
To set a default description template for issues, either:
- [Create an issue template](#create-an-issue-template) named `default.md` and save it in `.gitlab/issue_templates/`. To set a default description template for issues:
**If a `default.md` file exists, it's used as the default template even if you select another one in the project settings.**
- Select the default template in project settings:
1. On the top bar, select **Menu > Projects** and find your project. 1. Select **Expand** under **Default issue template**.
1. On the left sidebar, select **Settings**. 1. Fill in the **Default description template for issues** text area.
1. Expand **Default issue template**.
1. Fill in the **Default description template for issues** text area.
1. Select **Save changes**.
Because GitLab merge request and issues support [Markdown](../markdown.md), you can use it to format Because GitLab merge request and issues support [Markdown](../markdown.md), you can use it to format
headings, lists, and so on. headings, lists, and so on.
......
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
- create_a_merge_request_templates_help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: create_a_merge_request_template_help_link_url } - create_a_merge_request_templates_help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: create_a_merge_request_template_help_link_url }
= s_('ProjectSettings|%{link_start}What are description templates?%{link_end}').html_safe % { link_start: create_a_merge_request_templates_help_link_start, link_end: '</a>'.html_safe } = s_('ProjectSettings|%{link_start}What are description templates?%{link_end}').html_safe % { link_start: create_a_merge_request_templates_help_link_start, link_end: '</a>'.html_safe }
%p.text-secondary
= s_('ProjectSettings|If a %{code_start}default.md%{code_end} file exists in %{code_start}.gitlab/merge_request_templates%{code_end} in the repository, it overrides this setting.').html_safe % { code_start: '<code>'.html_safe, code_end: '</code>'.html_safe }
= form.text_area :merge_requests_template, class: "form-control", rows: 3, data: { qa_selector: 'default_merge_request_template_field' } = form.text_area :merge_requests_template, class: "form-control", rows: 3, data: { qa_selector: 'default_merge_request_template_field' }
.text-secondary .text-secondary
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
%p#issue-settings-default-template-label= _('Set a default description template to be used for new issues. %{link_start}What are description templates?%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe } %p#issue-settings-default-template-label= _('Set a default description template to be used for new issues. %{link_start}What are description templates?%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
.settings-content .settings-content
%p.text-secondary
= s_('ProjectSettings|If a %{code_start}default.md%{code_end} file exists in %{code_start}.gitlab/issue_templates%{code_end} in the repository, it overrides this setting.').html_safe % { code_start: '<code>'.html_safe, code_end: '</code>'.html_safe }
= form_for @project, html: { multipart: true, class: "issue-settings-form" }, authenticity_token: true do |f| = form_for @project, html: { multipart: true, class: "issue-settings-form" }, authenticity_token: true do |f|
%input{ type: 'hidden', name: 'update_section', value: 'js-issue-settings' } %input{ type: 'hidden', name: 'update_section', value: 'js-issue-settings' }
.row .row
......
...@@ -27964,12 +27964,6 @@ msgstr "" ...@@ -27964,12 +27964,6 @@ msgstr ""
msgid "ProjectSettings|Highlight the usage of hidden unicode characters. These have innocent uses for right-to-left languages, but can also be used in potential exploits." msgid "ProjectSettings|Highlight the usage of hidden unicode characters. These have innocent uses for right-to-left languages, but can also be used in potential exploits."
msgstr "" msgstr ""
msgid "ProjectSettings|If a %{code_start}default.md%{code_end} file exists in %{code_start}.gitlab/issue_templates%{code_end} in the repository, it overrides this setting."
msgstr ""
msgid "ProjectSettings|If a %{code_start}default.md%{code_end} file exists in %{code_start}.gitlab/merge_request_templates%{code_end} in the repository, it overrides this setting."
msgstr ""
msgid "ProjectSettings|If merge trains are enabled, merging is only possible if the branch can be rebased without conflicts." msgid "ProjectSettings|If merge trains are enabled, merging is only possible if the branch can be rebased without conflicts."
msgstr "" msgstr ""
......
...@@ -72,37 +72,6 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do ...@@ -72,37 +72,6 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do
].to_json ].to_json
expect(helper.available_service_desk_templates_for(@project)).to eq(value) expect(helper.available_service_desk_templates_for(@project)).to eq(value)
end end
context 'when no issuable_template parameter or default template is present' do
it 'does not select a template' do
expect(helper.selected_template(project)).to be(nil)
end
end
context 'when an issuable_template parameter has been provided' do
before do
allow(helper).to receive(:params).and_return({ issuable_template: 'another_issue_template' })
end
it 'selects the issuable template' do
expect(helper.selected_template(project)).to eq('another_issue_template')
end
end
context 'when there is a default template' do
let(:templates) do
{
"" => [
{ name: "another_issue_template", id: "another_issue_template", project_id: project.id },
{ name: "default", id: "default", project_id: project.id }
]
}
end
it 'selects the default template' do
expect(helper.selected_template(project)).to eq('default')
end
end
end end
context 'when there are not templates in the project' do context 'when there are not templates in the project' do
......
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