diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-29 12:06:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-29 12:06:40 +0000 |
commit | d64e3a8b281d355c7d51d04df52fab407b8cc76d (patch) | |
tree | 282d6cc62eacd3fb4a0f6841ae52ae4a709e303f /app | |
parent | 833eadad8cac85b99871842854c9a676a607e2da (diff) | |
download | gitlab-ce-d64e3a8b281d355c7d51d04df52fab407b8cc76d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
26 files changed, 174 insertions, 28 deletions
diff --git a/app/assets/javascripts/pages/projects/show/index.js b/app/assets/javascripts/pages/projects/show/index.js index 6aa41d0825b..370f3c6e7a2 100644 --- a/app/assets/javascripts/pages/projects/show/index.js +++ b/app/assets/javascripts/pages/projects/show/index.js @@ -48,7 +48,7 @@ document.addEventListener('DOMContentLoaded', () => { leaveByUrl('project'); if (document.getElementById('js-tree-list')) { - import('~/repository') + import('ee_else_ce/repository') .then(m => m.default()) .catch(e => { throw e; diff --git a/app/assets/javascripts/pages/projects/tree/show/index.js b/app/assets/javascripts/pages/projects/tree/show/index.js index 7b90a3a4f6e..16d71379e31 100644 --- a/app/assets/javascripts/pages/projects/tree/show/index.js +++ b/app/assets/javascripts/pages/projects/tree/show/index.js @@ -42,7 +42,7 @@ document.addEventListener('DOMContentLoaded', () => { GpgBadges.fetch(); if (document.getElementById('js-tree-list')) { - import('~/repository') + import('ee_else_ce/repository') .then(m => m.default()) .catch(e => { throw e; diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index f9727960040..6a6e7f73188 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -9,8 +9,10 @@ import { parseBoolean } from '../lib/utils/common_utils'; export default function setupVueRepositoryList() { const el = document.getElementById('js-tree-list'); - const { projectPath, projectShortPath, ref, fullName } = el.dataset; + const { dataset } = el; + const { projectPath, projectShortPath, ref, fullName } = dataset; const router = createRouter(projectPath, ref); + const hideOnRootEls = document.querySelectorAll('.js-hide-on-root'); apolloProvider.clients.defaultClient.cache.writeData({ data: { @@ -35,6 +37,7 @@ export default function setupVueRepositoryList() { document .querySelectorAll('.js-hide-on-navigation') .forEach(elem => elem.classList.toggle('hidden', !isRoot)); + hideOnRootEls.forEach(elem => elem.classList.toggle('hidden', isRoot)); }); const breadcrumbEl = document.getElementById('js-repo-breadcrumb'); @@ -88,7 +91,8 @@ export default function setupVueRepositoryList() { }, }); - return new Vue({ + // eslint-disable-next-line no-new + new Vue({ el, router, apolloProvider, @@ -96,4 +100,6 @@ export default function setupVueRepositoryList() { return h(App); }, }); + + return { router, data: dataset }; } diff --git a/app/controllers/concerns/preview_markdown.rb b/app/controllers/concerns/preview_markdown.rb index a3938ea3652..4189b8dcf96 100644 --- a/app/controllers/concerns/preview_markdown.rb +++ b/app/controllers/concerns/preview_markdown.rb @@ -5,7 +5,7 @@ module PreviewMarkdown # rubocop:disable Gitlab/ModuleWithInstanceVariables def preview_markdown - result = PreviewMarkdownService.new(@project, current_user, params).execute + result = PreviewMarkdownService.new(@project, current_user, markdown_service_params).execute markdown_params = case controller_name @@ -26,6 +26,8 @@ module PreviewMarkdown end # rubocop:enable Gitlab/ModuleWithInstanceVariables + private + def projects_filter_params { issuable_state_filter_enabled: true, @@ -33,10 +35,12 @@ module PreviewMarkdown } end - private - # Override this method to customise the markdown for your controller def preview_markdown_params {} end + + def markdown_service_params + params + end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 35e364abba3..31c25250745 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -6,6 +6,7 @@ class GroupsController < Groups::ApplicationController include ParamsBackwardCompatibility include PreviewMarkdown include RecordUserLastActivity + extend ::Gitlab::Utils::Override respond_to :html @@ -233,6 +234,11 @@ class GroupsController < Groups::ApplicationController @group.self_and_descendants.public_or_visible_to_user(current_user) end end + + override :markdown_service_params + def markdown_service_params + params.merge(group: group) + end end GroupsController.prepend_if_ee('EE::GroupsController') diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 4f31cc67ccc..404ea7b00d4 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -66,7 +66,7 @@ module GitlabRoutingHelper end def preview_markdown_path(parent, *args) - return group_preview_markdown_path(parent) if parent.is_a?(Group) + return group_preview_markdown_path(parent, *args) if parent.is_a?(Group) if @snippet.is_a?(PersonalSnippet) preview_markdown_snippets_path diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index ea7c7af72d3..19a27ba3499 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -32,7 +32,7 @@ module ServicesHelper end def service_save_button(service) - button_tag(class: 'btn btn-success', type: 'submit', disabled: service.deprecated?) do + button_tag(class: 'btn btn-success', type: 'submit', disabled: service.deprecated?, data: { qa_selector: 'save_changes_button' }) do icon('spinner spin', class: 'hidden js-btn-spinner') + content_tag(:span, 'Save changes', class: 'js-btn-label') end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index afa057421e0..1020c91b245 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -186,6 +186,15 @@ module TreeHelper attrs end + + def vue_file_list_data(project, ref) + { + project_path: project.full_path, + project_short_path: project.path, + ref: ref, + full_name: project.name_with_namespace + } + end end TreeHelper.prepend_if_ee('::EE::TreeHelper') diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index acd744bfaf5..0db1fe9d6dc 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -6,6 +6,7 @@ module Clusters include Gitlab::Utils::StrongMemoize include FromUnion include ReactiveCaching + include AfterCommitQueue self.table_name = 'clusters' @@ -126,7 +127,55 @@ module Clusters hierarchy_groups.flat_map(&:clusters) + Instance.new.clusters end + state_machine :cleanup_status, initial: :cleanup_not_started do + state :cleanup_not_started, value: 1 + state :cleanup_uninstalling_applications, value: 2 + state :cleanup_removing_project_namespaces, value: 3 + state :cleanup_removing_service_account, value: 4 + state :cleanup_errored, value: 5 + + event :start_cleanup do |cluster| + transition [:cleanup_not_started, :cleanup_errored] => :cleanup_uninstalling_applications + end + + event :continue_cleanup do + transition( + cleanup_uninstalling_applications: :cleanup_removing_project_namespaces, + cleanup_removing_project_namespaces: :cleanup_removing_service_account) + end + + event :make_cleanup_errored do + transition any => :cleanup_errored + end + + before_transition any => [:cleanup_errored] do |cluster, transition| + status_reason = transition.args.first + cluster.cleanup_status_reason = status_reason if status_reason + end + + after_transition [:cleanup_not_started, :cleanup_errored] => :cleanup_uninstalling_applications do |cluster| + cluster.run_after_commit do + Clusters::Cleanup::AppWorker.perform_async(cluster.id) + end + end + + after_transition cleanup_uninstalling_applications: :cleanup_removing_project_namespaces do |cluster| + cluster.run_after_commit do + Clusters::Cleanup::ProjectNamespaceWorker.perform_async(cluster.id) + end + end + + after_transition cleanup_removing_project_namespaces: :cleanup_removing_service_account do |cluster| + cluster.run_after_commit do + Clusters::Cleanup::ServiceAccountWorker.perform_async(cluster.id) + end + end + end + def status_name + return cleanup_status_name if cleanup_errored? + return :cleanup_ongoing unless cleanup_not_started? + provider&.status_name || connection_status.presence || :created end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index cd8ede3905a..250bac95b82 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -209,14 +209,20 @@ class MergeRequest < ApplicationRecord scope :by_target_branch, ->(branch_name) { where(target_branch: branch_name) } scope :preload_source_project, -> { preload(:source_project) } - scope :with_open_merge_when_pipeline_succeeds, -> do - with_state(:opened).where(merge_when_pipeline_succeeds: true) + scope :with_auto_merge_enabled, -> do + with_state(:opened).where(auto_merge_enabled: true) end after_save :keep_around_commit alias_attribute :project, :target_project alias_attribute :project_id, :target_project_id + + # Currently, `merge_when_pipeline_succeeds` column is used as a flag + # to check if _any_ auto merge strategy is activated on the merge request. + # Today, we have multiple strategies and MWPS is one of them. + # we'd eventually rename the column for avoiding confusions, but in the mean time + # please use `auto_merge_enabled` alias instead of `merge_when_pipeline_succeeds`. alias_attribute :auto_merge_enabled, :merge_when_pipeline_succeeds alias_method :issuing_parent, :target_project diff --git a/app/presenters/todo_presenter.rb b/app/presenters/todo_presenter.rb index b57fc712c5a..291be7848e2 100644 --- a/app/presenters/todo_presenter.rb +++ b/app/presenters/todo_presenter.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true class TodoPresenter < Gitlab::View::Presenter::Delegated - include GlobalID::Identification - presents :todo end diff --git a/app/serializers/diff_file_base_entity.rb b/app/serializers/diff_file_base_entity.rb index ee68b4b98e0..302fe3d7c67 100644 --- a/app/serializers/diff_file_base_entity.rb +++ b/app/serializers/diff_file_base_entity.rb @@ -89,6 +89,14 @@ class DiffFileBaseEntity < Grape::Entity expose :viewer, using: DiffViewerEntity + expose :old_size do |diff_file| + diff_file.old_blob&.raw_size + end + + expose :new_size do |diff_file| + diff_file.new_blob&.raw_size + end + private def memoized_submodule_links(diff_file, options) diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index b32499629ff..bd3fcf85a62 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -152,7 +152,8 @@ module MergeRequests def abort_ff_merge_requests_with_when_pipeline_succeeds return unless @project.ff_merge_must_be_possible? - requests_with_auto_merge_enabled_to(@push.branch_name).each do |merge_request| + merge_requests_with_auto_merge_enabled_to(@push.branch_name).each do |merge_request| + next unless merge_request.auto_merge_strategy == AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS next unless merge_request.should_be_rebased? abort_auto_merge_with_todo(merge_request, 'target branch was updated') @@ -167,11 +168,11 @@ module MergeRequests todo_service.merge_request_became_unmergeable(merge_request) end - def requests_with_auto_merge_enabled_to(target_branch) + def merge_requests_with_auto_merge_enabled_to(target_branch) @project .merge_requests .by_target_branch(target_branch) - .with_open_merge_when_pipeline_succeeds + .with_auto_merge_enabled end def mark_pending_todos_done diff --git a/app/services/preview_markdown_service.rb b/app/services/preview_markdown_service.rb index 2b4c4ae68e2..afe2651b11a 100644 --- a/app/services/preview_markdown_service.rb +++ b/app/services/preview_markdown_service.rb @@ -16,8 +16,12 @@ class PreviewMarkdownService < BaseService private + def quick_action_types + %w(Issue MergeRequest Commit) + end + def explain_quick_actions(text) - return text, [] unless %w(Issue MergeRequest Commit).include?(target_type) + return text, [] unless quick_action_types.include?(target_type) quick_actions_service = QuickActions::InterpretService.new(project, current_user) quick_actions_service.explain(text, find_commands_target) @@ -51,7 +55,7 @@ class PreviewMarkdownService < BaseService def find_commands_target QuickActions::TargetService - .new(project, current_user) + .new(project, current_user, group: params[:group]) .execute(target_type, target_id) end @@ -63,3 +67,5 @@ class PreviewMarkdownService < BaseService params[:target_id] end end + +PreviewMarkdownService.prepend_if_ee('EE::PreviewMarkdownService') diff --git a/app/services/quick_actions/target_service.rb b/app/services/quick_actions/target_service.rb index 69464c3c1ae..4273acfbf8b 100644 --- a/app/services/quick_actions/target_service.rb +++ b/app/services/quick_actions/target_service.rb @@ -32,3 +32,5 @@ module QuickActions end end end + +QuickActions::TargetService.prepend_if_ee('EE::QuickActions::TargetService') diff --git a/app/views/admin/application_settings/_outbound.html.haml b/app/views/admin/application_settings/_outbound.html.haml index ad26f52aea7..42528f40123 100644 --- a/app/views/admin/application_settings/_outbound.html.haml +++ b/app/views/admin/application_settings/_outbound.html.haml @@ -4,7 +4,7 @@ %fieldset .form-group .form-check - = f.check_box :allow_local_requests_from_web_hooks_and_services, class: 'form-check-input' + = f.check_box :allow_local_requests_from_web_hooks_and_services, class: 'form-check-input', data: { qa_selector: 'allow_requests_from_services_checkbox' } = f.label :allow_local_requests_from_web_hooks_and_services, class: 'form-check-label' do = _('Allow requests to the local network from web hooks and services') .form-check @@ -27,4 +27,4 @@ %span.form-text.text-muted = _('Resolves IP addresses once and uses them to submit requests') - = f.submit 'Save changes', class: "btn btn-success" + = f.submit 'Save changes', class: "btn btn-success", data: { qa_selector: 'save_changes_button' } diff --git a/app/views/admin/application_settings/network.html.haml b/app/views/admin/application_settings/network.html.haml index 092834b993c..7bd51172195 100644 --- a/app/views/admin/application_settings/network.html.haml +++ b/app/views/admin/application_settings/network.html.haml @@ -24,7 +24,7 @@ .settings-content = render 'ip_limits' -%section.settings.as-outbound.no-animate#js-outbound-settings{ class: ('expanded' if expanded_by_default?) } +%section.settings.as-outbound.no-animate#js-outbound-settings{ class: ('expanded' if expanded_by_default?), data: { qa_selector: 'outbound_requests_section' } } .settings-header %h4 = _('Outbound requests') diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index ec27f3c24df..247fbfefde9 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -163,7 +163,7 @@ - if project_nav_tab? :pipelines = nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts]) do - = link_to project_pipelines_path(@project), class: 'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines' do + = link_to project_pipelines_path(@project), class: 'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines', data: { qa_selector: 'ci_cd_link' } do .nav-icon-container = sprite_icon('rocket') %span.nav-item-name#js-onboarding-pipelines-link @@ -347,7 +347,7 @@ = _('Members') - if can_edit = nav_link(controller: [:integrations, :services, :hooks, :hook_logs]) do - = link_to project_settings_integrations_path(@project), title: _('Integrations') do + = link_to project_settings_integrations_path(@project), title: _('Integrations'), data: { qa_selector: 'integrations_settings_link' } do %span = _('Integrations') = nav_link(controller: :repository) do diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml index 95fdad125a7..3c0dfd4c029 100644 --- a/app/views/projects/_files.html.haml +++ b/app/views/projects/_files.html.haml @@ -19,7 +19,7 @@ = render 'stat_anchor_list', anchors: @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout) - if vue_file_list_enabled? - #js-tree-list{ data: { project_path: @project.full_path, project_short_path: @project.path, ref: ref, full_name: @project.name_with_namespace } } + #js-tree-list{ data: vue_file_list_data(project, ref) } - if can_edit_tree? = render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, @id), method: :post = render 'projects/blob/new_dir' diff --git a/app/views/projects/services/_index.html.haml b/app/views/projects/services/_index.html.haml index 7748a7a6a8e..3f33d72d3ec 100644 --- a/app/views/projects/services/_index.html.haml +++ b/app/views/projects/services/_index.html.haml @@ -21,7 +21,7 @@ %td{ "aria-label" => (service.activated? ? s_("ProjectService|%{service_title}: status on") : s_("ProjectService|%{service_title}: status off")) % { service_title: service.title } } = boolean_to_icon service.activated? %td - = link_to edit_project_service_path(@project, service.to_param) do + = link_to edit_project_service_path(@project, service.to_param), { data: { qa_selector: "#{service.title.downcase.gsub(/[\s\(\)]/,'_')}_link" } } do %strong= service.title %td.d-none.d-sm-block = service.description diff --git a/app/views/shared/_field.html.haml b/app/views/shared/_field.html.haml index 606d0f241aa..a7ad6d6f2c4 100644 --- a/app/views/shared/_field.html.haml +++ b/app/views/shared/_field.html.haml @@ -16,7 +16,7 @@ = form.label name, title, class: "col-form-label col-sm-2" .col-sm-10 - if type == 'text' - = form.text_field name, class: "form-control", placeholder: placeholder, required: required, disabled: disabled + = form.text_field name, class: "form-control", placeholder: placeholder, required: required, disabled: disabled, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" } - elsif type == 'textarea' = form.text_area name, rows: 5, class: "form-control", placeholder: placeholder, required: required, disabled: disabled - elsif type == 'checkbox' @@ -24,6 +24,6 @@ - elsif type == 'select' = form.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control", disabled: disabled} - elsif type == 'password' - = form.password_field name, autocomplete: "new-password", placeholder: placeholder, class: "form-control", required: value.blank? && required, disabled: disabled + = form.password_field name, autocomplete: "new-password", placeholder: placeholder, class: "form-control", required: value.blank? && required, disabled: disabled, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" } - if help %span.form-text.text-muted= help diff --git a/app/views/shared/_service_settings.html.haml b/app/views/shared/_service_settings.html.haml index 6fa61c15493..627a1eb6eae 100644 --- a/app/views/shared/_service_settings.html.haml +++ b/app/views/shared/_service_settings.html.haml @@ -12,7 +12,7 @@ .form-group.row = form.label :active, "Active", class: "col-form-label col-sm-2" .col-sm-10 - = form.check_box :active, disabled: disable_fields_service?(@service) + = form.check_box :active, disabled: disable_fields_service?(@service), data: { qa_selector: 'active_checkbox' } - if @service.configurable_events.present? .form-group.row diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index b161cc65602..10081840305 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -45,6 +45,9 @@ - gcp_cluster:cluster_project_configure - gcp_cluster:clusters_applications_wait_for_uninstall_app - gcp_cluster:clusters_applications_uninstall +- gcp_cluster:clusters_cleanup_app +- gcp_cluster:clusters_cleanup_project_namespace +- gcp_cluster:clusters_cleanup_service_account - github_import_advance_stage - github_importer:github_import_import_diff_note diff --git a/app/workers/clusters/cleanup/app_worker.rb b/app/workers/clusters/cleanup/app_worker.rb new file mode 100644 index 00000000000..1eedf510ba1 --- /dev/null +++ b/app/workers/clusters/cleanup/app_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Clusters + module Cleanup + class AppWorker + include ApplicationWorker + include ClusterQueue + include ClusterApplications + + # TODO: Merge with https://gitlab.com/gitlab-org/gitlab/merge_requests/16954 + # We're splitting the above MR in smaller chunks to facilitate reviews + def perform + end + end + end +end diff --git a/app/workers/clusters/cleanup/project_namespace_worker.rb b/app/workers/clusters/cleanup/project_namespace_worker.rb new file mode 100644 index 00000000000..09f2abf5d8a --- /dev/null +++ b/app/workers/clusters/cleanup/project_namespace_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Clusters + module Cleanup + class ProjectNamespaceWorker + include ApplicationWorker + include ClusterQueue + include ClusterApplications + + # TODO: Merge with https://gitlab.com/gitlab-org/gitlab/merge_requests/16954 + # We're splitting the above MR in smaller chunks to facilitate reviews + def perform + end + end + end +end diff --git a/app/workers/clusters/cleanup/service_account_worker.rb b/app/workers/clusters/cleanup/service_account_worker.rb new file mode 100644 index 00000000000..fab6318a807 --- /dev/null +++ b/app/workers/clusters/cleanup/service_account_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Clusters + module Cleanup + class ServiceAccountWorker + include ApplicationWorker + include ClusterQueue + include ClusterApplications + + # TODO: Merge with https://gitlab.com/gitlab-org/gitlab/merge_requests/16954 + # We're splitting the above MR in smaller chunks to facilitate reviews + def perform + end + end + end +end |