diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-29 03:12:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-29 03:12:19 +0000 |
commit | 7d8cc770b14b41fbe40181d447042dccdc45bff8 (patch) | |
tree | 4e14a5e236df733f3c0998cd351a72759c48eb46 /app | |
parent | 8c9cb9bb575b8d9dff39e5b4891fabb1e0f6a687 (diff) | |
download | gitlab-ce-7d8cc770b14b41fbe40181d447042dccdc45bff8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
66 files changed, 296 insertions, 258 deletions
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue index 6095ba79281..09b02068388 100644 --- a/app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue +++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_environments_dropdown.vue @@ -1,16 +1,18 @@ <script> import { debounce, uniq } from 'lodash'; -import { GlDropdownDivider, GlDropdownItem, GlCollapsibleListbox } from '@gitlab/ui'; +import { GlDropdownDivider, GlDropdownItem, GlCollapsibleListbox, GlSprintf } from '@gitlab/ui'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { __, s__, sprintf } from '~/locale'; import { convertEnvironmentScope } from '../utils'; +import { ENVIRONMENT_QUERY_LIMIT } from '../constants'; export default { name: 'CiEnvironmentsDropdown', components: { + GlCollapsibleListbox, GlDropdownDivider, GlDropdownItem, - GlCollapsibleListbox, + GlSprintf, }, mixins: [glFeatureFlagsMixin()], props: { @@ -95,9 +97,10 @@ export default { this.selectEnvironment(this.searchTerm); }, }, + ENVIRONMENT_QUERY_LIMIT, i18n: { maxEnvsNote: s__( - 'CiVariable|Maximum of 20 environments listed. For more environments, enter a search query.', + 'CiVariable|Maximum of %{limit} environments listed. For more environments, enter a search query.', ), }, }; @@ -117,9 +120,11 @@ export default { <gl-dropdown-divider v-if="shouldRenderDivider" /> <div v-if="isEnvScopeLimited" data-testid="max-envs-notice"> <gl-dropdown-item class="gl-list-style-none" disabled> - <span class="gl-font-sm"> - {{ $options.i18n.maxEnvsNote }} - </span> + <gl-sprintf :message="$options.i18n.maxEnvsNote" class="gl-font-sm"> + <template #limit> + {{ $options.ENVIRONMENT_QUERY_LIMIT }} + </template> + </gl-sprintf> </gl-dropdown-item> </div> <div v-if="shouldRenderCreateButton"> diff --git a/app/assets/javascripts/ci/ci_variable_list/constants.js b/app/assets/javascripts/ci/ci_variable_list/constants.js index e6874a5cde6..03374162b79 100644 --- a/app/assets/javascripts/ci/ci_variable_list/constants.js +++ b/app/assets/javascripts/ci/ci_variable_list/constants.js @@ -1,7 +1,7 @@ import { __, s__ } from '~/locale'; export const ADD_CI_VARIABLE_MODAL_ID = 'add-ci-variable'; -export const ENVIRONMENT_QUERY_LIMIT = 20; +export const ENVIRONMENT_QUERY_LIMIT = 30; export const SORT_DIRECTIONS = { ASC: 'KEY_ASC', diff --git a/app/assets/javascripts/notes/components/note_actions.vue b/app/assets/javascripts/notes/components/note_actions.vue index 89cd252b94b..14497a239ca 100644 --- a/app/assets/javascripts/notes/components/note_actions.vue +++ b/app/assets/javascripts/notes/components/note_actions.vue @@ -21,7 +21,7 @@ export default { editCommentLabel: __('Edit comment'), deleteCommentLabel: __('Delete comment'), moreActionsLabel: __('More actions'), - reportAbuse: __('Report abuse to administrator'), + reportAbuse: __('Report abuse'), }, name: 'NoteActions', components: { diff --git a/app/assets/javascripts/notes/components/notes_activity_header.vue b/app/assets/javascripts/notes/components/notes_activity_header.vue index 9c3b2139a5d..95c02884ace 100644 --- a/app/assets/javascripts/notes/components/notes_activity_header.vue +++ b/app/assets/javascripts/notes/components/notes_activity_header.vue @@ -27,7 +27,7 @@ export default { <template> <div - class="gl-display-flex gl-sm-align-items-center gl-flex-direction-column gl-sm-flex-direction-row gl-justify-content-space-between gl-pt-5" + class="gl-display-flex gl-sm-align-items-center gl-flex-direction-column gl-sm-flex-direction-row gl-justify-content-space-between gl-pt-5 gl-pb-3" > <h2 class="gl-font-size-h1 gl-m-0">{{ __('Activity') }}</h2> <div class="gl-display-flex gl-gap-3 gl-w-full gl-sm-w-auto gl-mt-3 gl-sm-mt-0"> diff --git a/app/assets/javascripts/pages/abuse_reports/index.js b/app/assets/javascripts/pages/abuse_reports/index.js index feceeb0b10a..ea7c9042e6d 100644 --- a/app/assets/javascripts/pages/abuse_reports/index.js +++ b/app/assets/javascripts/pages/abuse_reports/index.js @@ -1,3 +1,5 @@ import { initLinkToSpam } from '~/abuse_reports'; +import initFilePickers from '~/file_pickers'; initLinkToSpam(); +initFilePickers(); diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_conflicts.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_conflicts.vue index c69e047aedd..6976bfcc989 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_conflicts.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_conflicts.vue @@ -106,7 +106,7 @@ export default { v-if="userPermissions.canMerge" size="small" variant="confirm" - category="secondary" + category="tertiary" data-testid="merge-locally-button" class="js-check-out-modal-trigger gl-align-self-start" > diff --git a/app/assets/stylesheets/page_bundles/merge_requests.scss b/app/assets/stylesheets/page_bundles/merge_requests.scss index c9a937e21a7..d54b18a18c4 100644 --- a/app/assets/stylesheets/page_bundles/merge_requests.scss +++ b/app/assets/stylesheets/page_bundles/merge_requests.scss @@ -983,8 +983,8 @@ $tabs-holder-z-index: 250; .merge-request-overview { @include media-breakpoint-up(lg) { display: grid; - grid-template-columns: calc(95% - 285px) auto; - grid-gap: 5%; + grid-template-columns: calc(97% - 285px) auto; + grid-gap: 3%; } } diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb index f6b4fbac8d5..edeac57bc42 100644 --- a/app/controllers/abuse_reports_controller.rb +++ b/app/controllers/abuse_reports_controller.rb @@ -55,7 +55,7 @@ class AbuseReportsController < ApplicationController private def report_params - params.require(:abuse_report).permit(:message, :user_id, :category, :reported_from_url, links_to_spam: []) + params.require(:abuse_report).permit(:message, :user_id, :category, :reported_from_url, :screenshot, links_to_spam: []) end # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/controllers/admin/background_migrations_controller.rb b/app/controllers/admin/background_migrations_controller.rb index b904196c5ab..a5211961d81 100644 --- a/app/controllers/admin/background_migrations_controller.rb +++ b/app/controllers/admin/background_migrations_controller.rb @@ -10,6 +10,7 @@ module Admin def index @relations_by_tab = { 'queued' => batched_migration_class.queued.queue_order, + 'finalizing' => batched_migration_class.finalizing.queue_order, 'failed' => batched_migration_class.with_status(:failed).queue_order, 'finished' => batched_migration_class.with_status(:finished).queue_order.reverse_order } diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index e53d0bc65a0..db756ae336f 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -5,7 +5,7 @@ module UploadsActions include Gitlab::Utils::StrongMemoize include SendFileUpload - UPLOAD_MOUNTS = %w[avatar attachment file logo pwa_icon header_logo favicon].freeze + UPLOAD_MOUNTS = %w[avatar attachment file logo pwa_icon header_logo favicon screenshot].freeze included do prepend_before_action :set_request_format_from_path_extension diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index ea99aa12350..1a966739401 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -16,6 +16,7 @@ class UploadsController < ApplicationController "projects/topic" => Projects::Topic, 'alert_management_metric_image' => ::AlertManagement::MetricImage, "achievements/achievement" => Achievements::Achievement, + "abuse_report" => AbuseReport, nil => PersonalSnippet }.freeze diff --git a/app/finders/data_transfer/group_data_transfer_finder.rb b/app/finders/data_transfer/group_data_transfer_finder.rb new file mode 100644 index 00000000000..19ab99d4477 --- /dev/null +++ b/app/finders/data_transfer/group_data_transfer_finder.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module DataTransfer + class GroupDataTransferFinder + def initialize(group:, from:, to:, user:) + @group = group + @from = from + @to = to + @user = user + end + + def execute + return ::Projects::DataTransfer.none unless Ability.allowed?(user, :read_usage_quotas, group) + + ::Projects::DataTransfer + .with_namespace_between_dates(group, from, to) + .select('SUM(repository_egress + + artifacts_egress + + packages_egress + + registry_egress + ) as total_egress, + SUM(repository_egress) as repository_egress, + SUM(artifacts_egress) as artifacts_egress, + SUM(packages_egress) as packages_egress, + SUM(registry_egress) as registry_egress, + date, + namespace_id') + end + + private + + attr_reader :group, :from, :to, :user + end +end diff --git a/app/finders/data_transfer/mocked_transfer_finder.rb b/app/finders/data_transfer/mocked_transfer_finder.rb new file mode 100644 index 00000000000..9c5551005ea --- /dev/null +++ b/app/finders/data_transfer/mocked_transfer_finder.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# Mocked data for data transfer +# Follow this epic for recent progress: https://gitlab.com/groups/gitlab-org/-/epics/9330 +module DataTransfer + class MockedTransferFinder + def execute + start_date = Date.new(2023, 0o1, 0o1) + date_for_index = ->(i) { (start_date + i.months).strftime('%Y-%m-%d') } + + 0.upto(11).map do |i| + { + date: date_for_index.call(i), + repository_egress: rand(70000..550000), + artifacts_egress: rand(70000..550000), + packages_egress: rand(70000..550000), + registry_egress: rand(70000..550000) + }.tap do |hash| + hash[:total_egress] = hash + .slice(:repository_egress, :artifacts_egress, :packages_egress, :registry_egress) + .values + .sum + end + end + end + end +end diff --git a/app/finders/data_transfer/project_data_transfer_finder.rb b/app/finders/data_transfer/project_data_transfer_finder.rb new file mode 100644 index 00000000000..bcabbdb00a5 --- /dev/null +++ b/app/finders/data_transfer/project_data_transfer_finder.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module DataTransfer + class ProjectDataTransferFinder + def initialize(project:, from:, to:, user:) + @project = project + @from = from + @to = to + @user = user + end + + def execute + return ::Projects::DataTransfer.none unless Ability.allowed?(user, :read_usage_quotas, project) + + ::Projects::DataTransfer + .with_project_between_dates(project, from, to) + .select(:project_id, :date, :repository_egress, :artifacts_egress, :packages_egress, :registry_egress, + "repository_egress + artifacts_egress + packages_egress + registry_egress as total_egress") + end + + private + + attr_reader :project, :from, :to, :user + end +end diff --git a/app/graphql/mutations/award_emojis/base.rb b/app/graphql/mutations/award_emojis/base.rb index dc2d46269e6..65065de0de4 100644 --- a/app/graphql/mutations/award_emojis/base.rb +++ b/app/graphql/mutations/award_emojis/base.rb @@ -3,8 +3,6 @@ module Mutations module AwardEmojis class Base < BaseMutation - include ::Mutations::FindsByGid - NOT_EMOJI_AWARDABLE = 'You cannot award emoji to this resource.' authorize :award_emoji diff --git a/app/graphql/mutations/boards/update.rb b/app/graphql/mutations/boards/update.rb index 7cfce9d2d91..f611608d1b6 100644 --- a/app/graphql/mutations/boards/update.rb +++ b/app/graphql/mutations/boards/update.rb @@ -29,12 +29,6 @@ module Mutations errors: errors_on_object(board) } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/ci/runner/delete.rb b/app/graphql/mutations/ci/runner/delete.rb index db68914a4eb..ba309ca754d 100644 --- a/app/graphql/mutations/ci/runner/delete.rb +++ b/app/graphql/mutations/ci/runner/delete.rb @@ -15,16 +15,12 @@ module Mutations description: 'ID of the runner to delete.' def resolve(id:, **runner_attrs) - runner = authorized_find!(id) + runner = authorized_find!(id: id) ::Ci::Runners::UnregisterRunnerService.new(runner, current_user).execute { errors: runner.errors.full_messages } end - - def find_object(id) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/ci/runner/update.rb b/app/graphql/mutations/ci/runner/update.rb index 70f08e03553..00865b177a8 100644 --- a/app/graphql/mutations/ci/runner/update.rb +++ b/app/graphql/mutations/ci/runner/update.rb @@ -27,7 +27,7 @@ module Mutations description: 'Runner after mutation.' def resolve(id:, **runner_attrs) - runner = authorized_find!(id) + runner = authorized_find!(id: id) associated_projects_ids = runner_attrs.delete(:associated_projects) @@ -40,10 +40,6 @@ module Mutations response end - def find_object(id) - GitlabSchema.find_by_gid(id) - end - private def associate_runner_projects(response, runner, associated_project_ids) diff --git a/app/graphql/mutations/clusters/agent_tokens/create.rb b/app/graphql/mutations/clusters/agent_tokens/create.rb index 1b104652bd2..e717ff4d798 100644 --- a/app/graphql/mutations/clusters/agent_tokens/create.rb +++ b/app/graphql/mutations/clusters/agent_tokens/create.rb @@ -54,12 +54,6 @@ module Mutations errors: Array.wrap(result.message) } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/clusters/agent_tokens/revoke.rb b/app/graphql/mutations/clusters/agent_tokens/revoke.rb index 6e988799921..c4187746464 100644 --- a/app/graphql/mutations/clusters/agent_tokens/revoke.rb +++ b/app/graphql/mutations/clusters/agent_tokens/revoke.rb @@ -21,12 +21,6 @@ module Mutations { errors: errors_on_object(token) } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/clusters/agents/delete.rb b/app/graphql/mutations/clusters/agents/delete.rb index fb482e02794..ddb4e36a68e 100644 --- a/app/graphql/mutations/clusters/agents/delete.rb +++ b/app/graphql/mutations/clusters/agents/delete.rb @@ -24,12 +24,6 @@ module Mutations errors: Array.wrap(result.message) } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/concerns/mutations/finds_by_gid.rb b/app/graphql/mutations/concerns/mutations/finds_by_gid.rb deleted file mode 100644 index 157f87a413d..00000000000 --- a/app/graphql/mutations/concerns/mutations/finds_by_gid.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module FindsByGid - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - end -end diff --git a/app/graphql/mutations/container_repositories/destroy_base.rb b/app/graphql/mutations/container_repositories/destroy_base.rb index 1c2c4d87a5f..46851c15702 100644 --- a/app/graphql/mutations/container_repositories/destroy_base.rb +++ b/app/graphql/mutations/container_repositories/destroy_base.rb @@ -4,12 +4,6 @@ module Mutations module ContainerRepositories class DestroyBase < Mutations::BaseMutation include ::Mutations::PackageEventable - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/design_management/update.rb b/app/graphql/mutations/design_management/update.rb index 5dc20730a90..67732b70f29 100644 --- a/app/graphql/mutations/design_management/update.rb +++ b/app/graphql/mutations/design_management/update.rb @@ -28,12 +28,6 @@ module Mutations errors: errors_on_object(design) } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/discussions/toggle_resolve.rb b/app/graphql/mutations/discussions/toggle_resolve.rb index fce6e4f416f..dc5731add3a 100644 --- a/app/graphql/mutations/discussions/toggle_resolve.rb +++ b/app/graphql/mutations/discussions/toggle_resolve.rb @@ -53,10 +53,6 @@ module Mutations end end - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - def resolve!(discussion) ::Discussions::ResolveService.new( discussion.project, diff --git a/app/graphql/mutations/environments/canary_ingress/update.rb b/app/graphql/mutations/environments/canary_ingress/update.rb index 1cddfdd815b..43e9b6c0881 100644 --- a/app/graphql/mutations/environments/canary_ingress/update.rb +++ b/app/graphql/mutations/environments/canary_ingress/update.rb @@ -35,10 +35,6 @@ module Mutations { errors: Array.wrap(result[:message]) } end - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - private def certificate_based_clusters_enabled? diff --git a/app/graphql/mutations/metrics/dashboard/annotations/create.rb b/app/graphql/mutations/metrics/dashboard/annotations/create.rb index d458bdcf82b..225d313c487 100644 --- a/app/graphql/mutations/metrics/dashboard/annotations/create.rb +++ b/app/graphql/mutations/metrics/dashboard/annotations/create.rb @@ -83,10 +83,6 @@ module Mutations super(**args) end - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - def annotation_create_params(args) annotation_source = AnnotationSource.new(object: annotation_source(args)) diff --git a/app/graphql/mutations/notes/base.rb b/app/graphql/mutations/notes/base.rb index fb74805db17..d656835c335 100644 --- a/app/graphql/mutations/notes/base.rb +++ b/app/graphql/mutations/notes/base.rb @@ -13,12 +13,6 @@ module Mutations Types::Notes::NoteType, null: true, description: 'Note after mutation.' - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/notes/create/base.rb b/app/graphql/mutations/notes/create/base.rb index f48e62af767..69cd1426218 100644 --- a/app/graphql/mutations/notes/create/base.rb +++ b/app/graphql/mutations/notes/create/base.rb @@ -47,10 +47,6 @@ module Mutations private - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - def create_note_params(noteable, args) { noteable: noteable, diff --git a/app/graphql/mutations/packages/destroy.rb b/app/graphql/mutations/packages/destroy.rb index a398b1ff9dc..95832ec8b85 100644 --- a/app/graphql/mutations/packages/destroy.rb +++ b/app/graphql/mutations/packages/destroy.rb @@ -23,12 +23,6 @@ module Mutations errors: errors } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/packages/destroy_file.rb b/app/graphql/mutations/packages/destroy_file.rb index f2a8f2b853a..c7dd2df704e 100644 --- a/app/graphql/mutations/packages/destroy_file.rb +++ b/app/graphql/mutations/packages/destroy_file.rb @@ -21,12 +21,6 @@ module Mutations { errors: package_file.errors.full_messages } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/release_asset_links/delete.rb b/app/graphql/mutations/release_asset_links/delete.rb index 9a75b472411..891d8e5a4d8 100644 --- a/app/graphql/mutations/release_asset_links/delete.rb +++ b/app/graphql/mutations/release_asset_links/delete.rb @@ -19,7 +19,7 @@ module Mutations description: 'Deleted release asset link.' def resolve(id:) - link = authorized_find!(id) + link = authorized_find!(id: id) result = ::Releases::Links::DestroyService .new(link.release, current_user) @@ -31,10 +31,6 @@ module Mutations { link: nil, errors: result.message } end end - - def find_object(id) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/release_asset_links/update.rb b/app/graphql/mutations/release_asset_links/update.rb index 2e9054c290d..3df2d28b88c 100644 --- a/app/graphql/mutations/release_asset_links/update.rb +++ b/app/graphql/mutations/release_asset_links/update.rb @@ -44,7 +44,7 @@ module Mutations end def resolve(id:, **link_attrs) - link = authorized_find!(id) + link = authorized_find!(id: id) result = ::Releases::Links::UpdateService .new(link.release, current_user, link_attrs) @@ -56,10 +56,6 @@ module Mutations { link: nil, errors: result.message } end end - - def find_object(id) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/terraform/state/base.rb b/app/graphql/mutations/terraform/state/base.rb index 01f69934ea3..9a264836ef5 100644 --- a/app/graphql/mutations/terraform/state/base.rb +++ b/app/graphql/mutations/terraform/state/base.rb @@ -10,12 +10,6 @@ module Mutations Types::GlobalIDType[::Terraform::State], required: true, description: 'Global ID of the Terraform state.' - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/todos/base.rb b/app/graphql/mutations/todos/base.rb deleted file mode 100644 index 9a94c5d1e6d..00000000000 --- a/app/graphql/mutations/todos/base.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module Todos - class Base < ::Mutations::BaseMutation - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - end - end -end diff --git a/app/graphql/mutations/todos/create.rb b/app/graphql/mutations/todos/create.rb index 489d2f490ff..8a0906da724 100644 --- a/app/graphql/mutations/todos/create.rb +++ b/app/graphql/mutations/todos/create.rb @@ -2,7 +2,7 @@ module Mutations module Todos - class Create < ::Mutations::Todos::Base + class Create < ::Mutations::BaseMutation graphql_name 'TodoCreate' authorize :create_todo @@ -17,7 +17,7 @@ module Mutations description: 'To-do item created.' def resolve(target_id:) - target = authorized_find!(target_id) + target = authorized_find!(id: target_id) todo = TodoService.new.mark_todo(target, current_user)&.first errors = errors_on_object(todo) if todo @@ -27,12 +27,6 @@ module Mutations errors: errors } end - - private - - def find_object(id) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb index fe4023515a4..7f8d15e033a 100644 --- a/app/graphql/mutations/todos/mark_all_done.rb +++ b/app/graphql/mutations/todos/mark_all_done.rb @@ -2,7 +2,7 @@ module Mutations module Todos - class MarkAllDone < ::Mutations::Todos::Base + class MarkAllDone < ::Mutations::BaseMutation graphql_name 'TodosMarkAllDone' authorize :update_user diff --git a/app/graphql/mutations/todos/mark_done.rb b/app/graphql/mutations/todos/mark_done.rb index 4fecba55242..05d69fbc969 100644 --- a/app/graphql/mutations/todos/mark_done.rb +++ b/app/graphql/mutations/todos/mark_done.rb @@ -2,7 +2,7 @@ module Mutations module Todos - class MarkDone < ::Mutations::Todos::Base + class MarkDone < ::Mutations::BaseMutation graphql_name 'TodoMarkDone' authorize :update_todo diff --git a/app/graphql/mutations/todos/restore.rb b/app/graphql/mutations/todos/restore.rb index def24cb71bc..a169ec58a9a 100644 --- a/app/graphql/mutations/todos/restore.rb +++ b/app/graphql/mutations/todos/restore.rb @@ -2,7 +2,7 @@ module Mutations module Todos - class Restore < ::Mutations::Todos::Base + class Restore < ::Mutations::BaseMutation graphql_name 'TodoRestore' authorize :update_todo diff --git a/app/graphql/mutations/todos/restore_many.rb b/app/graphql/mutations/todos/restore_many.rb index f2f944860c2..106ba18b852 100644 --- a/app/graphql/mutations/todos/restore_many.rb +++ b/app/graphql/mutations/todos/restore_many.rb @@ -2,7 +2,7 @@ module Mutations module Todos - class RestoreMany < ::Mutations::Todos::Base + class RestoreMany < ::Mutations::BaseMutation graphql_name 'TodoRestoreMany' MAX_UPDATE_AMOUNT = 50 diff --git a/app/graphql/mutations/work_items/create_from_task.rb b/app/graphql/mutations/work_items/create_from_task.rb index 4ef8269a42f..23ae09b23fd 100644 --- a/app/graphql/mutations/work_items/create_from_task.rb +++ b/app/graphql/mutations/work_items/create_from_task.rb @@ -46,12 +46,6 @@ module Mutations response end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/work_items/delete.rb b/app/graphql/mutations/work_items/delete.rb index ec0244fa65e..bce59448412 100644 --- a/app/graphql/mutations/work_items/delete.rb +++ b/app/graphql/mutations/work_items/delete.rb @@ -29,12 +29,6 @@ module Mutations errors: result.errors } end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/work_items/delete_task.rb b/app/graphql/mutations/work_items/delete_task.rb index 47ab3748ab4..b13d7e2e3bf 100644 --- a/app/graphql/mutations/work_items/delete_task.rb +++ b/app/graphql/mutations/work_items/delete_task.rb @@ -53,11 +53,6 @@ module Mutations raise_resource_not_available_error! end end - - # method used by `authorized_find!(id: id)` - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/mutations/work_items/update.rb b/app/graphql/mutations/work_items/update.rb index 60b5536df56..3bcec7ebb1c 100644 --- a/app/graphql/mutations/work_items/update.rb +++ b/app/graphql/mutations/work_items/update.rb @@ -42,10 +42,6 @@ module Mutations private - def find_object(id:) - GitlabSchema.find_by_gid(id) - end - def interpret_quick_actions!(work_item, current_user, widget_params, attributes = {}) return unless work_item.work_item_type.widgets.include?(::WorkItems::Widgets::Description) diff --git a/app/graphql/resolvers/data_transfer/data_transfer_arguments.rb b/app/graphql/resolvers/data_transfer/data_transfer_arguments.rb new file mode 100644 index 00000000000..da75a78b2ac --- /dev/null +++ b/app/graphql/resolvers/data_transfer/data_transfer_arguments.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Resolvers + module DataTransfer + module DataTransferArguments + extend ActiveSupport::Concern + + included do + argument :from, Types::DateType, + description: + 'Retain egress data for one year. Data for the current month will increase dynamically as egress occurs.', + required: false + argument :to, Types::DateType, + description: 'End date for the data.', + required: false + end + end + end +end diff --git a/app/graphql/resolvers/data_transfer/group_data_transfer_resolver.rb b/app/graphql/resolvers/data_transfer/group_data_transfer_resolver.rb new file mode 100644 index 00000000000..83bb144017c --- /dev/null +++ b/app/graphql/resolvers/data_transfer/group_data_transfer_resolver.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Resolvers + module DataTransfer + class GroupDataTransferResolver < BaseResolver + include DataTransferArguments + include Gitlab::Graphql::Authorize::AuthorizeResource + + authorizes_object! + authorize :read_usage_quotas + + type Types::DataTransfer::GroupDataTransferType, null: false + + alias_method :group, :object + + def resolve(**args) + return { egress_nodes: [] } unless Feature.enabled?(:data_transfer_monitoring, group) + + results = if Feature.enabled?(:data_transfer_monitoring_mock_data, group) + ::DataTransfer::MockedTransferFinder.new.execute + else + ::DataTransfer::GroupDataTransferFinder.new( + group: group, + from: args[:from], + to: args[:to], + user: current_user + ).execute.map(&:attributes) + end + + { egress_nodes: results.to_a } + end + end + end +end diff --git a/app/graphql/resolvers/data_transfer/project_data_transfer_resolver.rb b/app/graphql/resolvers/data_transfer/project_data_transfer_resolver.rb new file mode 100644 index 00000000000..c3296f7d4c3 --- /dev/null +++ b/app/graphql/resolvers/data_transfer/project_data_transfer_resolver.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Resolvers + module DataTransfer + class ProjectDataTransferResolver < BaseResolver + include DataTransferArguments + include Gitlab::Graphql::Authorize::AuthorizeResource + + authorizes_object! + authorize :read_usage_quotas + + type Types::DataTransfer::ProjectDataTransferType, null: false + + alias_method :project, :object + + def resolve(**args) + return { egress_nodes: [] } unless Feature.enabled?(:data_transfer_monitoring, project.group) + + results = if Feature.enabled?(:data_transfer_monitoring_mock_data, project.group) + ::DataTransfer::MockedTransferFinder.new.execute + else + ::DataTransfer::ProjectDataTransferFinder.new( + project: project, + from: args[:from], + to: args[:to], + user: current_user + ).execute + end + + { egress_nodes: results } + end + end + end +end diff --git a/app/graphql/resolvers/data_transfer_resolver.rb b/app/graphql/resolvers/data_transfer_resolver.rb deleted file mode 100644 index ed97de0a256..00000000000 --- a/app/graphql/resolvers/data_transfer_resolver.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -module Resolvers - class DataTransferResolver < BaseResolver - argument :from, Types::DateType, - description: 'Retain egress data for 1 year. Current month will increase dynamically as egress occurs.', - required: false - argument :to, Types::DateType, - description: 'End date for the data.', - required: false - - type ::Types::DataTransfer::BaseType, null: false - - def self.source - raise NotImplementedError - end - - def self.project - Class.new(self) do - type Types::DataTransfer::ProjectDataTransferType, null: false - - def self.source - "Project" - end - end - end - - def self.group - Class.new(self) do - type Types::DataTransfer::GroupDataTransferType, null: false - - def self.source - "Group" - end - end - end - - def resolve(**_args) - return unless Feature.enabled?(:data_transfer_monitoring) - - # TODO: This is mock data as this feature is in development - # Follow this epic for recent progress: https://gitlab.com/groups/gitlab-org/-/epics/9330 - start_date = Date.new(2023, 0o1, 0o1) - date_for_index = ->(i) { (start_date + i.months).strftime('%Y-%m-%d') } - - nodes = 0.upto(11).map do |i| - { - date: date_for_index.call(i), - repository_egress: rand(70000..550000), - artifacts_egress: rand(70000..550000), - packages_egress: rand(70000..550000), - registry_egress: rand(70000..550000) - } - end - - { egress_nodes: nodes } - end - end -end diff --git a/app/graphql/resolvers/design_management/version_resolver.rb b/app/graphql/resolvers/design_management/version_resolver.rb index 7895981d67c..0d2479ded40 100644 --- a/app/graphql/resolvers/design_management/version_resolver.rb +++ b/app/graphql/resolvers/design_management/version_resolver.rb @@ -16,10 +16,6 @@ module Resolvers def resolve(id:) authorized_find!(id: id) end - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/resolvers/notes/synthetic_note_resolver.rb b/app/graphql/resolvers/notes/synthetic_note_resolver.rb index d4eafcd2c49..619f54d80b4 100644 --- a/app/graphql/resolvers/notes/synthetic_note_resolver.rb +++ b/app/graphql/resolvers/notes/synthetic_note_resolver.rb @@ -26,10 +26,6 @@ module Resolvers synthetic_notes.find { |note| note.discussion_id == sha } end - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end end diff --git a/app/graphql/resolvers/work_item_resolver.rb b/app/graphql/resolvers/work_item_resolver.rb index b174a0d2693..34e2f329efd 100644 --- a/app/graphql/resolvers/work_item_resolver.rb +++ b/app/graphql/resolvers/work_item_resolver.rb @@ -13,11 +13,5 @@ module Resolvers def resolve(id:) authorized_find!(id: id) end - - private - - def find_object(id:) - GitlabSchema.find_by_gid(id) - end end end diff --git a/app/graphql/types/data_transfer/base_type.rb b/app/graphql/types/data_transfer/base_type.rb index e077612bfd5..5031bd5c612 100644 --- a/app/graphql/types/data_transfer/base_type.rb +++ b/app/graphql/types/data_transfer/base_type.rb @@ -7,7 +7,7 @@ module Types field :egress_nodes, type: Types::DataTransfer::EgressNodeType.connection_type, description: 'Data nodes.', - null: true # disallow null once data_transfer_monitoring feature flag is rolled-out! + null: true # disallow null once data_transfer_monitoring feature flag is rolled-out! https://gitlab.com/gitlab-org/gitlab/-/issues/397693 end end end diff --git a/app/graphql/types/data_transfer/egress_node_type.rb b/app/graphql/types/data_transfer/egress_node_type.rb index a050540999f..f0ad3d15b53 100644 --- a/app/graphql/types/data_transfer/egress_node_type.rb +++ b/app/graphql/types/data_transfer/egress_node_type.rb @@ -26,12 +26,8 @@ module Types null: false field :registry_egress, GraphQL::Types::BigInt, - description: 'Registery egress for that project in that period of time.', + description: 'Registry egress for that project in that period of time.', null: false - - def total_egress - object.values.select { |x| x.is_a?(Integer) }.sum - end end end end diff --git a/app/graphql/types/data_transfer/project_data_transfer_type.rb b/app/graphql/types/data_transfer/project_data_transfer_type.rb index f385aa20a7e..36afa20194e 100644 --- a/app/graphql/types/data_transfer/project_data_transfer_type.rb +++ b/app/graphql/types/data_transfer/project_data_transfer_type.rb @@ -8,12 +8,14 @@ module Types field :total_egress, GraphQL::Types::BigInt, description: 'Total egress for that project in that period of time.', - null: true # disallow null once data_transfer_monitoring feature flag is rolled-out! + null: true, # disallow null once data_transfer_monitoring feature flag is rolled-out! https://gitlab.com/gitlab-org/gitlab/-/issues/397693 + extras: [:parent] - def total_egress(**_) - return unless Feature.enabled?(:data_transfer_monitoring) + def total_egress(parent:) + return unless Feature.enabled?(:data_transfer_monitoring, parent.group) + return 40_000_000 if Feature.enabled?(:data_transfer_monitoring_mock_data, parent.group) - 40_000_000 + object[:egress_nodes].sum('repository_egress + artifacts_egress + packages_egress + registry_egress') end end end diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index 3543ac29c17..d352d82a52e 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -241,7 +241,7 @@ module Types field :data_transfer, Types::DataTransfer::GroupDataTransferType, null: true, - resolver: Resolvers::DataTransferResolver.group, + resolver: Resolvers::DataTransfer::GroupDataTransferResolver, description: 'Data transfer data point for a specific period. This is mocked data under a development feature flag.' def label(title:) diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 4ca2bc8b1b5..a67ead051c2 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -567,8 +567,8 @@ module Types description: "Find runners visible to the current user." field :data_transfer, Types::DataTransfer::ProjectDataTransferType, - null: true, # disallow null once data_transfer_monitoring feature flag is rolled-out! - resolver: Resolvers::DataTransferResolver.project, + null: true, # disallow null once data_transfer_monitoring feature flag is rolled-out! https://gitlab.com/gitlab-org/gitlab/-/issues/391682 + resolver: Resolvers::DataTransfer::ProjectDataTransferResolver, description: 'Data transfer data point for a specific period. This is mocked data under a development feature flag.' field :visible_forks, Types::ProjectType.connection_type, diff --git a/app/helpers/abuse_reports_helper.rb b/app/helpers/abuse_reports_helper.rb new file mode 100644 index 00000000000..c18c78b26c7 --- /dev/null +++ b/app/helpers/abuse_reports_helper.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module AbuseReportsHelper + def valid_image_mimetypes + Gitlab::FileTypeDetection::SAFE_IMAGE_EXT + .map { |extension| "image/#{extension}" } + .to_sentence(last_word_connector: ' or ') + end +end diff --git a/app/helpers/admin/background_migrations_helper.rb b/app/helpers/admin/background_migrations_helper.rb index 79bb13810bb..cea9cd704c3 100644 --- a/app/helpers/admin/background_migrations_helper.rb +++ b/app/helpers/admin/background_migrations_helper.rb @@ -5,6 +5,7 @@ module Admin def batched_migration_status_badge_variant(migration) variants = { active: :info, + finalizing: :info, paused: :warning, failed: :danger, finished: :success diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb index 5ae5367ca5a..716738e87c9 100644 --- a/app/models/abuse_report.rb +++ b/app/models/abuse_report.rb @@ -3,8 +3,11 @@ class AbuseReport < ApplicationRecord include CacheMarkdownField include Sortable + include Gitlab::FileTypeDetection + include WithUploads MAX_CHAR_LIMIT_URL = 512 + MAX_FILE_SIZE = 1.megabyte cache_markdown_field :message, pipeline: :single_line @@ -42,6 +45,10 @@ class AbuseReport < ApplicationRecord before_validation :filter_empty_strings_from_links_to_spam validate :links_to_spam_contains_valid_urls + mount_uploader :screenshot, AttachmentUploader + validates :screenshot, file_size: { maximum: MAX_FILE_SIZE } + validate :validate_screenshot_is_image + scope :by_user_id, ->(id) { where(user_id: id) } scope :by_reporter_id, ->(id) { where(reporter_id: id) } scope :by_category, ->(category) { where(category: category) } @@ -84,6 +91,20 @@ class AbuseReport < ApplicationRecord AbuseReportMailer.notify(id).deliver_later end + def screenshot_path + return unless screenshot + return screenshot.url unless screenshot.upload + + asset_host = ActionController::Base.asset_host || Gitlab.config.gitlab.base_url + local_path = Gitlab::Routing.url_helpers.abuse_report_upload_path( + filename: screenshot.filename, + id: screenshot.upload.model_id, + model: 'abuse_report', + mounted_as: 'screenshot') + + Gitlab::Utils.append_path(asset_host, local_path) + end + private def filter_empty_strings_from_links_to_spam @@ -113,4 +134,24 @@ class AbuseReport < ApplicationRecord rescue ::Gitlab::UrlBlocker::BlockedUrlError errors.add(:links_to_spam, _('only supports valid HTTP(S) URLs')) end + + def filename + screenshot&.filename + end + + def valid_image_extensions + Gitlab::FileTypeDetection::SAFE_IMAGE_EXT + end + + def validate_screenshot_is_image + return if screenshot.blank? + return if image? + + errors.add( + :screenshot, + format( + _('must match one of the following file types: %{extension_list}'), + extension_list: valid_image_extensions.to_sentence(last_word_connector: ' or ')) + ) + end end diff --git a/app/models/pages_deployment.rb b/app/models/pages_deployment.rb index 125a86c68f6..fa29cbf8352 100644 --- a/app/models/pages_deployment.rb +++ b/app/models/pages_deployment.rb @@ -37,7 +37,7 @@ class PagesDeployment < ApplicationRecord end def store_after_commit? - Feature.enabled?(:pages_deploy_upload_file_outside_transaction) + Feature.enabled?(:pages_deploy_upload_file_outside_transaction, project) end strong_memoize_attr :store_after_commit? diff --git a/app/models/projects/data_transfer.rb b/app/models/projects/data_transfer.rb index faab0bb6db2..c7f5132fbc7 100644 --- a/app/models/projects/data_transfer.rb +++ b/app/models/projects/data_transfer.rb @@ -13,6 +13,14 @@ module Projects belongs_to :namespace scope :current_month, -> { where(date: beginning_of_month) } + scope :with_project_between_dates, ->(project, from, to) { + where(project: project, date: from..to) + } + scope :with_namespace_between_dates, ->(namespace, from, to) { + where(namespace: namespace, date: from..to) + .group(:date, :namespace_id) + .order(date: :desc) + } counter_attribute :repository_egress, returns_current: true counter_attribute :artifacts_egress, returns_current: true diff --git a/app/views/abuse_reports/new.html.haml b/app/views/abuse_reports/new.html.haml index 8b9bbfd0a59..39b8fe26c7b 100644 --- a/app/views/abuse_reports/new.html.haml +++ b/app/views/abuse_reports/new.html.haml @@ -26,6 +26,17 @@ = f.label :reported_from = f.text_field :reported_from_url, class: "form-control", readonly: true #js-links-to-spam{ data: { links: Array(@abuse_report.links_to_spam) } } + + .form-group.row + .col-lg-8 + = f.label :screenshot do + %span + = s_('ReportAbuse|Screenshot') + .gl-font-weight-normal + = s_('ReportAbuse|Screenshot of abuse') + %div + = render 'shared/file_picker_button', f: f, field: :screenshot, help_text: _("Screenshot must be less than 1 MB."), mime_types: valid_image_mimetypes + .form-group.row .col-lg-8 = f.label :reason diff --git a/app/views/admin/background_migrations/index.html.haml b/app/views/admin/background_migrations/index.html.haml index 00859bf6b66..9550ea2884e 100644 --- a/app/views/admin/background_migrations/index.html.haml +++ b/app/views/admin/background_migrations/index.html.haml @@ -17,6 +17,9 @@ = gl_tab_link_to admin_background_migrations_path({ tab: nil, database: params[:database] }), item_active: @current_tab == 'queued' do = _('Queued') = gl_tab_counter_badge limited_counter_with_delimiter(@relations_by_tab['queued']) + = gl_tab_link_to admin_background_migrations_path({ tab: 'finalizing', database: params[:database] }), item_active: @current_tab == 'finalizing' do + = _('Finalizing') + = gl_tab_counter_badge limited_counter_with_delimiter(@relations_by_tab['finalizing']) = gl_tab_link_to admin_background_migrations_path({ tab: 'failed', database: params[:database] }), item_active: @current_tab == 'failed' do = _('Failed') = gl_tab_counter_badge limited_counter_with_delimiter(@relations_by_tab['failed']) diff --git a/app/views/shared/_file_picker_button.html.haml b/app/views/shared/_file_picker_button.html.haml index 8d76e9c1b7d..beb564f7c7c 100644 --- a/app/views/shared/_file_picker_button.html.haml +++ b/app/views/shared/_file_picker_button.html.haml @@ -1,9 +1,10 @@ - classes = local_assigns.fetch(:classes, '') +- mime_types = local_assigns.fetch(:mime_types, '') %span.js-filepicker = render Pajamas::ButtonComponent.new(button_options: { class: "js-filepicker-button #{classes}" }) do = _("Choose fileā¦") - %span.file_name.js-filepicker-filename= _("No file chosen.") - = f.file_field field, class: "js-filepicker-input hidden" + %span.file_name.gl-ml-3.js-filepicker-filename= _("No file chosen.") + = f.file_field field, class: "js-filepicker-input hidden", accept: mime_types - if help_text.present? .form-text.text-muted= help_text diff --git a/app/views/shared/hook_logs/_index.html.haml b/app/views/shared/hook_logs/_index.html.haml index 6a46b0b3510..7dab14b95c1 100644 --- a/app/views/shared/hook_logs/_index.html.haml +++ b/app/views/shared/hook_logs/_index.html.haml @@ -1,4 +1,4 @@ -- docs_link_url = help_page_path('user/project/integrations/webhooks', anchor: 'troubleshoot-webhooks') +- docs_link_url = help_page_path('user/project/integrations/webhooks', anchor: 'troubleshooting') - link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: docs_link_url } - link_end = '</a>'.html_safe diff --git a/app/views/shared/web_hooks/_web_hook_disabled_alert.html.haml b/app/views/shared/web_hooks/_web_hook_disabled_alert.html.haml index d9155b397b8..f8e2dc3d8dd 100644 --- a/app/views/shared/web_hooks/_web_hook_disabled_alert.html.haml +++ b/app/views/shared/web_hooks/_web_hook_disabled_alert.html.haml @@ -8,6 +8,6 @@ = c.body do = s_('Webhooks|A webhook in this project was automatically disabled after being retried multiple times.') = succeed '.' do - = link_to _('Learn more'), help_page_path('user/project/integrations/webhooks', anchor: 'troubleshoot-webhooks'), target: '_blank', rel: 'noopener noreferrer' + = link_to _('Learn more'), help_page_path('user/project/integrations/webhooks', anchor: 'troubleshooting'), target: '_blank', rel: 'noopener noreferrer' = c.actions do = link_to s_('Webhooks|Go to webhooks'), project_hooks_path(@project, anchor: 'webhooks-index'), class: 'btn gl-alert-action btn-confirm gl-button' |