From d193734fb97510ffc55f84c2f3a0a3692cd2d859 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 28 May 2021 06:10:48 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../stylesheets/pages/merge_requests.scss | 5 + .../projects/templates_controller.rb | 2 +- app/finders/template_finder.rb | 16 ---- app/helpers/gitpod_helper.rb | 2 +- .../issuables_description_templates_helper.rb | 9 +- app/models/project.rb | 4 - .../application_settings/_gitpod.html.haml | 6 +- .../inherited_issuable_templates.yml | 8 -- .../geo/disaster_recovery/index.md | 1 + doc/user/project/description_templates.md | 37 +------- lib/api/project_templates.rb | 2 +- locale/gitlab.pot | 17 ++-- .../projects/templates_controller_spec.rb | 26 +----- .../settings/service_desk_setting_spec.rb | 19 +--- ...ables_description_templates_helper_spec.rb | 93 ++++++------------- 15 files changed, 61 insertions(+), 186 deletions(-) delete mode 100644 config/feature_flags/development/inherited_issuable_templates.yml diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index 8246739c8f7..1abaff40bc9 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -107,10 +107,15 @@ $tabs-holder-z-index: 250; border-radius: $border-radius-default; } + .mr-widget-section:not(:first-child), .mr-widget-footer { border-top: solid 1px $border-color; } + .mr-widget-alert-container + .mr-widget-section { + border-top: 0; + } + .mr-fast-forward-message { padding-left: $gl-padding-50; padding-bottom: $gl-padding; diff --git a/app/controllers/projects/templates_controller.rb b/app/controllers/projects/templates_controller.rb index b4b8fb97049..df945a99c73 100644 --- a/app/controllers/projects/templates_controller.rb +++ b/app/controllers/projects/templates_controller.rb @@ -25,7 +25,7 @@ class Projects::TemplatesController < Projects::ApplicationController def names respond_to do |format| - format.json { render json: TemplateFinder.all_template_names_hash_or_array(project, params[:template_type].to_s) } + format.json { render json: TemplateFinder.all_template_names(project, params[:template_type].to_s.pluralize) } end end diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb index 0f5622f2df0..b82b601541c 100644 --- a/app/finders/template_finder.rb +++ b/app/finders/template_finder.rb @@ -21,27 +21,11 @@ class TemplateFinder end end - # This is temporary and will be removed once we introduce group level inherited templates and - # remove the inherited_issuable_templates FF - def all_template_names_hash_or_array(project, issuable_type) - if project.inherited_issuable_templates_enabled? - all_template_names(project, issuable_type.pluralize) - else - all_template_names_array(project, issuable_type.pluralize) - end - end - def all_template_names(project, type) return {} if !VENDORED_TEMPLATES.key?(type.to_s) && type.to_s != 'licenses' build(type, project).template_names end - - # This is for issues and merge requests description templates only. - # This will be removed once we introduce group level inherited templates and remove the inherited_issuable_templates FF - def all_template_names_array(project, type) - all_template_names(project, type).values.flatten.select { |tmpl| tmpl[:project_id] == project.id }.compact.uniq - end end attr_reader :type, :project, :params diff --git a/app/helpers/gitpod_helper.rb b/app/helpers/gitpod_helper.rb index 875a44c51bb..726c852fcdd 100644 --- a/app/helpers/gitpod_helper.rb +++ b/app/helpers/gitpod_helper.rb @@ -2,6 +2,6 @@ module GitpodHelper def gitpod_enable_description - s_('Enable %{linkStart}Gitpod%{linkEnd} integration to launch a development environment in your browser directly from GitLab.') + s_('Users can launch a development environment from a GitLab browser tab when the %{linkStart}Gitpod%{linkEnd} integration is enabled.') end end diff --git a/app/helpers/issuables_description_templates_helper.rb b/app/helpers/issuables_description_templates_helper.rb index 5f69098de56..6cafde65c5c 100644 --- a/app/helpers/issuables_description_templates_helper.rb +++ b/app/helpers/issuables_description_templates_helper.rb @@ -29,17 +29,12 @@ module IssuablesDescriptionTemplatesHelper def issuable_templates(project, issuable_type) @template_types ||= {} @template_types[project.id] ||= {} - @template_types[project.id][issuable_type] ||= TemplateFinder.all_template_names_hash_or_array(project, issuable_type) + @template_types[project.id][issuable_type] ||= TemplateFinder.all_template_names(project, issuable_type.pluralize) end def issuable_templates_names(issuable) all_templates = issuable_templates(ref_project, issuable.to_ability_name) - - if ref_project.inherited_issuable_templates_enabled? - all_templates.values.flatten.map { |tpl| tpl[:name] if tpl[:project_id] == ref_project.id }.compact.uniq - else - all_templates.map { |template| template[:name] } - end + all_templates.values.flatten.map { |tpl| tpl[:name] if tpl[:project_id] == ref_project.id }.compact.uniq end def selected_template(issuable) diff --git a/app/models/project.rb b/app/models/project.rb index 26a7062581f..df3c4bf54df 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2592,10 +2592,6 @@ class Project < ApplicationRecord Projects::GitGarbageCollectWorker end - def inherited_issuable_templates_enabled? - Feature.enabled?(:inherited_issuable_templates, self, default_enabled: :yaml) - end - def activity_path Gitlab::Routing.url_helpers.activity_project_path(self) end diff --git a/app/views/admin/application_settings/_gitpod.html.haml b/app/views/admin/application_settings/_gitpod.html.haml index 6d335e2db16..c08b41e8c55 100644 --- a/app/views/admin/application_settings/_gitpod.html.haml +++ b/app/views/admin/application_settings/_gitpod.html.haml @@ -22,7 +22,9 @@ = f.label :gitpod_enabled, s_('Gitpod|Enable Gitpod integration'), class: 'form-check-label' .form-group = f.label :gitpod_url, s_('Gitpod|Gitpod URL'), class: 'label-bold' - = f.text_field :gitpod_url, class: 'form-control gl-form-input', placeholder: s_('Gitpod|e.g. https://gitpod.example.com') + = f.text_field :gitpod_url, class: 'form-control gl-form-input', placeholder: s_('Gitpod|https://gitpod.example.com') .form-text.text-muted - = s_('Gitpod|Add the URL to your Gitpod instance configured to read your GitLab projects.') + = s_('Gitpod|The URL to your Gitpod instance configured to read your GitLab projects, such as https://gitpod.example.com.') + - link_start = ''.html_safe % { url: help_page_path('integration/gitpod', anchor: 'enable-gitpod-in-your-user-settings') } + = s_('Gitpod|To use the integration, each user must also enable Gitpod on their GitLab account. %{link_start}How do I enable it?%{link_end} ').html_safe % { link_start: link_start, link_end: ''.html_safe } = f.submit s_('Save changes'), class: 'gl-button btn btn-confirm' diff --git a/config/feature_flags/development/inherited_issuable_templates.yml b/config/feature_flags/development/inherited_issuable_templates.yml deleted file mode 100644 index 403361ff784..00000000000 --- a/config/feature_flags/development/inherited_issuable_templates.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: inherited_issuable_templates -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52360 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/321247 -milestone: '13.9' -type: development -group: group::project management -default_enabled: true diff --git a/doc/administration/geo/disaster_recovery/index.md b/doc/administration/geo/disaster_recovery/index.md index 254ffff5e90..a98187466e2 100644 --- a/doc/administration/geo/disaster_recovery/index.md +++ b/doc/administration/geo/disaster_recovery/index.md @@ -246,6 +246,7 @@ required: sets the database to read-write. The instructions vary depending on where your database is hosted: - [Amazon RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html#USER_ReadRepl.Promote) - [Azure PostgreSQL](https://docs.microsoft.com/en-us/azure/postgresql/howto-read-replicas-portal#stop-replication) + - [Google Cloud SQL](https://cloud.google.com/sql/docs/mysql/replication/manage-replicas#promote-replica) - For other external PostgreSQL databases, save the following script in your secondary node, for example `/tmp/geo_promote.sh`, and modify the connection parameters to match your environment. Then, execute it to promote the replica: diff --git a/doc/user/project/description_templates.md b/doc/user/project/description_templates.md index 4a2bd56b7ba..c745f5e2afe 100644 --- a/doc/user/project/description_templates.md +++ b/doc/user/project/description_templates.md @@ -106,11 +106,7 @@ instance or the project's parent groups. ### Set instance-level description templates **(PREMIUM SELF)** > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52360) in GitLab 13.9. -> - [Deployed behind a feature flag](../feature_flags.md), disabled by default. -> - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56737) in GitLab 13.11. -> - Enabled by default on GitLab.com. -> - Recommended for production use. -> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-issue-and-merge-request-description-templates-at-group-and-instance-level). **(PREMIUM SELF)** +> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/321247) in GitLab 14.0. You can set a description template at the **instance level** for issues and merge requests. @@ -132,11 +128,7 @@ Learn more about [instance template repository](../admin_area/settings/instance_ ### Set group-level description templates **(PREMIUM)** > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52360) in GitLab 13.9. -> - [Deployed behind a feature flag](../feature_flags.md), disabled by default. -> - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56737) in GitLab 13.11. -> - Enabled by default on GitLab.com. -> - Recommended for production use. -> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-issue-and-merge-request-description-templates-at-group-and-instance-level). **(PREMIUM SELF)** +> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/321247) in GitLab 14.0. With **group-level** description templates, you can store your templates in a single repository and configure the group file templates setting to point to that repository. @@ -231,28 +223,3 @@ it's very hard to read otherwise.) /cc @project-manager /assign @qa-tester ``` - -## Enable or disable issue and merge request description templates at group and instance level **(PREMIUM SELF)** - -Setting issue and merge request description templates at group and instance levels -is under development but ready for production use. It is deployed behind a -feature flag that is **enabled by default**. -[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md) -can disable it. - -To disable it: - -```ruby -Feature.disable(:inherited_issuable_templates) -``` - -To enable it: - -```ruby -Feature.enable(:inherited_issuable_templates) -``` - -The feature flag affects these features: - -- Setting a templates project as issue and merge request description templates source at group level. -- Setting a templates project as issue and merge request description templates source at instance level. diff --git a/lib/api/project_templates.rb b/lib/api/project_templates.rb index 5d6f67ccbae..acf9bfece65 100644 --- a/lib/api/project_templates.rb +++ b/lib/api/project_templates.rb @@ -26,7 +26,7 @@ module API use :pagination end get ':id/templates/:type' do - templates = TemplateFinder.all_template_names_array(user_project, params[:type]) + templates = TemplateFinder.all_template_names(user_project, params[:type]).values.flatten present paginate(::Kaminari.paginate_array(templates)), with: Entities::TemplatesList end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index bb4096c010c..f2b641a976b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -12109,9 +12109,6 @@ msgstr "" msgid "Enable" msgstr "" -msgid "Enable %{linkStart}Gitpod%{linkEnd} integration to launch a development environment in your browser directly from GitLab." -msgstr "" - msgid "Enable Auto DevOps" msgstr "" @@ -15337,16 +15334,19 @@ msgstr "" msgid "Gitpod" msgstr "" -msgid "Gitpod|Add the URL to your Gitpod instance configured to read your GitLab projects." -msgstr "" - msgid "Gitpod|Enable Gitpod integration" msgstr "" msgid "Gitpod|Gitpod URL" msgstr "" -msgid "Gitpod|e.g. https://gitpod.example.com" +msgid "Gitpod|The URL to your Gitpod instance configured to read your GitLab projects, such as https://gitpod.example.com." +msgstr "" + +msgid "Gitpod|To use the integration, each user must also enable Gitpod on their GitLab account. %{link_start}How do I enable it?%{link_end} " +msgstr "" + +msgid "Gitpod|https://gitpod.example.com" msgstr "" msgid "Given access %{time_ago}" @@ -35787,6 +35787,9 @@ msgstr "" msgid "Users" msgstr "" +msgid "Users can launch a development environment from a GitLab browser tab when the %{linkStart}Gitpod%{linkEnd} integration is enabled." +msgstr "" + msgid "Users in License" msgstr "" diff --git a/spec/controllers/projects/templates_controller_spec.rb b/spec/controllers/projects/templates_controller_spec.rb index bd299efb5b5..da381357bda 100644 --- a/spec/controllers/projects/templates_controller_spec.rb +++ b/spec/controllers/projects/templates_controller_spec.rb @@ -160,28 +160,12 @@ RSpec.describe Projects::TemplatesController do end shared_examples 'template names request' do - context 'when feature flag enabled' do - it 'returns the template names', :aggregate_failures do - get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) + it 'returns the template names', :aggregate_failures do + get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['Project Templates'].size).to eq(2) - expect(json_response['Project Templates'].map { |x| x.slice('name') }).to match(expected_template_names) - end - end - - context 'when feature flag disabled' do - before do - stub_feature_flags(inherited_issuable_templates: false) - end - - it 'returns the template names', :aggregate_failures do - get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response.size).to eq(2) - expect(json_response.map { |x| x.slice('name') }).to match(expected_template_names) - end + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['Project Templates'].size).to eq(2) + expect(json_response['Project Templates'].map { |x| x.slice('name') }).to match(expected_template_names) end it 'fails for user with no access' do diff --git a/spec/features/projects/settings/service_desk_setting_spec.rb b/spec/features/projects/settings/service_desk_setting_spec.rb index 50451075db5..91355d8f625 100644 --- a/spec/features/projects/settings/service_desk_setting_spec.rb +++ b/spec/features/projects/settings/service_desk_setting_spec.rb @@ -89,25 +89,10 @@ RSpec.describe 'Service Desk Setting', :js, :clean_gitlab_redis_cache do before do stub_licensed_features(custom_file_templates_for_namespace: false, custom_file_templates: false) group.update_columns(file_template_project_id: group_template_repo.id) + visit edit_project_path(project) end - context 'when inherited_issuable_templates enabled' do - before do - stub_feature_flags(inherited_issuable_templates: true) - visit edit_project_path(project) - end - - it_behaves_like 'issue description templates from current project only' - end - - context 'when inherited_issuable_templates disabled' do - before do - stub_feature_flags(inherited_issuable_templates: false) - visit edit_project_path(project) - end - - it_behaves_like 'issue description templates from current project only' - end + it_behaves_like 'issue description templates from current project only' end end end diff --git a/spec/helpers/issuables_description_templates_helper_spec.rb b/spec/helpers/issuables_description_templates_helper_spec.rb index e8961ccb535..95460174266 100644 --- a/spec/helpers/issuables_description_templates_helper_spec.rb +++ b/spec/helpers/issuables_description_templates_helper_spec.rb @@ -13,24 +13,8 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do let_it_be(:group_member) { create(:group_member, :developer, group: parent_group, user: user) } let_it_be(:project_member) { create(:project_member, :developer, user: user, project: project) } - context 'when feature flag disabled' do - before do - stub_feature_flags(inherited_issuable_templates: false) - end - - it 'returns empty array when template type does not exist' do - expect(helper.issuable_templates(project, 'non-existent-template-type')).to eq([]) - end - end - - context 'when feature flag enabled' do - before do - stub_feature_flags(inherited_issuable_templates: true) - end - - it 'returns empty hash when template type does not exist' do - expect(helper.issuable_templates(build(:project), 'non-existent-template-type')).to eq({}) - end + it 'returns empty hash when template type does not exist' do + expect(helper.issuable_templates(build(:project), 'non-existent-template-type')).to eq({}) end context 'with cached issuable templates' do @@ -81,16 +65,18 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do allow(helper).to receive(:issuable_templates).and_return(templates) end - context 'when feature flag disabled' do + context 'with matching project templates' do let(:templates) do - [ - { name: "another_issue_template", id: "another_issue_template", project_id: project.id }, - { name: "custom_issue_template", id: "custom_issue_template", project_id: project.id } - ] - end - - before do - stub_feature_flags(inherited_issuable_templates: false) + { + "" => [ + { name: "another_issue_template", id: "another_issue_template", project_id: project.id }, + { name: "custom_issue_template", id: "custom_issue_template", project_id: project.id } + ], + "Instance" => [ + { name: "first_issue_issue_template", id: "first_issue_issue_template", project_id: non_existing_record_id }, + { name: "second_instance_issue_template", id: "second_instance_issue_template", project_id: non_existing_record_id } + ] + } end it 'returns project templates only' do @@ -98,47 +84,22 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do end end - context 'when feature flag enabled' do - before do - stub_feature_flags(inherited_issuable_templates: true) + context 'without matching project templates' do + let(:templates) do + { + "Project Templates" => [ + { name: "another_issue_template", id: "another_issue_template", project_id: non_existing_record_id }, + { name: "custom_issue_template", id: "custom_issue_template", project_id: non_existing_record_id } + ], + "Instance" => [ + { name: "first_issue_issue_template", id: "first_issue_issue_template", project_id: non_existing_record_id }, + { name: "second_instance_issue_template", id: "second_instance_issue_template", project_id: non_existing_record_id } + ] + } end - context 'with matching project templates' do - let(:templates) do - { - "" => [ - { name: "another_issue_template", id: "another_issue_template", project_id: project.id }, - { name: "custom_issue_template", id: "custom_issue_template", project_id: project.id } - ], - "Instance" => [ - { name: "first_issue_issue_template", id: "first_issue_issue_template", project_id: non_existing_record_id }, - { name: "second_instance_issue_template", id: "second_instance_issue_template", project_id: non_existing_record_id } - ] - } - end - - it 'returns project templates only' do - expect(helper.issuable_templates_names(Issue.new)).to eq(%w[another_issue_template custom_issue_template]) - end - end - - context 'without matching project templates' do - let(:templates) do - { - "Project Templates" => [ - { name: "another_issue_template", id: "another_issue_template", project_id: non_existing_record_id }, - { name: "custom_issue_template", id: "custom_issue_template", project_id: non_existing_record_id } - ], - "Instance" => [ - { name: "first_issue_issue_template", id: "first_issue_issue_template", project_id: non_existing_record_id }, - { name: "second_instance_issue_template", id: "second_instance_issue_template", project_id: non_existing_record_id } - ] - } - end - - it 'returns empty array' do - expect(helper.issuable_templates_names(Issue.new)).to eq([]) - end + it 'returns empty array' do + expect(helper.issuable_templates_names(Issue.new)).to eq([]) end end