diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-23 12:08:18 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-23 12:08:18 +0000 |
commit | 4aeb8a02c506eaa8f0710ee17edd9e35dd68d280 (patch) | |
tree | 42a0ab818ee72a5f99d017f7ca05b6b6349e142a /app | |
parent | b8bb2148c282f5ebaf5cd3c83d905285902a1446 (diff) | |
download | gitlab-ce-4aeb8a02c506eaa8f0710ee17edd9e35dd68d280.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/boards/components/modal/list.vue | 6 | ||||
-rw-r--r-- | app/assets/javascripts/commit/pipelines/pipelines_table.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/fly_out_nav.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/wikis/wikis.js | 4 | ||||
-rw-r--r-- | app/controllers/projects/raw_controller.rb | 12 | ||||
-rw-r--r-- | app/graphql/gitlab_schema.rb | 9 | ||||
-rw-r--r-- | app/graphql/resolvers/base_resolver.rb | 14 |
8 files changed, 38 insertions, 18 deletions
diff --git a/app/assets/javascripts/boards/components/modal/list.vue b/app/assets/javascripts/boards/components/modal/list.vue index 1802b543687..78e3351a79e 100644 --- a/app/assets/javascripts/boards/components/modal/list.vue +++ b/app/assets/javascripts/boards/components/modal/list.vue @@ -1,6 +1,6 @@ <script> +import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import Icon from '~/vue_shared/components/icon.vue'; -import bp from '../../../breakpoints'; import ModalStore from '../../stores/modal_store'; import IssueCardInner from '../issue_card_inner.vue'; @@ -105,9 +105,9 @@ export default { setColumnCount() { const breakpoint = bp.getBreakpointSize(); - if (breakpoint === 'lg' || breakpoint === 'md') { + if (breakpoint === 'xl' || breakpoint === 'lg') { this.columns = 3; - } else if (breakpoint === 'sm') { + } else if (breakpoint === 'md') { this.columns = 2; } else { this.columns = 1; diff --git a/app/assets/javascripts/commit/pipelines/pipelines_table.vue b/app/assets/javascripts/commit/pipelines/pipelines_table.vue index e5b030d4900..6b0d184faec 100644 --- a/app/assets/javascripts/commit/pipelines/pipelines_table.vue +++ b/app/assets/javascripts/commit/pipelines/pipelines_table.vue @@ -1,5 +1,6 @@ <script> import { GlButton, GlLoadingIcon } from '@gitlab/ui'; +import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import PipelinesService from '~/pipelines/services/pipelines_service'; import PipelineStore from '~/pipelines/stores/pipelines_store'; import pipelinesMixin from '~/pipelines/mixins/pipelines'; @@ -7,7 +8,6 @@ import eventHub from '~/pipelines/event_hub'; import TablePagination from '~/vue_shared/components/pagination/table_pagination.vue'; import { getParameterByName } from '~/lib/utils/common_utils'; import CIPaginationMixin from '~/vue_shared/mixins/ci_pagination_api_mixin'; -import bp from '~/breakpoints'; export default { components: { diff --git a/app/assets/javascripts/fly_out_nav.js b/app/assets/javascripts/fly_out_nav.js index 2566ed6b47c..b9ce0851585 100644 --- a/app/assets/javascripts/fly_out_nav.js +++ b/app/assets/javascripts/fly_out_nav.js @@ -1,4 +1,4 @@ -import bp from './breakpoints'; +import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { SIDEBAR_COLLAPSED_CLASS } from './contextual_sidebar'; const HIDE_INTERVAL_TIMEOUT = 300; @@ -40,10 +40,7 @@ export const canShowActiveSubItems = el => { return true; }; -export const canShowSubItems = () => - bp.getBreakpointSize() === 'sm' || - bp.getBreakpointSize() === 'md' || - bp.getBreakpointSize() === 'lg'; +export const canShowSubItems = () => ['md', 'lg', 'xl'].includes(bp.getBreakpointSize()); export const getHideSubItemsInterval = () => { if (!currentOpenMenu || !mousePos.length) return 0; diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 71f73cd5420..18462cc24c7 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -2,12 +2,12 @@ * @module common-utils */ +import { GlBreakpointInstance as breakpointInstance } from '@gitlab/ui/dist/utils'; import $ from 'jquery'; import axios from './axios_utils'; import { getLocationHash } from './url_utility'; import { convertToCamelCase, convertToSnakeCase } from './text_utility'; import { isObject } from './type_utility'; -import breakpointInstance from '../../breakpoints'; export const getPagePath = (index = 0) => { const page = $('body').attr('data-page') || ''; diff --git a/app/assets/javascripts/pages/projects/wikis/wikis.js b/app/assets/javascripts/pages/projects/wikis/wikis.js index d41199f6374..80b62859134 100644 --- a/app/assets/javascripts/pages/projects/wikis/wikis.js +++ b/app/assets/javascripts/pages/projects/wikis/wikis.js @@ -1,4 +1,4 @@ -import bp from '../../../breakpoints'; +import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { s__, sprintf } from '~/locale'; export default class Wikis { @@ -52,7 +52,7 @@ export default class Wikis { static sidebarCanCollapse() { const bootstrapBreakpoint = bp.getBreakpointSize(); - return bootstrapBreakpoint === 'xs'; + return bootstrapBreakpoint === 'xs' || bootstrapBreakpoint === 'sm'; } renderSidebar() { diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index f39d98be516..f7bc6898112 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -9,9 +9,9 @@ class Projects::RawController < Projects::ApplicationController prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:blob) } before_action :require_non_empty_project - before_action :assign_ref_vars before_action :authorize_download_code! before_action :show_rate_limit, only: [:show], unless: :external_storage_request? + before_action :assign_ref_vars before_action :redirect_to_external_storage, only: :show, if: :static_objects_external_storage_enabled? def show @@ -23,11 +23,15 @@ class Projects::RawController < Projects::ApplicationController private def show_rate_limit - if rate_limiter.throttled?(:show_raw_controller, scope: [@project, @commit, @path], threshold: raw_blob_request_limit) + # This bypasses assign_ref_vars to avoid a Gitaly FindCommit lookup. + # When rate limiting, we really don't care if a different commit is + # being requested. + _ref, path = extract_ref(get_id) + + if rate_limiter.throttled?(:show_raw_controller, scope: [@project, path], threshold: raw_blob_request_limit) rate_limiter.log_request(request, :raw_blob_request_limit, current_user) - flash[:alert] = _('You cannot access the raw file. Please wait a minute.') - redirect_to project_blob_path(@project, File.join(@ref, @path)), status: :too_many_requests + render plain: _('You cannot access the raw file. Please wait a minute.'), status: :too_many_requests end end diff --git a/app/graphql/gitlab_schema.rb b/app/graphql/gitlab_schema.rb index a5ddf316572..ccbb1d56030 100644 --- a/app/graphql/gitlab_schema.rb +++ b/app/graphql/gitlab_schema.rb @@ -57,13 +57,20 @@ class GitlabSchema < GraphQL::Schema object.to_global_id end - def object_from_id(global_id, _ctx = nil) + def object_from_id(global_id, ctx = {}) + expected_type = ctx[:expected_type] gid = GlobalID.parse(global_id) unless gid raise Gitlab::Graphql::Errors::ArgumentError, "#{global_id} is not a valid GitLab id." end + if expected_type && !gid.model_class.ancestors.include?(expected_type) + vars = { global_id: global_id, expected_type: expected_type } + msg = _('%{global_id} is not a valid id for %{expected_type}.') % vars + raise Gitlab::Graphql::Errors::ArgumentError, msg + end + if gid.model_class < ApplicationRecord Gitlab::Graphql::Loaders::BatchModelLoader.new(gid.model_class, gid.model_id).find elsif gid.model_class.respond_to?(:lazy_find) diff --git a/app/graphql/resolvers/base_resolver.rb b/app/graphql/resolvers/base_resolver.rb index 62dcc41dd9c..f2b015edfa1 100644 --- a/app/graphql/resolvers/base_resolver.rb +++ b/app/graphql/resolvers/base_resolver.rb @@ -9,6 +9,10 @@ module Resolvers def resolve(**args) super.first end + + def single? + true + end end end @@ -17,6 +21,10 @@ module Resolvers def resolve(**args) super.last end + + def single? + true + end end end @@ -42,9 +50,13 @@ module Resolvers override :object def object super.tap do |obj| - # If the field this resolver is used in is wrapped in a presenter, go back to it's subject + # If the field this resolver is used in is wrapped in a presenter, unwrap its subject break obj.subject if obj.is_a?(Gitlab::View::Presenter::Base) end end + + def single? + false + end end end |