diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 12:08:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 12:08:53 +0000 |
commit | 8a5138ed7d38ccff8b5ca2fe0f7bbb77f8fdaad3 (patch) | |
tree | 4c0d373c990fc01cacff9b4093366ab398fcb7d3 /app | |
parent | 6d8f30ab0ae82678f10450d2158f24772f0c765c (diff) | |
download | gitlab-ce-8a5138ed7d38ccff8b5ca2fe0f7bbb77f8fdaad3.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
16 files changed, 88 insertions, 138 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_file_header.vue b/app/assets/javascripts/diffs/components/diff_file_header.vue index 0f1c13f818f..c3a4897ce78 100644 --- a/app/assets/javascripts/diffs/components/diff_file_header.vue +++ b/app/assets/javascripts/diffs/components/diff_file_header.vue @@ -376,7 +376,7 @@ export default { v-if="isReviewable && showLocalFileReviews" v-gl-tooltip.hover data-testid="fileReviewCheckbox" - class="gl-mr-5 gl-display-flex gl-align-items-center" + class="gl-mr-5 gl-mb-n3 gl-display-flex gl-align-items-center" :title="$options.i18n.fileReviewTooltip" :checked="reviewed" @change="toggleReview" diff --git a/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_area_chart.vue b/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_area_chart.vue index c89e843b660..b4751d51fcb 100644 --- a/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_area_chart.vue +++ b/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_area_chart.vue @@ -1,4 +1,5 @@ <script> +import { v4 as uuidv4 } from 'uuid'; import { GlAreaChart } from '@gitlab/ui/dist/charts'; import { CHART_CONTAINER_HEIGHT } from './constants'; @@ -17,6 +18,15 @@ export default { required: true, }, }, + data: () => ({ + chartKey: uuidv4(), + }), + watch: { + chartData() { + // Re-render area chart when the data changes + this.chartKey = uuidv4(); + }, + }, chartContainerHeight: CHART_CONTAINER_HEIGHT, }; </script> @@ -27,6 +37,7 @@ export default { </p> <gl-area-chart v-bind="$attrs" + :key="chartKey" responsive width="auto" :height="$options.chartContainerHeight" diff --git a/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_charts.vue b/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_charts.vue index 47b96934420..e5d82bad54f 100644 --- a/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_charts.vue +++ b/app/assets/javascripts/vue_shared/components/ci_cd_analytics/ci_cd_analytics_charts.vue @@ -39,11 +39,10 @@ export default { </script> <template> <div> - <segmented-control-button-group - v-model="selectedChart" - :options="chartRanges" - class="gl-mb-4" - /> + <div class="gl-display-flex gl-flex-wrap-wrap gl-gap-5"> + <segmented-control-button-group v-model="selectedChart" :options="chartRanges" /> + <slot name="extend-button-group"></slot> + </div> <ci-cd-analytics-area-chart v-if="chart" v-bind="$attrs" diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index 8f482cf6e2f..bc6e67a3a7d 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -169,18 +169,6 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController gon.push(webauthn: { options: options, app_id: u2f_app_id }) end - # Adds delete path to u2f registrations - # to reduce logic in view template - def u2f_registrations - current_user.u2f_registrations.map do |u2f_registration| - { - name: u2f_registration.name, - created_at: u2f_registration.created_at, - delete_path: profile_u2f_registration_path(u2f_registration) - } - end - end - def webauthn_registrations current_user.webauthn_registrations.map do |webauthn_registration| { @@ -235,10 +223,6 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController @qr_code = build_qr_code @account_string = account_string - if Feature.enabled?(:webauthn) - setup_webauthn_registration - else - setup_u2f_registration - end + setup_webauthn_registration end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 44c8c8f8f44..da15b393e6c 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -10,9 +10,6 @@ class ProfilesController < Profiles::ApplicationController check_rate_limit!(:profile_update_username, scope: current_user) end skip_before_action :require_email, only: [:show, :update] - before_action do - push_frontend_feature_flag(:webauthn) - end feature_category :user_profile, [:show, :update, :reset_incoming_email_token, :reset_feed_token, :reset_static_object_token, :update_username] diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index bd5701a3557..cc0d3818e33 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -20,28 +20,14 @@ class Projects::BlameController < Projects::ApplicationController end load_environment - - @blame_mode = Gitlab::Git::BlameMode.new(@commit.project, blame_params) - blame_service = Projects::BlameService.new(@blob, @commit, @blame_mode, blame_params) - - @blame = Gitlab::View::Presenter::Factory.new(blame_service.blame, project: @project, path: @path, page: blame_service.page).fabricate! - - @blame_pagination = blame_service.pagination - - @blame_per_page = blame_service.per_page - - render locals: { total_extra_pages: blame_service.total_extra_pages } + load_blame end def page @blob = @repository.blob_at(@commit.id, @path) load_environment - - @blame_mode = Gitlab::Git::BlameMode.new(@commit.project, blame_params) - blame_service = Projects::BlameService.new(@blob, @commit, @blame_mode, blame_params) - - @blame = Gitlab::View::Presenter::Factory.new(blame_service.blame, project: @project, path: @path, page: blame_service.page).fabricate! + load_blame render partial: 'page' end @@ -54,6 +40,14 @@ class Projects::BlameController < Projects::ApplicationController @environment = ::Environments::EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last end + def load_blame + @blame_mode = Gitlab::Git::BlameMode.new(@commit.project, blame_params) + @blame_pagination = Gitlab::Git::BlamePagination.new(@blob, @blame_mode, blame_params) + + blame = Gitlab::Blame.new(@blob, @commit, range: @blame_pagination.blame_range) + @blame = Gitlab::View::Presenter::Factory.new(blame, project: @project, path: @path, page: @blame_pagination.page).fabricate! + end + def blame_params params.permit(:page, :no_pagination, :streaming) end diff --git a/app/models/clusters/agents/authorizations/user_access/group_authorization.rb b/app/models/clusters/agents/authorizations/user_access/group_authorization.rb new file mode 100644 index 00000000000..088ce1c0e27 --- /dev/null +++ b/app/models/clusters/agents/authorizations/user_access/group_authorization.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Clusters + module Agents + module Authorizations + module UserAccess + class GroupAuthorization < ApplicationRecord + self.table_name = 'agent_user_access_group_authorizations' + + belongs_to :agent, class_name: 'Clusters::Agent', optional: false + belongs_to :group, class_name: '::Group', optional: false + + validates :config, json_schema: { filename: 'clusters_agents_authorizations_user_access_config' } + + def config_project + agent.project + end + end + end + end + end +end diff --git a/app/models/clusters/agents/authorizations/user_access/project_authorization.rb b/app/models/clusters/agents/authorizations/user_access/project_authorization.rb new file mode 100644 index 00000000000..22b2c3fea22 --- /dev/null +++ b/app/models/clusters/agents/authorizations/user_access/project_authorization.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Clusters + module Agents + module Authorizations + module UserAccess + class ProjectAuthorization < ApplicationRecord + self.table_name = 'agent_user_access_project_authorizations' + + belongs_to :agent, class_name: 'Clusters::Agent', optional: false + belongs_to :project, class_name: '::Project', optional: false + + validates :config, json_schema: { filename: 'clusters_agents_authorizations_user_access_config' } + + def config_project + agent.project + end + end + end + end + end +end diff --git a/app/models/members_preloader.rb b/app/models/members_preloader.rb index f6617fa0888..1fef155e6ea 100644 --- a/app/models/members_preloader.rb +++ b/app/models/members_preloader.rb @@ -8,15 +8,12 @@ class MembersPreloader end def preload_all - user_associations = [:status] - user_associations << :webauthn_registrations if Feature.enabled?(:webauthn) - ActiveRecord::Associations::Preloader.new( records: members, associations: [ :source, :created_by, - { user: user_associations } + { user: [:status, :webauthn_registrations] } ] ).call end diff --git a/app/models/user.rb b/app/models/user.rb index 738e1eba982..16b4e604a9e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1087,8 +1087,6 @@ class User < ApplicationRecord end def two_factor_webauthn_enabled? - return false unless Feature.enabled?(:webauthn) - (webauthn_registrations.loaded? && webauthn_registrations.any?) || (!webauthn_registrations.loaded? && webauthn_registrations.exists?) end diff --git a/app/services/projects/blame_service.rb b/app/services/projects/blame_service.rb deleted file mode 100644 index d4c01044828..00000000000 --- a/app/services/projects/blame_service.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true - -# Service class to correctly initialize Gitlab::Blame and Kaminari pagination -# objects -module Projects - class BlameService - PER_PAGE = 1000 - STREAMING_FIRST_PAGE_SIZE = 200 - STREAMING_PER_PAGE = 2000 - - def initialize(blob, commit, blame_mode, params) - @blob = blob - @commit = commit - @blame_mode = blame_mode - @page = extract_page(params) - @params = params - end - - attr_reader :page - - def blame - Gitlab::Blame.new(blob, commit, range: blame_range) - end - - def pagination - return unless blame_mode.pagination? - - Kaminari.paginate_array([], total_count: blob_lines_count, limit: per_page) - .tap { |pagination| pagination.max_paginates_per(per_page) } - .page(page) - end - - def per_page - blame_mode.streaming? ? STREAMING_PER_PAGE : PER_PAGE - end - - def total_pages - total = (blob_lines_count.to_f / per_page).ceil - return total unless blame_mode.streaming? - - ([blob_lines_count - STREAMING_FIRST_PAGE_SIZE, 0].max.to_f / per_page).ceil + 1 - end - - def total_extra_pages - [total_pages - 1, 0].max - end - - private - - attr_reader :blob, :commit, :blame_mode - - def blame_range - return if blame_mode.full? - - first_line = (page - 1) * per_page + 1 - - if blame_mode.streaming? - return 1..STREAMING_FIRST_PAGE_SIZE if page == 1 - - first_line = STREAMING_FIRST_PAGE_SIZE + (page - 2) * per_page + 1 - end - - last_line = (first_line + per_page).to_i - 1 - - first_line..last_line - end - - def extract_page(params) - page = params.fetch(:page, 1).to_i - - return 1 if page < 1 || overlimit?(page) - - page - end - - def overlimit?(page) - page > total_pages - end - - def blob_lines_count - @blob_lines_count ||= blob.data.lines.count - end - end -end diff --git a/app/services/users/approve_service.rb b/app/services/users/approve_service.rb index 353456c545d..53ec37d0ff7 100644 --- a/app/services/users/approve_service.rb +++ b/app/services/users/approve_service.rb @@ -17,6 +17,11 @@ module Users user.accept_pending_invitations! if user.active_for_authentication? DeviseMailer.user_admin_approval(user).deliver_later + if user.created_by_id + reset_token = user.generate_reset_token + NotificationService.new.new_user(user, reset_token) + end + log_event(user) after_approve_hook(user) success(message: 'Success', http_status: :created) diff --git a/app/validators/json_schemas/clusters_agents_authorizations_user_access_config.json b/app/validators/json_schemas/clusters_agents_authorizations_user_access_config.json new file mode 100644 index 00000000000..75624af9e6a --- /dev/null +++ b/app/validators/json_schemas/clusters_agents_authorizations_user_access_config.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Cluster Agent configuration for an authorized project or group through user_access keyword", + "type": "object", + "additionalProperties": true +} diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml index 5e62d6c5421..161e7aef253 100644 --- a/app/views/projects/_files.html.haml +++ b/app/views/projects/_files.html.haml @@ -6,7 +6,7 @@ - if readme_path = @project.repository.readme_path - add_page_startup_api_call project_blob_path(@project, tree_join(@ref, readme_path), viewer: "rich", format: "json") -#tree-holder.tree-holder.clearfix.js-per-page{ data: { blame_per_page: Projects::BlameService::PER_PAGE } } +#tree-holder.tree-holder.clearfix.js-per-page{ data: { blame_per_page: Gitlab::Git::BlamePagination::PAGINATION_PER_PAGE } } .info-well.gl-display-none.gl-sm-display-flex.project-last-commit.gl-flex-direction-column.gl-mt-5 #js-last-commit.gl-m-auto = gl_loading_icon(size: 'md') diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index 689dcb3b2cb..a56d398d3a0 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -2,7 +2,7 @@ - add_page_specific_style 'page_bundles/tree' - blame_streaming_url = blame_pages_streaming_url(@id, @project) -- if @blame_mode.streaming? && total_extra_pages > 0 +- if @blame_mode.streaming? && @blame_pagination.total_extra_pages > 0 - content_for :startup_js do = javascript_tag do :plain @@ -11,7 +11,7 @@ url.searchParams.set('page', 2); return fetch(url).then(response => response.body); })(); -- dataset = { testid: 'blob-content-holder', qa_selector: 'blame_file_content', per_page: @blame_per_page, total_extra_pages: total_extra_pages - 1, pages_url: blame_streaming_url } +- dataset = { testid: 'blob-content-holder', qa_selector: 'blame_file_content', per_page: @blame_pagination.per_page, total_extra_pages: @blame_pagination.total_extra_pages - 1, pages_url: blame_streaming_url } #blob-content-holder.tree-holder.js-per-page{ data: dataset } = render "projects/blob/breadcrumb", blob: @blob, blame: true @@ -53,5 +53,4 @@ = _('Loading full blame...') - if @blame_mode.pagination? - = paginate(@blame_pagination, theme: "gitlab") - + = paginate(@blame_pagination.paginator, theme: "gitlab") diff --git a/app/views/projects/blob/_blob.html.haml b/app/views/projects/blob/_blob.html.haml index d11bf36a610..1a751849b3a 100644 --- a/app/views/projects/blob/_blob.html.haml +++ b/app/views/projects/blob/_blob.html.haml @@ -16,7 +16,7 @@ - if project.forked? #js-fork-info{ data: vue_fork_divergence_data(project, ref) } -#blob-content-holder.blob-content-holder.js-per-page{ data: { blame_per_page: Projects::BlameService::PER_PAGE } } +#blob-content-holder.blob-content-holder.js-per-page{ data: { blame_per_page: Gitlab::Git::BlamePagination::PAGINATION_PER_PAGE } } - if @code_navigation_path #js-code-navigation{ data: { code_navigation_path: @code_navigation_path, blob_path: blob.path, definition_path_prefix: project_blob_path(@project, @ref) } } - if !expanded |