diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 12:08:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 12:08:33 +0000 |
commit | 1808454313ed75c92e1384466e8c83bfbc8ae25e (patch) | |
tree | 5c006c158fd796dc6d21e9bd771542f2fb0c24e2 /app | |
parent | fd3a95f07ae9cd78fecffcfa5de4494f933a7808 (diff) | |
download | gitlab-ce-1808454313ed75c92e1384466e8c83bfbc8ae25e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/behaviors/markdown/nodes/playable.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_stats.vue | 8 | ||||
-rw-r--r-- | app/assets/javascripts/pages/registrations/welcome/index.js | 7 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/prometheus.scss | 1 | ||||
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/registrations_controller.rb | 3 | ||||
-rw-r--r-- | app/finders/members_finder.rb | 37 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/discussion_on_diff.rb | 2 | ||||
-rw-r--r-- | app/models/project_group_link.rb | 4 | ||||
-rw-r--r-- | app/services/projects/after_import_service.rb | 8 | ||||
-rw-r--r-- | app/services/suggestions/apply_service.rb | 2 |
12 files changed, 59 insertions, 40 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/nodes/playable.js b/app/assets/javascripts/behaviors/markdown/nodes/playable.js index 08539df1242..9209c69d04a 100644 --- a/app/assets/javascripts/behaviors/markdown/nodes/playable.js +++ b/app/assets/javascripts/behaviors/markdown/nodes/playable.js @@ -42,7 +42,7 @@ export default class Playable extends Node { }, { tag: `${this.mediaType}[src]`, - getAttrs: el => ({ src: el.getAttribute('src'), alt: el.dataset.title }), + getAttrs: el => ({ src: el.src, alt: el.dataset.title }), }, ]; diff --git a/app/assets/javascripts/diffs/components/diff_stats.vue b/app/assets/javascripts/diffs/components/diff_stats.vue index 2e5855380af..5329cb1e241 100644 --- a/app/assets/javascripts/diffs/components/diff_stats.vue +++ b/app/assets/javascripts/diffs/components/diff_stats.vue @@ -1,6 +1,7 @@ <script> import Icon from '~/vue_shared/components/icon.vue'; import { n__ } from '~/locale'; +import { isNumber } from 'underscore'; export default { components: { Icon }, @@ -16,7 +17,7 @@ export default { diffFilesLength: { type: Number, required: false, - default: null, + default: 0, }, }, computed: { @@ -26,6 +27,9 @@ export default { isCompareVersionsHeader() { return Boolean(this.diffFilesLength); }, + hasDiffFiles() { + return isNumber(this.diffFilesLength) && this.diffFilesLength >= 0; + }, }, }; </script> @@ -38,7 +42,7 @@ export default { 'd-inline-flex': !isCompareVersionsHeader, }" > - <div v-if="diffFilesLength !== null" class="diff-stats-group"> + <div v-if="hasDiffFiles" class="diff-stats-group"> <icon name="doc-code" class="diff-stats-icon text-secondary" /> <strong>{{ diffFilesLength }} {{ filesText }}</strong> </div> diff --git a/app/assets/javascripts/pages/registrations/welcome/index.js b/app/assets/javascripts/pages/registrations/welcome/index.js deleted file mode 100644 index 2d555fa7977..00000000000 --- a/app/assets/javascripts/pages/registrations/welcome/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import LengthValidator from '~/pages/sessions/new/length_validator'; -import NoEmojiValidator from '~/emoji/no_emoji_validator'; - -document.addEventListener('DOMContentLoaded', () => { - new LengthValidator(); // eslint-disable-line no-new - new NoEmojiValidator(); // eslint-disable-line no-new -}); diff --git a/app/assets/stylesheets/pages/prometheus.scss b/app/assets/stylesheets/pages/prometheus.scss index 2138231aaed..8133a167687 100644 --- a/app/assets/stylesheets/pages/prometheus.scss +++ b/app/assets/stylesheets/pages/prometheus.scss @@ -47,6 +47,7 @@ } .prometheus-graphs-header { + .monitor-environment-dropdown-header header, .monitor-dashboard-dropdown-header header { font-size: $gl-font-size; } diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 7bd084458d1..109c8b7005f 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -8,27 +8,26 @@ class Projects::ProjectMembersController < Projects::ApplicationController # Authorize before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access] - # rubocop: disable CodeReuse/ActiveRecord def index @sort = params[:sort].presence || sort_value_name + + @skip_groups = @project.invited_group_ids + @skip_groups += @project.group.self_and_ancestors_ids if @project.group + @group_links = @project.project_group_links + @group_links = @group_links.search(params[:search]) if params[:search].present? - @skip_groups = @group_links.pluck(:group_id) - @skip_groups << @project.namespace_id unless @project.personal? - @skip_groups += @project.group.ancestors.pluck(:id) if @project.group + @project_members = MembersFinder.new(@project, current_user) + .execute(include_relations: requested_relations, params: params.merge(sort: @sort)) - @project_members = MembersFinder.new(@project, current_user).execute(include_relations: requested_relations) + @project_members = present_members(@project_members.page(params[:page])) - if params[:search].present? - @project_members = @project_members.joins(:user).merge(User.search(params[:search])) - @group_links = @group_links.where(group_id: @project.invited_groups.search(params[:search]).select(:id)) - end + @requesters = present_members( + AccessRequestsFinder.new(@project).execute(current_user) + ) - @project_members = present_members(@project_members.sort_by_attribute(@sort).page(params[:page])) - @requesters = present_members(AccessRequestsFinder.new(@project).execute(current_user)) @project_member = @project.project_members.new end - # rubocop: enable CodeReuse/ActiveRecord def import @projects = current_user.authorized_projects.order_id_desc diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c0ba87bf3ed..55f06df6bb0 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -56,7 +56,6 @@ class RegistrationsController < Devise::RegistrationsController return redirect_to stored_location_or_dashboard_or_almost_there_path(current_user) if current_user.role.present? && !current_user.setup_for_company.nil? current_user.name = nil if current_user.name == current_user.username - render layout: 'devise_experimental_separate_sign_up_flow' end def update_registration @@ -68,7 +67,7 @@ class RegistrationsController < Devise::RegistrationsController set_flash_message! :notice, :signed_up redirect_to stored_location_or_dashboard_or_almost_there_path(current_user) else - render :welcome, layout: 'devise_experimental_separate_sign_up_flow' + render :welcome end end diff --git a/app/finders/members_finder.rb b/app/finders/members_finder.rb index a919ff5bf8a..0617f34dc8c 100644 --- a/app/finders/members_finder.rb +++ b/app/finders/members_finder.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true class MembersFinder - attr_reader :project, :current_user, :group + # Params can be any of the following: + # sort: string + # search: string def initialize(project, current_user) @project = project @@ -9,28 +11,39 @@ class MembersFinder @group = project.group end - def execute(include_relations: [:inherited, :direct]) + def execute(include_relations: [:inherited, :direct], params: {}) + members = find_members(include_relations, params) + + filter_members(members, params) + end + + def can?(*args) + Ability.allowed?(*args) + end + + private + + attr_reader :project, :current_user, :group + + def find_members(include_relations, params) project_members = project.project_members project_members = project_members.non_invite unless can?(current_user, :admin_project, project) return project_members if include_relations == [:direct] union_members = group_union_members(include_relations) - union_members << project_members if include_relations.include?(:direct) - if union_members.any? - distinct_union_of_members(union_members) - else - project_members - end - end + return project_members unless union_members.any? - def can?(*args) - Ability.allowed?(*args) + distinct_union_of_members(union_members) end - private + def filter_members(members, params) + members = members.search(params[:search]) if params[:search].present? + members = members.sort_by_attribute(params[:sort]) if params[:sort].present? + members + end def group_union_members(include_relations) [].tap do |members| diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index d58f634425b..ace8bae03ac 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -18,7 +18,7 @@ module CommitsHelper end def commit_to_html(commit, ref, project) - render 'projects/commits/commit', + render 'projects/commits/commit.html', commit: commit, ref: ref, project: project diff --git a/app/models/concerns/discussion_on_diff.rb b/app/models/concerns/discussion_on_diff.rb index e4e5928f5cf..8542c48f366 100644 --- a/app/models/concerns/discussion_on_diff.rb +++ b/app/models/concerns/discussion_on_diff.rb @@ -40,7 +40,7 @@ module DiscussionOnDiff # Returns an array of at most 16 highlighted lines above a diff note def truncated_diff_lines(highlight: true, diff_limit: nil) return [] unless on_text? - return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote) + return [] if diff_line.nil? diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min lines = highlight ? highlighted_diff_lines : diff_lines diff --git a/app/models/project_group_link.rb b/app/models/project_group_link.rb index b70c07a8386..bc16a34612a 100644 --- a/app/models/project_group_link.rb +++ b/app/models/project_group_link.rb @@ -31,6 +31,10 @@ class ProjectGroupLink < ApplicationRecord DEVELOPER end + def self.search(query) + joins(:group).merge(Group.search(query)) + end + def human_access self.class.access_options.key(self.group_access) end diff --git a/app/services/projects/after_import_service.rb b/app/services/projects/after_import_service.rb index 6fc15db9b4c..a2270f10547 100644 --- a/app/services/projects/after_import_service.rb +++ b/app/services/projects/after_import_service.rb @@ -12,7 +12,9 @@ module Projects service = Projects::HousekeepingService.new(@project) service.execute do - repository.delete_all_refs_except(RESERVED_REF_PREFIXES) + import_failure_service.with_retry(action: 'delete_all_refs') do + repository.delete_all_refs_except(RESERVED_REF_PREFIXES) + end end # Right now we don't actually have a way to know if a project @@ -26,6 +28,10 @@ module Projects private + def import_failure_service + @import_failure_service ||= Gitlab::ImportExport::ImportFailureService.new(@project) + end + def repository @repository ||= @project.repository end diff --git a/app/services/suggestions/apply_service.rb b/app/services/suggestions/apply_service.rb index a6485e42bdb..479eed3ce57 100644 --- a/app/services/suggestions/apply_service.rb +++ b/app/services/suggestions/apply_service.rb @@ -96,7 +96,7 @@ module Suggestions end def suggestion_commit_message(project) - project.suggestion_commit_message || DEFAULT_SUGGESTION_COMMIT_MESSAGE + project.suggestion_commit_message.presence || DEFAULT_SUGGESTION_COMMIT_MESSAGE end def processed_suggestion_commit_message(suggestion) |