diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-14 15:06:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-14 15:06:30 +0300 |
commit | d8c06be498acbfc2024c01b6b6b02d120dc499f2 (patch) | |
tree | 9e2e0852c45332d6222898676a2f6f096e600084 /app | |
parent | 2fa7d2ddf6a7004f89616e43b8279229af831e25 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/cycle_analytics/components/stage_card_list_item.vue | 44 | ||||
-rw-r--r-- | app/assets/javascripts/cycle_analytics/components/stage_nav_item.vue | 36 | ||||
-rw-r--r-- | app/assets/javascripts/repository/components/last_commit.vue | 17 | ||||
-rw-r--r-- | app/assets/javascripts/repository/components/preview/index.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/repository/queries/pathLastCommit.query.graphql | 18 | ||||
-rw-r--r-- | app/assets/javascripts/repository/utils/readme.js | 8 | ||||
-rw-r--r-- | app/controllers/concerns/issuable_collections.rb | 2 | ||||
-rw-r--r-- | app/controllers/groups/boards_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/boards_controller.rb | 2 | ||||
-rw-r--r-- | app/graphql/resolvers/base_resolver.rb | 8 | ||||
-rw-r--r-- | app/graphql/resolvers/commit_pipelines_resolver.rb | 13 | ||||
-rw-r--r-- | app/graphql/types/commit_type.rb | 10 | ||||
-rw-r--r-- | app/models/group.rb | 8 | ||||
-rw-r--r-- | app/models/merge_request.rb | 25 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 6 | ||||
-rw-r--r-- | app/views/layouts/header/_current_user_dropdown.html.haml | 2 |
16 files changed, 92 insertions, 111 deletions
diff --git a/app/assets/javascripts/cycle_analytics/components/stage_card_list_item.vue b/app/assets/javascripts/cycle_analytics/components/stage_card_list_item.vue deleted file mode 100644 index fc6d83bf96c..00000000000 --- a/app/assets/javascripts/cycle_analytics/components/stage_card_list_item.vue +++ /dev/null @@ -1,44 +0,0 @@ -<script> -import Icon from '~/vue_shared/components/icon.vue'; -import { GlButton } from '@gitlab/ui'; - -export default { - name: 'StageCardListItem', - components: { - Icon, - GlButton, - }, - props: { - isActive: { - type: Boolean, - required: true, - }, - canEdit: { - type: Boolean, - default: false, - required: false, - }, - }, -}; -</script> - -<template> - <div - :class="{ active: isActive }" - class="stage-nav-item d-flex pl-4 pr-4 m-0 mb-1 ml-2 rounded border-color-default border-style-solid border-width-1px" - > - <slot></slot> - <div v-if="canEdit" class="dropdown"> - <gl-button - :title="__('More actions')" - class="more-actions-toggle btn btn-transparent p-0" - data-toggle="dropdown" - > - <icon class="icon" name="ellipsis_v" /> - </gl-button> - <ul class="more-actions-dropdown dropdown-menu dropdown-open-left"> - <slot name="dropdown-options"></slot> - </ul> - </div> - </div> -</template> diff --git a/app/assets/javascripts/cycle_analytics/components/stage_nav_item.vue b/app/assets/javascripts/cycle_analytics/components/stage_nav_item.vue index 004d335f572..1b09fe1b370 100644 --- a/app/assets/javascripts/cycle_analytics/components/stage_nav_item.vue +++ b/app/assets/javascripts/cycle_analytics/components/stage_nav_item.vue @@ -1,11 +1,6 @@ <script> -import StageCardListItem from './stage_card_list_item.vue'; - export default { name: 'StageNavItem', - components: { - StageCardListItem, - }, props: { isDefaultStage: { type: Boolean, @@ -40,16 +35,16 @@ export default { hasValue() { return this.value && this.value.length > 0; }, - editable() { - return this.isUserAllowed && this.canEdit; - }, }, }; </script> <template> <li @click="$emit('select')"> - <stage-card-list-item :is-active="isActive" :can-edit="editable"> + <div + :class="{ active: isActive }" + class="stage-nav-item d-flex pl-4 pr-4 m-0 mb-1 ml-2 rounded border-color-default border-style-solid border-width-1px" + > <div class="stage-nav-item-cell stage-name p-0" :class="{ 'font-weight-bold': isActive }"> {{ title }} </div> @@ -62,27 +57,6 @@ export default { <span class="not-available">{{ __('Not available') }}</span> </template> </div> - <template v-slot:dropdown-options> - <template v-if="isDefaultStage"> - <li> - <button type="button" class="btn-default btn-transparent"> - {{ __('Hide stage') }} - </button> - </li> - </template> - <template v-else> - <li> - <button type="button" class="btn-default btn-transparent"> - {{ __('Edit stage') }} - </button> - </li> - <li> - <button type="button" class="btn-danger danger"> - {{ __('Remove stage') }} - </button> - </li> - </template> - </template> - </stage-card-list-item> + </div> </li> </template> diff --git a/app/assets/javascripts/repository/components/last_commit.vue b/app/assets/javascripts/repository/components/last_commit.vue index 5cbe8d6247a..5a89efa4538 100644 --- a/app/assets/javascripts/repository/components/last_commit.vue +++ b/app/assets/javascripts/repository/components/last_commit.vue @@ -38,7 +38,14 @@ export default { path: this.currentPath.replace(/^\//, ''), }; }, - update: data => data.project.repository.tree.lastCommit, + update: data => { + const pipelines = data.project.repository.tree.lastCommit.pipelines.edges; + + return { + ...data.project.repository.tree.lastCommit, + pipeline: pipelines.length && pipelines[0].node, + }; + }, context: { isSingleRequest: true, }, @@ -61,7 +68,7 @@ export default { computed: { statusTitle() { return sprintf(s__('Commits|Commit: %{commitText}'), { - commitText: this.commit.latestPipeline.detailedStatus.text, + commitText: this.commit.pipeline.detailedStatus.text, }); }, isLoading() { @@ -127,14 +134,14 @@ export default { <div v-if="commit.signatureHtml" v-html="commit.signatureHtml"></div> <div class="ci-status-link"> <gl-link - v-if="commit.latestPipeline" + v-if="commit.pipeline" v-gl-tooltip.left - :href="commit.latestPipeline.detailedStatus.detailsPath" + :href="commit.pipeline.detailedStatus.detailsPath" :title="statusTitle" class="js-commit-pipeline" > <ci-icon - :status="commit.latestPipeline.detailedStatus" + :status="commit.pipeline.detailedStatus" :size="24" :aria-label="statusTitle" /> diff --git a/app/assets/javascripts/repository/components/preview/index.vue b/app/assets/javascripts/repository/components/preview/index.vue index 564be211c46..7f974838359 100644 --- a/app/assets/javascripts/repository/components/preview/index.vue +++ b/app/assets/javascripts/repository/components/preview/index.vue @@ -34,7 +34,7 @@ export default { </script> <template> - <article class="file-holder js-hide-on-navigation limited-width-container readme-holder"> + <article class="file-holder limited-width-container readme-holder"> <div class="file-title"> <i aria-hidden="true" class="fa fa-file-text-o fa-fw"></i> <gl-link :href="blob.webUrl"> diff --git a/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql b/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql index 71c1bf12749..74ccdd79dd0 100644 --- a/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql +++ b/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql @@ -14,13 +14,17 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { webUrl } signatureHtml - latestPipeline { - detailedStatus { - detailsPath - icon - tooltip - text - group + pipelines(ref: $ref, first: 1) { + edges { + node { + detailedStatus { + detailsPath + icon + tooltip + text + group + } + } } } } diff --git a/app/assets/javascripts/repository/utils/readme.js b/app/assets/javascripts/repository/utils/readme.js index b219b857c66..e43b2bdc33a 100644 --- a/app/assets/javascripts/repository/utils/readme.js +++ b/app/assets/javascripts/repository/utils/readme.js @@ -3,7 +3,11 @@ const ASCIIDOC_EXTENSIONS = ['adoc', 'ad', 'asciidoc']; const OTHER_EXTENSIONS = ['textile', 'rdoc', 'org', 'creole', 'wiki', 'mediawiki', 'rst']; const EXTENSIONS = [...MARKDOWN_EXTENSIONS, ...ASCIIDOC_EXTENSIONS, ...OTHER_EXTENSIONS]; const PLAIN_FILENAMES = ['readme', 'index']; -const FILE_REGEXP = new RegExp(`^(${PLAIN_FILENAMES.join('|')})`, 'i'); +const FILE_REGEXP = new RegExp( + `^(${PLAIN_FILENAMES.join('|')})(.(${EXTENSIONS.join('|')}))?$`, + 'i', +); +const PLAIN_FILE_REGEXP = new RegExp(`^(${PLAIN_FILENAMES.join('|')})`, 'i'); const EXTENSIONS_REGEXP = new RegExp(`.(${EXTENSIONS.join('|')})$`, 'i'); // eslint-disable-next-line import/prefer-default-export @@ -11,7 +15,7 @@ export const readmeFile = blobs => { const readMeFiles = blobs.filter(f => f.name.search(FILE_REGEXP) !== -1); const previewableReadme = readMeFiles.find(f => f.name.search(EXTENSIONS_REGEXP) !== -1); - const plainReadme = readMeFiles.find(f => f.name.search(FILE_REGEXP) !== -1); + const plainReadme = readMeFiles.find(f => f.name.search(PLAIN_FILE_REGEXP) !== -1); return previewableReadme || plainReadme; }; diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index c9a8de0b290..5aa00af8910 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -148,7 +148,7 @@ module IssuableCollections when 'Issue' common_attributes + [:project, project: :namespace] when 'MergeRequest' - common_attributes + [:target_project, source_project: :route, head_pipeline: :project, target_project: :namespace, latest_merge_request_diff: :merge_request_diff_commits] + common_attributes + [:target_project, :latest_merge_request_diff, source_project: :route, head_pipeline: :project, target_project: :namespace] end end # rubocop:enable Gitlab/ModuleWithInstanceVariables diff --git a/app/controllers/groups/boards_controller.rb b/app/controllers/groups/boards_controller.rb index 3c86f3108ab..8c9bf17f017 100644 --- a/app/controllers/groups/boards_controller.rb +++ b/app/controllers/groups/boards_controller.rb @@ -6,7 +6,7 @@ class Groups::BoardsController < Groups::ApplicationController before_action :assign_endpoint_vars before_action do - push_frontend_feature_flag(:multi_select_board) + push_frontend_feature_flag(:multi_select_board, default_enabled: true) end private diff --git a/app/controllers/projects/boards_controller.rb b/app/controllers/projects/boards_controller.rb index 3b335fa4af4..db05da0bb7f 100644 --- a/app/controllers/projects/boards_controller.rb +++ b/app/controllers/projects/boards_controller.rb @@ -8,7 +8,7 @@ class Projects::BoardsController < Projects::ApplicationController before_action :authorize_read_board!, only: [:index, :show] before_action :assign_endpoint_vars before_action do - push_frontend_feature_flag(:multi_select_board) + push_frontend_feature_flag(:multi_select_board, default_enabled: true) end private diff --git a/app/graphql/resolvers/base_resolver.rb b/app/graphql/resolvers/base_resolver.rb index 5b7eb57841c..85d6b377934 100644 --- a/app/graphql/resolvers/base_resolver.rb +++ b/app/graphql/resolvers/base_resolver.rb @@ -10,6 +10,14 @@ module Resolvers end end + def self.last + @last ||= Class.new(self) do + def resolve(**args) + super.last + end + end + end + def self.resolver_complexity(args, child_complexity:) complexity = 1 complexity += 1 if args[:sort] diff --git a/app/graphql/resolvers/commit_pipelines_resolver.rb b/app/graphql/resolvers/commit_pipelines_resolver.rb new file mode 100644 index 00000000000..92a83523593 --- /dev/null +++ b/app/graphql/resolvers/commit_pipelines_resolver.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Resolvers + class CommitPipelinesResolver < BaseResolver + include ::ResolvesPipelines + + alias_method :commit, :object + + def resolve(**args) + resolve_pipelines(commit.project, args.merge!({ sha: commit.sha })) + end + end +end diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb index d5600881728..dcf4a2802c7 100644 --- a/app/graphql/types/commit_type.rb +++ b/app/graphql/types/commit_type.rb @@ -29,12 +29,16 @@ module Types field :author, type: Types::UserType, null: true, description: 'Author of the commit' + field :pipelines, Types::Ci::PipelineType.connection_type, + null: true, + description: 'Pipelines of the commit ordered latest first', + resolver: Resolvers::CommitPipelinesResolver + field :latest_pipeline, type: Types::Ci::PipelineType, null: true, description: "Latest pipeline of the commit", - resolve: -> (obj, ctx, args) do - Gitlab::Graphql::Loaders::PipelineForShaLoader.new(obj.project, obj.sha).find_last - end + deprecation_reason: 'use pipelines', + resolver: Resolvers::CommitPipelinesResolver.last end end diff --git a/app/models/group.rb b/app/models/group.rb index 7496fee0b51..8289d4f099c 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -451,6 +451,14 @@ class Group < Namespace false end + def export_file_exists? + export_file&.file + end + + def export_file + import_export_upload&.export_file + end + private def update_two_factor_requirement diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 5cf2ded114d..df516009397 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -212,8 +212,8 @@ class MergeRequest < ApplicationRecord scope :join_project, -> { joins(:target_project) } scope :references_project, -> { references(:target_project) } scope :with_api_entity_associations, -> { - preload(:assignees, :author, :unresolved_notes, :labels, :milestone, :timelogs, - latest_merge_request_diff: [:merge_request_diff_commits], + preload(:assignees, :author, :unresolved_notes, :labels, :milestone, + :timelogs, :latest_merge_request_diff, metrics: [:latest_closed_by, :merged_by], target_project: [:route, { namespace: :route }], source_project: [:route, { namespace: :route }]) @@ -396,14 +396,17 @@ class MergeRequest < ApplicationRecord end end - def commit_shas - if persisted? - merge_request_diff.commit_shas - elsif compare_commits - compare_commits.to_a.reverse.map(&:sha) - else - Array(diff_head_sha) - end + def commit_shas(limit: nil) + return merge_request_diff.commit_shas(limit: limit) if persisted? + + shas = + if compare_commits + compare_commits.to_a.reverse.map(&:sha) + else + Array(diff_head_sha) + end + + limit ? shas.take(limit) : shas end # Returns true if there are commits that match at least one commit SHA. @@ -913,7 +916,7 @@ class MergeRequest < ApplicationRecord def commit_notes # Fetch comments only from last 100 commits - commit_ids = commit_shas.take(100) + commit_ids = commit_shas(limit: 100) Note .user diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 735ad046f22..5fe97a13a42 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -218,7 +218,7 @@ class MergeRequestDiff < ApplicationRecord end def last_commit_sha - commit_shas.first + commit_shas(limit: 1).first end def first_commit @@ -247,8 +247,8 @@ class MergeRequestDiff < ApplicationRecord project.commit_by(oid: head_commit_sha) end - def commit_shas - merge_request_diff_commits.map(&:sha) + def commit_shas(limit: nil) + merge_request_diff_commits.limit(limit).pluck(:sha) end def commits_by_shas(shas) diff --git a/app/views/layouts/header/_current_user_dropdown.html.haml b/app/views/layouts/header/_current_user_dropdown.html.haml index 8fb335c3801..d15f0ae3228 100644 --- a/app/views/layouts/header/_current_user_dropdown.html.haml +++ b/app/views/layouts/header/_current_user_dropdown.html.haml @@ -21,7 +21,7 @@ - if current_user_menu?(:start_trial) %li %a.profile-link{ href: trials_link_url } - = s_("CurrentUser|Start a trial") + = s_("CurrentUser|Start a Gold trial") = emoji_icon('rocket') - if current_user_menu?(:settings) %li |