diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 09:08:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 09:08:47 +0000 |
commit | 66d4203791a01fdedf668a78818a229ea2c07aad (patch) | |
tree | 374fc9f6c5e709cf6ab48e257e6bfe4a504d6bbb /app | |
parent | a496f41f60e12a0a5c31482b7594ad547e0ade42 (diff) | |
download | gitlab-ce-66d4203791a01fdedf668a78818a229ea2c07aad.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
5 files changed, 62 insertions, 50 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue index 66167a0d748..5eccc0c543d 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue @@ -1,6 +1,6 @@ <script> import _ from 'underscore'; -import { GlIcon } from '@gitlab/ui'; +import { GlIcon, GlButton } from '@gitlab/ui'; import successSvg from 'icons/_icon_status_success.svg'; import warningSvg from 'icons/_icon_status_warning.svg'; import readyToMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/ready_to_merge'; @@ -26,6 +26,7 @@ export default { CommitEdit, CommitMessageDropdown, GlIcon, + GlButton, MergeImmediatelyConfirmationDialog: () => import( 'ee_component/vue_merge_request_widget/components/merge_immediately_confirmation_dialog.vue' @@ -67,18 +68,13 @@ export default { return 'success'; }, - mergeButtonClass() { - const defaultClass = 'btn btn-sm btn-success accept-merge-request'; - const failedClass = `${defaultClass} btn-danger`; - const inActionClass = `${defaultClass} btn-info`; - + mergeButtonVariant() { if (this.status === 'failed') { - return failedClass; + return 'danger'; } else if (this.status === 'pending') { - return inActionClass; + return 'info'; } - - return defaultClass; + return 'success'; }, iconClass() { if ( @@ -267,16 +263,16 @@ export default { <div class="media-body"> <div class="mr-widget-body-controls media space-children"> <span class="btn-group"> - <button + <gl-button + size="sm" + class="qa-merge-button accept-merge-request" + :variant="mergeButtonVariant" :disabled="isMergeButtonDisabled" - :class="mergeButtonClass" - type="button" - class="qa-merge-button" + :loading="isMakingRequest" @click="handleMergeButtonClick(isAutoMergeAvailable)" > - <i v-if="isMakingRequest" class="fa fa-spinner fa-spin" aria-hidden="true"></i> {{ mergeButtonText }} - </button> + </gl-button> <button v-if="shouldShowMergeImmediatelyDropdown" :disabled="isMergeButtonDisabled" diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue index 8132b1a944b..e52ad9156d5 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue @@ -1,15 +1,17 @@ <script> import $ from 'jquery'; -import { __ } from '~/locale'; +import { GlButton } from '@gitlab/ui'; +import { __, s__ } from '~/locale'; import createFlash from '~/flash'; -import statusIcon from '../mr_widget_status_icon.vue'; +import StatusIcon from '../mr_widget_status_icon.vue'; import tooltip from '../../../vue_shared/directives/tooltip'; import eventHub from '../../event_hub'; export default { name: 'WorkInProgress', components: { - statusIcon, + StatusIcon, + GlButton, }, directives: { tooltip, @@ -23,8 +25,15 @@ export default { isMakingRequest: false, }; }, + computed: { + wipInfoTooltip() { + return s__( + 'mrWidget|When this merge request is ready, remove the WIP: prefix from the title to allow it to be merged', + ); + }, + }, methods: { - removeWIP() { + handleRemoveWIP() { this.isMakingRequest = true; this.service .removeWIP() @@ -52,29 +61,22 @@ export default { <i v-tooltip class="fa fa-question-circle" - :title=" - s__( - 'mrWidget|When this merge request is ready, remove the WIP: prefix from the title to allow it to be merged', - ) - " - :aria-label=" - s__( - 'mrWidget|When this merge request is ready, remove the WIP: prefix from the title to allow it to be merged', - ) - " + :title="wipInfoTooltip" + :aria-label="wipInfoTooltip" > </i> </span> - <button + <gl-button v-if="mr.removeWIPPath" + size="sm" + variant="default" :disabled="isMakingRequest" - type="button" - class="btn btn-default btn-sm js-remove-wip" - @click="removeWIP" + :loading="isMakingRequest" + class="js-remove-wip" + @click="handleRemoveWIP" > - <i v-if="isMakingRequest" class="fa fa-spinner fa-spin" aria-hidden="true"> </i> {{ s__('mrWidget|Resolve WIP status') }} - </button> + </gl-button> </div> </div> </template> diff --git a/app/graphql/resolvers/base_resolver.rb b/app/graphql/resolvers/base_resolver.rb index 66cb224f157..cf0642930ad 100644 --- a/app/graphql/resolvers/base_resolver.rb +++ b/app/graphql/resolvers/base_resolver.rb @@ -28,6 +28,10 @@ module Resolvers end end + def self.complexity + 0 + end + def self.resolver_complexity(args, child_complexity:) complexity = 1 complexity += 1 if args[:sort] diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb index 3ade1300c2d..8ff2b5ad532 100644 --- a/app/graphql/types/base_field.rb +++ b/app/graphql/types/base_field.rb @@ -9,7 +9,7 @@ module Types def initialize(*args, **kwargs, &block) @calls_gitaly = !!kwargs.delete(:calls_gitaly) @constant_complexity = !!kwargs[:complexity] - kwargs[:complexity] ||= field_complexity(kwargs[:resolver_class]) + kwargs[:complexity] = field_complexity(kwargs[:resolver_class], kwargs[:complexity]) @feature_flag = kwargs[:feature_flag] kwargs = check_feature_flag(kwargs) @@ -51,7 +51,9 @@ module Types args end - def field_complexity(resolver_class) + def field_complexity(resolver_class, current) + return current if current.present? && current > 0 + if resolver_class field_resolver_complexity else @@ -66,22 +68,30 @@ module Types # proc because we set complexity depending on arguments and number of # items which can be loaded. proc do |ctx, args, child_complexity| + next base_complexity unless resolver_complexity_enabled?(ctx) + # Resolvers may add extra complexity depending on used arguments complexity = child_complexity + self.resolver&.try(:resolver_complexity, args, child_complexity: child_complexity).to_i complexity += 1 if calls_gitaly? - - field_defn = to_graphql - - if field_defn.connection? - # Resolvers may add extra complexity depending on number of items being loaded. - page_size = field_defn.connection_max_page_size || ctx.schema.default_max_page_size - limit_value = [args[:first], args[:last], page_size].compact.min - multiplier = self.resolver&.try(:complexity_multiplier, args).to_f - complexity += complexity * limit_value * multiplier - end + complexity += complexity * connection_complexity_multiplier(ctx, args) complexity.to_i end end + + def resolver_complexity_enabled?(ctx) + ctx.fetch(:graphql_resolver_complexity_flag) { |key| ctx[key] = Feature.enabled?(:graphql_resolver_complexity) } + end + + def connection_complexity_multiplier(ctx, args) + # Resolvers may add extra complexity depending on number of items being loaded. + field_defn = to_graphql + return 0 unless field_defn.connection? + + page_size = field_defn.connection_max_page_size || ctx.schema.default_max_page_size + limit_value = [args[:first], args[:last], page_size].compact.min + multiplier = self.resolver&.try(:complexity_multiplier, args).to_f + limit_value * multiplier + end end end diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb index 10bbeecc2f7..7c12fe29ade 100644 --- a/app/models/concerns/spammable.rb +++ b/app/models/concerns/spammable.rb @@ -16,7 +16,7 @@ module Spammable attr_accessor :spam_log alias_method :spam?, :spam - after_validation :check_for_spam, on: [:create, :update] + after_validation :invalidate_if_spam, on: [:create, :update] cattr_accessor :spammable_attrs, instance_accessor: false do [] @@ -37,7 +37,7 @@ module Spammable end end - def check_for_spam + def invalidate_if_spam error_msg = if Gitlab::Recaptcha.enabled? "Your #{spammable_entity_type} has been recognized as spam. "\ "Please, change the content or solve the reCAPTCHA to proceed." |