diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-17 18:09:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-17 18:09:22 +0300 |
commit | 99f4b14cb0546a905d8f14f938d679d17e569005 (patch) | |
tree | d0520a58f46c8b5ceb018ca4d404e9a682f4af3c /app | |
parent | 4f8983ade80c0d71d4c8e6cc0d686c9cecf5e7d4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
56 files changed, 395 insertions, 234 deletions
diff --git a/app/assets/javascripts/boards/components/board_list.vue b/app/assets/javascripts/boards/components/board_list.vue index 6f2b35f5191..3ea569a6c13 100644 --- a/app/assets/javascripts/boards/components/board_list.vue +++ b/app/assets/javascripts/boards/components/board_list.vue @@ -260,6 +260,10 @@ export default { this.showIssueForm = !this.showIssueForm; } }, + isObservableItem(index) { + // observe every 6 item of 10 to achieve smooth loading state + return index !== 0 && index % 6 === 0; + }, onReachingListBottom() { if (!this.loadingMore && this.hasNextPage) { this.showCount = true; @@ -393,8 +397,14 @@ export default { :list="list" :list-items-length="boardListItems.length" /> + <gl-intersection-observer + v-if="isObservableItem(index)" + data-testid="board-card-gl-io" + @appear="onReachingListBottom" + /> </board-card> - <gl-intersection-observer @appear="onReachingListBottom"> + <div> + <!-- for supporting previous structure with intersection observer --> <li v-if="showCount" class="board-list-count gl-text-center gl-text-secondary gl-py-4" @@ -409,7 +419,7 @@ export default { <span v-if="showingAllItems">{{ showingAllItemsText }}</span> <span v-else>{{ paginatedIssueText }}</span> </li> - </gl-intersection-observer> + </div> </component> </div> </template> diff --git a/app/assets/javascripts/super_sidebar/components/context_switcher.vue b/app/assets/javascripts/super_sidebar/components/context_switcher.vue index f1ddb8290a0..19cc9c50b05 100644 --- a/app/assets/javascripts/super_sidebar/components/context_switcher.vue +++ b/app/assets/javascripts/super_sidebar/components/context_switcher.vue @@ -54,7 +54,7 @@ export default { :item="project" > <template #icon> - <gl-avatar shape="rect" :size="32" :src="project.avatar" /> + <gl-avatar shape="rect" :size="24" :src="project.avatar" /> </template> </nav-item> <nav-item :item="$options.viewAllProjectsItem" /> @@ -71,7 +71,7 @@ export default { :item="project" > <template #icon> - <gl-avatar shape="rect" :size="32" :src="project.avatar" /> + <gl-avatar shape="rect" :size="24" :src="project.avatar" /> </template> </nav-item> <nav-item :item="$options.viewAllGroupsItem" /> diff --git a/app/assets/javascripts/super_sidebar/components/context_switcher_toggle.vue b/app/assets/javascripts/super_sidebar/components/context_switcher_toggle.vue index b6f058f7aee..7a2cc47d3a7 100644 --- a/app/assets/javascripts/super_sidebar/components/context_switcher_toggle.vue +++ b/app/assets/javascripts/super_sidebar/components/context_switcher_toggle.vue @@ -32,13 +32,27 @@ export default { <button v-collapse-toggle.context-switcher type="button" - class="context-switcher-toggle gl-bg-transparent gl-border-0 border-top border-bottom gl-border-gray-a-08 gl-box-shadow-none gl-display-flex gl-align-items-center gl-font-weight-bold gl-w-full gl-pl-3 gl-pr-5 gl-h-8" + class="context-switcher-toggle gl-p-0 gl-bg-transparent gl-hover-bg-t-gray-a-08 gl-border-0 border-top border-bottom gl-border-gray-a-08 gl-box-shadow-none gl-display-flex gl-align-items-center gl-font-weight-bold gl-w-full gl-h-8" > - <gl-avatar :size="32" shape="rect" :src="context.avatar" class="gl-mr-3" /> + <span + v-if="context.icon" + class="gl-avatar avatar-container gl-bg-t-gray-a-08 icon-avatar rect-avatar s24 gl-mr-3 gl-ml-4" + > + <gl-icon :name="context.icon" :size="16" /> + </span> + <gl-avatar + v-else + :size="24" + shape="rect" + :entity-name="context.title" + :entity-id="context.id" + :src="context.avatar" + class="gl-mr-3 gl-ml-4" + /> <div class="gl-overflow-auto"> <gl-truncate :text="context.title" /> </div> - <span class="gl-flex-grow-1 gl-text-right"> + <span class="gl-flex-grow-1 gl-text-right gl-mr-4"> <gl-icon :name="collapseIcon" /> </span> </button> diff --git a/app/assets/javascripts/super_sidebar/components/nav_item.vue b/app/assets/javascripts/super_sidebar/components/nav_item.vue index 4fd6918fd6f..100f1d18793 100644 --- a/app/assets/javascripts/super_sidebar/components/nav_item.vue +++ b/app/assets/javascripts/super_sidebar/components/nav_item.vue @@ -1,9 +1,10 @@ <script> -import { GlIcon } from '@gitlab/ui'; +import { GlCollapse, GlIcon } from '@gitlab/ui'; export default { name: 'NavItem', components: { + GlCollapse, GlIcon, }, props: { @@ -12,18 +13,69 @@ export default { required: true, }, }, + data() { + return { + expanded: this.item.is_active, + }; + }, + computed: { + collapseIcon() { + return this.expanded ? 'chevron-up' : 'chevron-down'; + }, + isSection() { + return Boolean(this.item?.items?.length); + }, + isActive() { + if (this.isSection) { + return !this.expanded && this.item.is_active; + } + return this.item.is_active; + }, + linkProps() { + if (this.isSection) { + return { + href: '#', + 'aria-hidden': true, + }; + } + return { + href: this.item.link, + }; + }, + linkClasses() { + return { + 'gl-bg-t-gray-a-08': this.isActive, + }; + }, + }, + methods: { + click(event) { + if (this.isSection) { + event.preventDefault(); + this.expanded = !this.expanded; + } + }, + }, }; </script> <template> <li> <a - :href="item.link" - class="gl-display-flex gl-pl-3 gl-py-3 gl-line-height-normal gl-text-black-normal gl-hover-bg-t-gray-a-08" + v-bind="linkProps" + class="gl-rounded-base gl-relative gl-display-flex gl-py-3 gl-px-0 gl-line-height-normal gl-text-black-normal! gl-hover-bg-t-gray-a-08 gl-text-decoration-none!" + :class="linkClasses" + @click="click" > - <div class="gl-mr-3"> + <div + :class="[isActive ? 'gl-bg-blue-500' : 'gl-bg-transparent']" + class="gl-absolute gl-left-2 gl-top-2 gl-bottom-2 gl-transition-slow" + aria-hidden="true" + style="width: 3px; border-radius: 3px; margin-right: 1px" + ></div> + <div class="gl-flex-shrink-0 gl-w-6 gl-mx-3"> <slot name="icon"> - <gl-icon v-if="item.icon" :name="item.icon" /> + <gl-icon v-if="item.icon" :name="item.icon" class="gl-ml-2" /> </slot> </div> <div class="gl-pr-3"> @@ -32,6 +84,18 @@ export default { {{ item.subtitle }} </div> </div> + <span v-if="isSection" class="gl-flex-grow-1 gl-text-right gl-mr-3"> + <gl-icon :name="collapseIcon" /> + </span> </a> + <gl-collapse v-if="isSection" :id="item.title" v-model="expanded"> + <ul class="gl-p-0"> + <nav-item + v-for="subItem of item.items" + :key="`${item.title}-${subItem.title}`" + :item="subItem" + /> + </ul> + </gl-collapse> </li> </template> diff --git a/app/assets/javascripts/super_sidebar/components/sidebar_menu.vue b/app/assets/javascripts/super_sidebar/components/sidebar_menu.vue new file mode 100644 index 00000000000..fc8968c50ea --- /dev/null +++ b/app/assets/javascripts/super_sidebar/components/sidebar_menu.vue @@ -0,0 +1,24 @@ +<script> +import NavItem from './nav_item.vue'; + +export default { + name: 'SidebarMenu', + components: { + NavItem, + }, + props: { + items: { + type: Array, + required: true, + }, + }, +}; +</script> + +<template> + <nav class="gl-py-2 gl-relative"> + <ul class="gl-px-2 gl-list-style-none"> + <nav-item v-for="item in items" :key="`menu-${item.title}`" :item="item" /> + </ul> + </nav> +</template> diff --git a/app/assets/javascripts/super_sidebar/components/super_sidebar.vue b/app/assets/javascripts/super_sidebar/components/super_sidebar.vue index c4b769dcf24..cff68258a35 100644 --- a/app/assets/javascripts/super_sidebar/components/super_sidebar.vue +++ b/app/assets/javascripts/super_sidebar/components/super_sidebar.vue @@ -1,19 +1,19 @@ <script> import { GlCollapse } from '@gitlab/ui'; -import { context } from '../mock_data'; import UserBar from './user_bar.vue'; import ContextSwitcherToggle from './context_switcher_toggle.vue'; import ContextSwitcher from './context_switcher.vue'; import HelpCenter from './help_center.vue'; +import SidebarMenu from './sidebar_menu.vue'; export default { - context, components: { GlCollapse, UserBar, ContextSwitcherToggle, ContextSwitcher, HelpCenter, + SidebarMenu, }, props: { sidebarData: { @@ -26,6 +26,11 @@ export default { contextSwitcherOpened: false, }; }, + computed: { + menuItems() { + return this.sidebarData.current_menu_items || []; + }, + }, }; </script> @@ -38,10 +43,16 @@ export default { <user-bar :sidebar-data="sidebarData" /> <div class="gl-display-flex gl-flex-direction-column gl-flex-grow-1 gl-overflow-hidden"> <div class="gl-flex-grow-1 gl-overflow-auto"> - <context-switcher-toggle :context="$options.context" :expanded="contextSwitcherOpened" /> + <context-switcher-toggle + :context="sidebarData.current_context_header" + :expanded="contextSwitcherOpened" + /> <gl-collapse id="context-switcher" v-model="contextSwitcherOpened"> <context-switcher /> </gl-collapse> + <gl-collapse :visible="!contextSwitcherOpened"> + <sidebar-menu :items="menuItems" /> + </gl-collapse> </div> <div class="gl-p-3"> <help-center :sidebar-data="sidebarData" /> diff --git a/app/assets/javascripts/super_sidebar/mock_data.js b/app/assets/javascripts/super_sidebar/mock_data.js index 0d1ac006df7..8b35b5b7d45 100644 --- a/app/assets/javascripts/super_sidebar/mock_data.js +++ b/app/assets/javascripts/super_sidebar/mock_data.js @@ -1,11 +1,5 @@ import { s__ } from '~/locale'; -export const context = { - title: 'Typeahead.js', - link: '/', - avatar: 'https://gitlab.com/uploads/-/system/project/avatar/278964/project_avatar.png?width=32', -}; - export const contextSwitcherItems = { yourWork: { title: s__('Navigation|Your work'), link: '/', icon: 'work' }, recentProjects: [ diff --git a/app/assets/stylesheets/utilities.scss b/app/assets/stylesheets/utilities.scss index af98d59251f..ab088436335 100644 --- a/app/assets/stylesheets/utilities.scss +++ b/app/assets/stylesheets/utilities.scss @@ -257,6 +257,10 @@ to @gitlab/ui by https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1709 gap: $gl-spacing-scale-2; } +.gl-bg-t-gray-a-08 { + background-color: $t-gray-a-08; +} + .gl-hover-bg-t-gray-a-08:hover { background-color: $t-gray-a-08; } diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index ade58ca0970..66b14657134 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -101,8 +101,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController def reset_error_tracking_access_token @application_setting.reset_error_tracking_access_token! - redirect_to general_admin_application_settings_path, - notice: _('New error tracking access token has been generated!') + redirect_to general_admin_application_settings_path, notice: _('New error tracking access token has been generated!') end def clear_repository_check_states diff --git a/app/controllers/admin/ci/variables_controller.rb b/app/controllers/admin/ci/variables_controller.rb index ef50d7362c4..1d9a6bdbc31 100644 --- a/app/controllers/admin/ci/variables_controller.rb +++ b/app/controllers/admin/ci/variables_controller.rb @@ -32,10 +32,7 @@ module Admin end def render_instance_variables - render status: :ok, - json: { - variables: ::Ci::InstanceVariableSerializer.new.represent(variables) - } + render status: :ok, json: { variables: ::Ci::InstanceVariableSerializer.new.represent(variables) } end def render_error(errors) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index e3a33bafb62..ef45eaac437 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -65,8 +65,8 @@ class Admin::GroupsController < Admin::ApplicationController Groups::DestroyService.new(@group, current_user).async_execute redirect_to admin_groups_path, - status: :found, - alert: format(_('Group %{group_name} was scheduled for deletion.'), group_name: @group.name) + status: :found, + alert: format(_('Group %{group_name} was scheduled for deletion.'), group_name: @group.name) end private diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb index 984ae736697..478708f3d9b 100644 --- a/app/controllers/admin/spam_logs_controller.rb +++ b/app/controllers/admin/spam_logs_controller.rb @@ -15,8 +15,8 @@ class Admin::SpamLogsController < Admin::ApplicationController if params[:remove_user] spam_log.remove_user(deleted_by: current_user) redirect_to admin_spam_logs_path, - status: :found, - notice: format(_('User %{username} was successfully removed.'), username: spam_log.user.username) + status: :found, + notice: format(_('User %{username} was successfully removed.'), username: spam_log.user.username) else spam_log.destroy head :ok diff --git a/app/controllers/admin/topics_controller.rb b/app/controllers/admin/topics_controller.rb index 345a778772d..94d084932ad 100644 --- a/app/controllers/admin/topics_controller.rb +++ b/app/controllers/admin/topics_controller.rb @@ -41,8 +41,8 @@ class Admin::TopicsController < Admin::ApplicationController @topic.destroy! redirect_to admin_topics_path, - status: :found, - notice: format(_('Topic %{topic_name} was successfully removed.'), topic_name: @topic.title_or_name) + status: :found, + notice: format(_('Topic %{topic_name} was successfully removed.'), topic_name: @topic.title_or_name) end def merge diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 353f9098b95..5bca5a91ac5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -260,10 +260,7 @@ class ApplicationController < ActionController::Base respond_to do |format| format.html do - render template, - layout: "errors", - status: status, - locals: { message: message } + render template, layout: "errors", status: status, locals: { message: message } end format.any { head status } end diff --git a/app/controllers/chaos_controller.rb b/app/controllers/chaos_controller.rb index 6139168d29f..7328b793b09 100644 --- a/app/controllers/chaos_controller.rb +++ b/app/controllers/chaos_controller.rb @@ -52,13 +52,14 @@ class ChaosController < ActionController::Base def validate_chaos_secret unless chaos_secret_configured render plain: "chaos misconfigured: please configure GITLAB_CHAOS_SECRET", - status: :internal_server_error + status: :internal_server_error + return end unless Devise.secure_compare(chaos_secret_configured, chaos_secret_request) render plain: "To experience chaos, please set a valid `X-Chaos-Secret` header or `token` param", - status: :unauthorized + status: :unauthorized end end diff --git a/app/controllers/concerns/invisible_captcha_on_signup.rb b/app/controllers/concerns/invisible_captcha_on_signup.rb index b78869e02d0..a704ff251b3 100644 --- a/app/controllers/concerns/invisible_captcha_on_signup.rb +++ b/app/controllers/concerns/invisible_captcha_on_signup.rb @@ -26,15 +26,17 @@ module InvisibleCaptchaOnSignup end def invisible_captcha_honeypot_counter - @invisible_captcha_honeypot_counter ||= - Gitlab::Metrics.counter(:bot_blocked_by_invisible_captcha_honeypot, - 'Counter of blocked sign up attempts with filled honeypot') + @invisible_captcha_honeypot_counter ||= Gitlab::Metrics.counter( + :bot_blocked_by_invisible_captcha_honeypot, + 'Counter of blocked sign up attempts with filled honeypot' + ) end def invisible_captcha_timestamp_counter - @invisible_captcha_timestamp_counter ||= - Gitlab::Metrics.counter(:bot_blocked_by_invisible_captcha_timestamp, - 'Counter of blocked sign up attempts with invalid timestamp') + @invisible_captcha_timestamp_counter ||= Gitlab::Metrics.counter( + :bot_blocked_by_invisible_captcha_timestamp, + 'Counter of blocked sign up attempts with invalid timestamp' + ) end def log_request(message) diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index e1381b4173f..f0e8f180eb3 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -175,10 +175,7 @@ module IssuableActions end def render_cached_discussions(discussions, serializer, cache_context) - render_cached(discussions, - with: serializer, - cache_context: ->(_) { cache_context }, - context: self) + render_cached(discussions, with: serializer, cache_context: ->(_) { cache_context }, context: self) end def notes_filter diff --git a/app/controllers/concerns/known_sign_in.rb b/app/controllers/concerns/known_sign_in.rb index cacc7e4628f..997f26fa959 100644 --- a/app/controllers/concerns/known_sign_in.rb +++ b/app/controllers/concerns/known_sign_in.rb @@ -26,8 +26,13 @@ module KnownSignIn end def update_cookie - set_secure_cookie(KNOWN_SIGN_IN_COOKIE, current_user.id, - type: COOKIE_TYPE_ENCRYPTED, httponly: true, expires: KNOWN_SIGN_IN_COOKIE_EXPIRY) + set_secure_cookie( + KNOWN_SIGN_IN_COOKIE, + current_user.id, + type: COOKIE_TYPE_ENCRYPTED, + httponly: true, + expires: KNOWN_SIGN_IN_COOKIE_EXPIRY + ) end def sessions diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index 773e4c15d6e..da2ed9d62e7 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -63,10 +63,10 @@ module MembershipActions if access_requester.persisted? redirect_to polymorphic_path(membershipable), - notice: _('Your request for access has been queued for review.') + notice: _('Your request for access has been queued for review.') else redirect_to polymorphic_path(membershipable), - alert: format(_("Your request for access could not be processed: %{error_message}"), error_message: access_requester.errors.full_messages.to_sentence) + alert: format(_("Your request for access could not be processed: %{error_message}"), error_message: access_requester.errors.full_messages.to_sentence) end end diff --git a/app/controllers/concerns/observability/content_security_policy.rb b/app/controllers/concerns/observability/content_security_policy.rb index 3865e3b606d..14e9217fe02 100644 --- a/app/controllers/concerns/observability/content_security_policy.rb +++ b/app/controllers/concerns/observability/content_security_policy.rb @@ -18,11 +18,11 @@ module Observability # When ObservabilityUI is not authenticated, it needs to be able # to redirect to the GL sign-in page, hence '/users/sign_in' and '/oauth/authorize' - frame_src_values = Array.wrap(default_frame_src) | [Gitlab::Observability.observability_url, - Gitlab::Utils.append_path(Gitlab.config.gitlab.url, -'/users/sign_in'), - Gitlab::Utils.append_path(Gitlab.config.gitlab.url, -'/oauth/authorize')] + frame_src_values = Array.wrap(default_frame_src) | [ + Gitlab::Observability.observability_url, + Gitlab::Utils.append_path(Gitlab.config.gitlab.url, '/users/sign_in'), + Gitlab::Utils.append_path(Gitlab.config.gitlab.url, '/oauth/authorize') + ] p.frame_src(*frame_src_values) end diff --git a/app/controllers/concerns/wiki_actions.rb b/app/controllers/concerns/wiki_actions.rb index 2b781c528ad..46303cefb60 100644 --- a/app/controllers/concerns/wiki_actions.rb +++ b/app/controllers/concerns/wiki_actions.rb @@ -142,8 +142,7 @@ module WikiActions # rubocop:disable Gitlab/ModuleWithInstanceVariables def history if page - @commits = Kaminari.paginate_array(page.versions(page: params[:page].to_i), - total_count: page.count_versions) + @commits = Kaminari.paginate_array(page.versions(page: params[:page].to_i), total_count: page.count_versions) .page(params[:page]) render 'shared/wikis/history' @@ -178,8 +177,7 @@ module WikiActions if response.success? flash[:toast] = _("Wiki page was successfully deleted.") - redirect_to wiki_path(wiki), - status: :found + redirect_to wiki_path(wiki), status: :found else @error = response.message render 'shared/wikis/edit' diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 3005d19f8ed..a1b8dbcd304 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -29,9 +29,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController respond_to do |format| format.html do - redirect_to dashboard_todos_path, - status: :found, - notice: _('To-do item successfully marked as done.') + redirect_to dashboard_todos_path, status: :found, notice: _('To-do item successfully marked as done.') end format.js { head :ok } format.json { render json: todos_counts } diff --git a/app/controllers/groups/children_controller.rb b/app/controllers/groups/children_controller.rb index d10c52f0301..fb3a86d5219 100644 --- a/app/controllers/groups/children_controller.rb +++ b/app/controllers/groups/children_controller.rb @@ -41,10 +41,11 @@ module Groups protected def setup_children(parent) - @children = GroupDescendantsFinder.new(current_user: current_user, - parent_group: parent, - params: params.to_unsafe_h).execute - @children = @children.page(params[:page]) + @children = GroupDescendantsFinder.new( + current_user: current_user, + parent_group: parent, + params: params.to_unsafe_h + ).execute.page(params[:page]) end private diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index f0b857ca4c9..a1ccf6d51f4 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -18,8 +18,7 @@ class Groups::GroupMembersController < Groups::ApplicationController skip_before_action :check_two_factor_requirement, only: :leave skip_cross_project_access_check :index, :update, :destroy, :request_access, - :approve_access_request, :leave, :resend_invite, - :override + :approve_access_request, :leave, :resend_invite, :override feature_category :subgroups urgency :low diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 8f7a2c177b7..76065bc3ab8 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -46,8 +46,7 @@ class GroupsController < Groups::ApplicationController helper_method :captcha_required? - skip_cross_project_access_check :index, :new, :create, :edit, :update, - :destroy, :projects + skip_cross_project_access_check :index, :new, :create, :edit, :update, :destroy, :projects # When loading show as an atom feed, we render events that could leak cross # project information skip_cross_project_access_check :show, if: -> { request.format.html? } @@ -201,7 +200,7 @@ class GroupsController < Groups::ApplicationController send_upload(@group.export_file, attachment: @group.export_file.filename) else redirect_to edit_group_path(@group), - alert: _('The file containing the export is not available yet; it may still be transferring. Please try again later.') + alert: _('The file containing the export is not available yet; it may still be transferring. Please try again later.') end else redirect_to edit_group_path(@group), diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb index bfd6181a940..3dfa8d7b11e 100644 --- a/app/controllers/metrics_controller.rb +++ b/app/controllers/metrics_controller.rb @@ -10,9 +10,10 @@ class MetricsController < ActionController::Base response = if Gitlab::Metrics.prometheus_metrics_enabled? metrics_service.metrics_text else - help_page = help_page_url('administration/monitoring/prometheus/gitlab_metrics', - anchor: 'gitlab-prometheus-metrics' - ) + help_page = help_page_url( + 'administration/monitoring/prometheus/gitlab_metrics', + anchor: 'gitlab-prometheus-metrics' + ) "# Metrics are disabled, see: #{help_page}\n" end diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb index c88616b6d6c..28a57ef19f6 100644 --- a/app/controllers/profiles/emails_controller.rb +++ b/app/controllers/profiles/emails_controller.rb @@ -3,9 +3,9 @@ class Profiles::EmailsController < Profiles::ApplicationController before_action :find_email, only: [:destroy, :resend_confirmation_instructions] before_action -> { check_rate_limit!(:profile_add_new_email, scope: current_user, redirect_back: true) }, - only: [:create] + only: [:create] before_action -> { check_rate_limit!(:profile_resend_email_confirmation, scope: current_user, redirect_back: true) }, - only: [:resend_confirmation_instructions] + only: [:resend_confirmation_instructions] feature_category :user_profile urgency :low, [:index] diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 59cea00e26b..a930cb458a1 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -53,10 +53,13 @@ class Projects::BlobController < Projects::ApplicationController end def create - create_commit(Files::CreateService, success_notice: _("The file has been successfully created."), - success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) }, - failure_view: :new, - failure_path: project_new_blob_path(@project, @ref)) + create_commit( + Files::CreateService, + success_notice: _("The file has been successfully created."), + success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) }, + failure_view: :new, + failure_path: project_new_blob_path(@project, @ref) + ) end def show @@ -86,9 +89,11 @@ class Projects::BlobController < Projects::ApplicationController def update @path = params[:file_path] if params[:file_path].present? - create_commit(Files::UpdateService, success_path: -> { after_edit_path }, - failure_view: :edit, - failure_path: project_blob_path(@project, @id)) + create_commit( + Files::UpdateService, success_path: -> { after_edit_path }, + failure_view: :edit, + failure_path: project_blob_path(@project, @id) + ) rescue Files::UpdateService::FileChangedError @conflict = true render :edit @@ -106,9 +111,12 @@ class Projects::BlobController < Projects::ApplicationController end def destroy - create_commit(Files::DeleteService, success_notice: _("The file has been successfully deleted."), - success_path: -> { after_delete_path }, - failure_path: project_blob_path(@project, @id)) + create_commit( + Files::DeleteService, + success_notice: _("The file has been successfully deleted."), + success_path: -> { after_delete_path }, + failure_path: project_blob_path(@project, @id) + ) end def diff diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 252b203b38a..a86a0fb3bd2 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -115,8 +115,12 @@ class Projects::CommitController < Projects::ApplicationController @branch_name = create_new_branch? ? @commit.revert_branch_name : @start_branch - create_commit(Commits::RevertService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully reverted.", - success_path: -> { successful_change_path(@project) }, failure_path: failed_change_path) + create_commit( + Commits::RevertService, + success_notice: "The #{@commit.change_type_title(current_user)} has been successfully reverted.", + success_path: -> { successful_change_path(@project) }, + failure_path: failed_change_path + ) end def cherry_pick @@ -131,10 +135,13 @@ class Projects::CommitController < Projects::ApplicationController @branch_name = create_new_branch? ? @commit.cherry_pick_branch_name : @start_branch - create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.", - success_path: -> { successful_change_path(target_project) }, - failure_path: failed_change_path, - target_project: target_project) + create_commit( + Commits::CherryPickService, + success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.", + success_path: -> { successful_change_path(target_project) }, + failure_path: failed_change_path, + target_project: target_project + ) end private diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 9a88a8160b6..600238b04e3 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -30,17 +30,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController before_action :expire_etag_cache, only: [:index], unless: -> { request.format.json? } after_action :expire_etag_cache, only: [:cancel_auto_stop] - track_event :index, - :folder, - :show, - :new, - :edit, - :create, - :update, - :stop, - :cancel_auto_stop, - :terminal, - name: 'users_visiting_environments_pages' + track_event :index, :folder, :show, :new, :edit, :create, :update, :stop, :cancel_auto_stop, :terminal, + name: 'users_visiting_environments_pages' feature_category :continuous_delivery urgency :low @@ -255,11 +246,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController def search_environments(type: nil) search = params[:search] if params[:search] && params[:search].length >= MIN_SEARCH_LENGTH - @search_environments ||= - Environments::EnvironmentsFinder.new(project, - current_user, - type: type, - search: search).execute + @search_environments ||= Environments::EnvironmentsFinder.new(project, current_user, type: type, search: search).execute end def metrics_params diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb index d2e36ef5496..d70ee0fabea 100644 --- a/app/controllers/projects/error_tracking_controller.rb +++ b/app/controllers/projects/error_tracking_controller.rb @@ -74,8 +74,7 @@ class Projects::ErrorTrackingController < Projects::ErrorTracking::BaseControlle def render_errors(result) unless result[:status] == :success - render json: { message: result[:message] }, - status: result[:http_status] || :bad_request + render json: { message: result[:message] }, status: result[:http_status] || :bad_request end end diff --git a/app/controllers/projects/feature_flags_controller.rb b/app/controllers/projects/feature_flags_controller.rb index 16392775c09..83923965a45 100644 --- a/app/controllers/projects/feature_flags_controller.rb +++ b/app/controllers/projects/feature_flags_controller.rb @@ -97,23 +97,45 @@ class Projects::FeatureFlagsController < Projects::ApplicationController end def create_params - params.require(:operations_feature_flag) - .permit(:name, :description, :active, :version, - scopes_attributes: [:environment_scope, :active, - strategies: [:name, parameters: [:groupId, :percentage, :userIds]]], - strategies_attributes: [:name, :user_list_id, - parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], - scopes_attributes: [:environment_scope]]) + params.require(:operations_feature_flag).permit( + :name, + :description, + :active, + :version, + scopes_attributes: [ + :environment_scope, :active, + strategies: [:name, parameters: [:groupId, :percentage, :userIds]] + ], + strategies_attributes: [ + :name, + :user_list_id, + parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], + scopes_attributes: [:environment_scope] + ] + ) end def update_params - params.require(:operations_feature_flag) - .permit(:name, :description, :active, - scopes_attributes: [:id, :environment_scope, :active, :_destroy, - strategies: [:name, parameters: [:groupId, :percentage, :userIds]]], - strategies_attributes: [:id, :name, :user_list_id, :_destroy, - parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], - scopes_attributes: [:id, :environment_scope, :_destroy]]) + params.require(:operations_feature_flag).permit( + :name, + :description, + :active, + scopes_attributes: [ + :id, + :environment_scope, + :active, + :_destroy, + strategies: [:name, parameters: [:groupId, :percentage, :userIds]] + ], + strategies_attributes: [ + :id, + :name, + :user_list_id, + :_destroy, + parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], + scopes_attributes: [:id, :environment_scope, :_destroy] + ] + ) end def feature_flag_json(feature_flag) @@ -144,7 +166,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController end def render_error_json(messages, status = :bad_request) - render json: { message: messages }, - status: status + render json: { message: messages }, status: status end end diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 3fea5c694f7..36fa1fab68f 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -128,8 +128,7 @@ class Projects::JobsController < Projects::ApplicationController service_response = Ci::BuildEraseService.new(@build, current_user).execute if service_response.success? - redirect_to project_job_path(project, @build), - notice: _("Job has been successfully erased!") + redirect_to project_job_path(project, @build), notice: _("Job has been successfully erased!") else head service_response.http_status end @@ -138,9 +137,7 @@ class Projects::JobsController < Projects::ApplicationController def raw if @build.trace.archived? workhorse_set_content_type! - send_upload(@build.job_artifacts_trace.file, - send_params: raw_send_params, - redirect_params: raw_redirect_params) + send_upload(@build.job_artifacts_trace.file, send_params: raw_send_params, redirect_params: raw_redirect_params) else @build.trace.read do |stream| if stream.file? @@ -234,10 +231,12 @@ class Projects::JobsController < Projects::ApplicationController end def build_service_specification - @build.service_specification(service: params['service'], - port: params['port'], - path: params['path'], - subprotocols: proxy_subprotocol) + @build.service_specification( + service: params['service'], + port: params['port'], + path: params['path'], + subprotocols: proxy_subprotocol + ) end def proxy_subprotocol diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 14f2e372bc5..649bead0b6d 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -82,9 +82,7 @@ class Projects::LabelsController < Projects::ApplicationController @label.destroy @labels = find_labels - redirect_to project_labels_path(@project), - status: :found, - notice: 'Label was removed' + redirect_to project_labels_path(@project), status: :found, notice: 'Label was removed' end def remove_priority @@ -138,8 +136,9 @@ class Projects::LabelsController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to(project_labels_path(@project), - notice: _('Failed to promote label due to internal error. Please contact administrators.')) + redirect_to( + project_labels_path(@project), + notice: _('Failed to promote label due to internal error. Please contact administrators.')) end format.js end @@ -165,13 +164,14 @@ class Projects::LabelsController < Projects::ApplicationController end def find_labels - @available_labels ||= - LabelsFinder.new(current_user, - project_id: @project.id, - include_ancestor_groups: true, - search: params[:search], - subscribed: params[:subscribed], - sort: sort).execute + @available_labels ||= LabelsFinder.new( + current_user, + project_id: @project.id, + include_ancestor_groups: true, + search: params[:search], + subscribed: params[:subscribed], + sort: sort + ).execute end def sort diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb index 3b399e3294e..3a03831ab88 100644 --- a/app/controllers/projects/merge_requests/creations_controller.rb +++ b/app/controllers/projects/merge_requests/creations_controller.rb @@ -114,11 +114,10 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap @target_project = @merge_request.target_project @source_project = @merge_request.source_project - @commits = - set_commits_for_rendering( - @merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch), - commits_count: @merge_request.commits_count - ) + @commits = set_commits_for_rendering( + @merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch), + commits_count: @merge_request.commits_count + ) @commit = @merge_request.diff_head_commit diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index d92ef3de6d9..363d1ecc5dd 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -383,10 +383,12 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo @merge_request.merge_request_reviewers.map(&:cache_key) ] - render_cached(@merge_request, - with: serializer, - cache_context: ->(_) { [Digest::SHA256.hexdigest(cache_context.to_s)] }, - serializer: params[:serializer]) + render_cached( + @merge_request, + with: serializer, + cache_context: ->(_) { [Digest::SHA256.hexdigest(cache_context.to_s)] }, + serializer: params[:serializer] + ) else render json: serializer.represent(@merge_request, serializer: params[:serializer]) end @@ -485,8 +487,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo AutoMergeService.new(project, current_user, merge_params).update(merge_request) else AutoMergeService.new(project, current_user, merge_params) - .execute(merge_request, - params[:auto_merge_strategy] || AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS) + .execute(merge_request, params[:auto_merge_strategy] || AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS) end else @merge_request.merge_async(current_user.id, merge_params) diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb index db0762a6cff..3d0b48c2fc1 100644 --- a/app/controllers/projects/pages_controller.rb +++ b/app/controllers/projects/pages_controller.rb @@ -43,9 +43,7 @@ class Projects::PagesController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to project_pages_path(@project), - status: :found, - notice: 'Pages were scheduled for removal' + redirect_to project_pages_path(@project), status: :found, notice: 'Pages were scheduled for removal' end end end diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb index 43952a2efe4..5cb69e8bf99 100644 --- a/app/controllers/projects/pages_domains_controller.rb +++ b/app/controllers/projects/pages_domains_controller.rb @@ -69,9 +69,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to project_pages_path(@project), - status: :found, - notice: 'Domain was removed' + redirect_to project_pages_path(@project), status: :found, notice: 'Domain was removed' end format.js end diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index 19d031bd59b..bbc62c03957 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -78,9 +78,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController if schedule.destroy redirect_to pipeline_schedules_path(@project), status: :found else - redirect_to pipeline_schedules_path(@project), - status: :forbidden, - alert: _("Failed to remove the pipeline schedule") + redirect_to pipeline_schedules_path(@project), status: :forbidden, alert: _("Failed to remove the pipeline schedule") end end diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 10f58a9f479..6d84cb20983 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -98,15 +98,15 @@ class Projects::PipelinesController < Projects::ApplicationController end format.json do if service_response.success? - render json: PipelineSerializer - .new(project: project, current_user: current_user) - .represent(@pipeline), - status: :created + render json: PipelineSerializer.new(project: project, current_user: current_user).represent(@pipeline), + status: :created else - render json: { errors: @pipeline.error_messages.map(&:content), - warnings: @pipeline.warning_messages(limit: ::Gitlab::Ci::Warnings::MAX_LIMIT).map(&:content), - total_warnings: @pipeline.warning_messages.length }, - status: :bad_request + bad_request_json = { + errors: @pipeline.error_messages.map(&:content), + warnings: @pipeline.warning_messages(limit: ::Gitlab::Ci::Warnings::MAX_LIMIT).map(&:content), + total_warnings: @pipeline.warning_messages.length + } + render json: bad_request_json, status: :bad_request end end end diff --git a/app/controllers/projects/prometheus/metrics_controller.rb b/app/controllers/projects/prometheus/metrics_controller.rb index db5471ea322..c20c80ba334 100644 --- a/app/controllers/projects/prometheus/metrics_controller.rb +++ b/app/controllers/projects/prometheus/metrics_controller.rb @@ -68,7 +68,7 @@ module Projects if @metric.persisted? redirect_to edit_project_settings_integration_path(project, ::Integrations::Prometheus), - notice: _('Metric was successfully added.') + notice: _('Metric was successfully added.') else render 'new' end @@ -79,7 +79,7 @@ module Projects if @metric.update(metrics_params) redirect_to edit_project_settings_integration_path(project, ::Integrations::Prometheus), - notice: _('Metric was successfully updated.') + notice: _('Metric was successfully updated.') else render 'edit' end diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 1cd4c5b6137..e688720ce6a 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -49,9 +49,14 @@ class Projects::RepositoriesController < Projects::ApplicationController def set_cache_headers commit_id = archive_metadata['CommitId'] - expires_in(cache_max_age(commit_id), - public: Guest.can?(:download_code, project), must_revalidate: true, stale_if_error: 5.minutes, - stale_while_revalidate: 1.minute, 's-maxage': 1.minute) + expires_in( + cache_max_age(commit_id), + public: Guest.can?(:download_code, project), + must_revalidate: true, + stale_if_error: 5.minutes, + stale_while_revalidate: 1.minute, + 's-maxage': 1.minute + ) fresh_when(strong_etag: [commit_id, archive_metadata['ArchivePath']]) end diff --git a/app/controllers/projects/security/configuration_controller.rb b/app/controllers/projects/security/configuration_controller.rb index 00a2a5d1193..ee2e60b5a1a 100644 --- a/app/controllers/projects/security/configuration_controller.rb +++ b/app/controllers/projects/security/configuration_controller.rb @@ -32,9 +32,7 @@ module Projects end def configuration_presenter - ::Projects::Security::ConfigurationPresenter.new(project, - **presenter_attributes, - current_user: current_user) + ::Projects::Security::ConfigurationPresenter.new(project, **presenter_attributes, current_user: current_user) end def presenter_attributes diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 737a6290431..ba18a2e0dce 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -40,9 +40,12 @@ class Projects::TreeController < Projects::ApplicationController def create_dir return render_404 unless @commit_params.values.all? - create_commit(Files::CreateDirService, success_notice: _("The directory has been successfully created."), - success_path: project_tree_path(@project, File.join(@branch_name, @dir_name)), - failure_path: project_tree_path(@project, @ref)) + create_commit( + Files::CreateDirService, + success_notice: _("The directory has been successfully created."), + success_path: project_tree_path(@project, File.join(@branch_name, @dir_name)), + failure_path: project_tree_path(@project, @ref) + ) end private diff --git a/app/controllers/projects/web_ide_terminals_controller.rb b/app/controllers/projects/web_ide_terminals_controller.rb index cfccc949244..be7423e3919 100644 --- a/app/controllers/projects/web_ide_terminals_controller.rb +++ b/app/controllers/projects/web_ide_terminals_controller.rb @@ -29,10 +29,7 @@ class Projects::WebIdeTerminalsController < Projects::ApplicationController end def create - result = ::Ci::CreateWebIdeTerminalService.new(project, - current_user, - ref: params[:branch]) - .execute + result = ::Ci::CreateWebIdeTerminalService.new(project, current_user, ref: params[:branch]).execute if result[:status] == :error render status: :bad_request, json: result[:message] diff --git a/app/controllers/repositories/lfs_api_controller.rb b/app/controllers/repositories/lfs_api_controller.rb index 83973d07a17..d52ae723eee 100644 --- a/app/controllers/repositories/lfs_api_controller.rb +++ b/app/controllers/repositories/lfs_api_controller.rb @@ -172,13 +172,15 @@ module Repositories LfsObjectsProject.link_to_project!(lfs_object, project) - Gitlab::AppJsonLogger.info(message: "LFS object auto-linked to forked project", - lfs_object_oid: lfs_object.oid, - lfs_object_size: lfs_object.size, - source_project_id: project.fork_source.id, - source_project_path: project.fork_source.full_path, - target_project_id: project.project_id, - target_project_path: project.full_path) + Gitlab::AppJsonLogger.info( + message: "LFS object auto-linked to forked project", + lfs_object_oid: lfs_object.oid, + lfs_object_size: lfs_object.size, + source_project_id: project.fork_source.id, + source_project_path: project.fork_source.full_path, + target_project_id: project.project_id, + target_project_path: project.full_path + ) end end end diff --git a/app/controllers/repositories/lfs_locks_api_controller.rb b/app/controllers/repositories/lfs_locks_api_controller.rb index ea858d63236..52ae9068c75 100644 --- a/app/controllers/repositories/lfs_locks_api_controller.rb +++ b/app/controllers/repositories/lfs_locks_api_controller.rb @@ -37,9 +37,7 @@ module Repositories private def render_json(data, process = true) - render json: build_payload(data, process), - content_type: LfsRequest::CONTENT_TYPE, - status: @result[:http_status] + render json: build_payload(data, process), content_type: LfsRequest::CONTENT_TYPE, status: @result[:http_status] end def build_payload(data, process) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 1ca34dee3d6..8796fda572f 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -11,10 +11,10 @@ class SearchController < ApplicationController CODE_SEARCH_LITERALS = %w[blob: extension: path: filename:].freeze track_custom_event :show, - name: 'i_search_total', - label: 'redis_hll_counters.search.search_total_unique_counts_monthly', - action: 'executed', - destinations: [:redis_hll, :snowplow] + name: 'i_search_total', + label: 'redis_hll_counters.search.search_total_unique_counts_monthly', + action: 'executed', + destinations: [:redis_hll, :snowplow] def self.search_rate_limited_endpoints %i[show count autocomplete] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9546f71cd37..58f40e10fd4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -9,20 +9,21 @@ class UsersController < ApplicationController include Gitlab::NoteableMetadata requires_cross_project_access show: false, - groups: false, - projects: false, - contributed: false, - snippets: true, - calendar: false, - followers: false, - following: false, - calendar_activities: true + groups: false, + projects: false, + contributed: false, + snippets: true, + calendar: false, + followers: false, + following: false, + calendar_activities: true skip_before_action :authenticate_user! prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) } before_action :user, except: [:exists] - before_action :authorize_read_user_profile!, - only: [:calendar, :calendar_activities, :groups, :projects, :contributed, :starred, :snippets, :followers, :following] + before_action :authorize_read_user_profile!, only: [ + :calendar, :calendar_activities, :groups, :projects, :contributed, :starred, :snippets, :followers, :following + ] before_action only: [:exists] do check_rate_limit!(:username_exists, scope: request.ip) end diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index d0421cd5184..0b0921cea8b 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -66,11 +66,21 @@ module NavHelper end def show_super_sidebar? - Feature.enabled?(:super_sidebar_nav, current_user) && current_user&.use_new_navigation + Feature.enabled?(:super_sidebar_nav, current_user) && current_user&.use_new_navigation && super_sidebar_supported? end private + # This is a temporary measure until we support all other existing sidebars: + # https://gitlab.com/gitlab-org/gitlab/-/issues/391500 + # https://gitlab.com/gitlab-org/gitlab/-/issues/391501 + # https://gitlab.com/gitlab-org/gitlab/-/issues/391502 + def super_sidebar_supported? + return true if @nav.nil? + + %w(your_work project group).include?(@nav) + end + def get_header_links links = if current_user [:user_dropdown] diff --git a/app/helpers/sidebars_helper.rb b/app/helpers/sidebars_helper.rb index 27020738515..a7f56ebf004 100644 --- a/app/helpers/sidebars_helper.rb +++ b/app/helpers/sidebars_helper.rb @@ -23,19 +23,21 @@ module SidebarsHelper end end - def project_sidebar_context(project, user, current_ref, ref_type: nil) + def project_sidebar_context(project, user, current_ref, ref_type: nil, **args) context_data = project_sidebar_context_data(project, user, current_ref, ref_type: ref_type) - Sidebars::Projects::Context.new(**context_data) + Sidebars::Projects::Context.new(**context_data, **args) end - def group_sidebar_context(group, user) + def group_sidebar_context(group, user, **args) context_data = group_sidebar_context_data(group, user) - Sidebars::Groups::Context.new(**context_data) + Sidebars::Groups::Context.new(**context_data, **args) end - def super_sidebar_context(user, group:, project:) + def super_sidebar_context(user, group:, project:, panel:) { + current_menu_items: panel.super_sidebar_menu_items, + current_context_header: panel.super_sidebar_context_header, name: user.name, username: user.username, avatar_url: user.avatar_url, @@ -55,6 +57,21 @@ module SidebarsHelper } end + def super_sidebar_nav_panel(nav: nil, project: nil, user: nil, group: nil, current_ref: nil, ref_type: nil) + case nav + when 'project' + context = project_sidebar_context(project, user, current_ref, ref_type: ref_type, + route_is_active: method(:active_nav_link?)) + Sidebars::Projects::Panel.new(context) + when 'group' + context = group_sidebar_context(group, user, route_is_active: method(:active_nav_link?)) + Sidebars::Groups::Panel.new(context) + else + Sidebars::YourWork::Panel.new(Sidebars::Context.new(current_user: user, container: nil, + route_is_active: method(:active_nav_link?))) + end + end + private def create_new_menu_groups(group:, project:) diff --git a/app/models/bulk_imports/file_transfer/base_config.rb b/app/models/bulk_imports/file_transfer/base_config.rb index 036d511bc59..67c4e7400b3 100644 --- a/app/models/bulk_imports/file_transfer/base_config.rb +++ b/app/models/bulk_imports/file_transfer/base_config.rb @@ -51,7 +51,8 @@ module BulkImports end def portable_relations_tree - @portable_relations_tree ||= attributes_finder.find_relations_tree(portable_class_sym).deep_stringify_keys + @portable_relations_tree ||= attributes_finder + .find_relations_tree(portable_class_sym, include_import_only_tree: true).deep_stringify_keys end private diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 46a9e3f6494..5df6f774767 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -27,6 +27,7 @@ module Ci has_many :processables, class_name: 'Ci::Processable', foreign_key: :stage_id, inverse_of: :ci_stage has_many :builds, foreign_key: :stage_id, inverse_of: :ci_stage has_many :bridges, foreign_key: :stage_id, inverse_of: :ci_stage + has_many :generic_commit_statuses, foreign_key: :stage_id, inverse_of: :ci_stage scope :ordered, -> { order(position: :asc) } scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) } diff --git a/app/services/security/ci_configuration/base_create_service.rb b/app/services/security/ci_configuration/base_create_service.rb index 3e8865d3dff..c5fbabf487c 100644 --- a/app/services/security/ci_configuration/base_create_service.rb +++ b/app/services/security/ci_configuration/base_create_service.rb @@ -51,7 +51,7 @@ module Security end def existing_gitlab_ci_content - root_ref = root_ref_sha(project) + root_ref = root_ref_sha(project.repository) return if root_ref.nil? @gitlab_ci_yml ||= project.ci_config_for(root_ref) @@ -82,13 +82,10 @@ module Security ) end - def root_ref_sha(project) - project.repository.root_ref_sha - rescue StandardError => e - # this might fail on the very first commit, - # and unfortunately it raises a StandardError - Gitlab::ErrorTracking.track_exception(e, project_id: project.id) - nil + def root_ref_sha(repository) + commit = repository.commit(repository.root_ref) + + commit&.sha end end end diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index d2ed70d6b48..77f0c3c636f 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -2,7 +2,8 @@ - @left_sidebar = true .layout-page.hide-when-top-nav-responsive-open{ class: page_with_sidebar_class } - if show_super_sidebar? - - sidebar_data = super_sidebar_context(current_user, group: @group, project: @project).to_json + - sidebar_panel = super_sidebar_nav_panel(nav: nav, user: current_user, group: @group, project: @project, current_ref: current_ref, ref_type: @ref_type) + - sidebar_data = super_sidebar_context(current_user, group: @group, project: @project, panel: sidebar_panel).to_json %aside.js-super-sidebar.nav-sidebar{ data: { root_path: root_path, sidebar: sidebar_data, toggle_new_nav_endpoint: profile_preferences_url } } - if display_whats_new? diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index 827aa86d61a..74b85a93c8e 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -22,7 +22,7 @@ %span.legend-box.legend-box-9 %span.right-label Older - .table-responsive.blame-table{ data: { qa_selector: 'blame_file_content' } } + .table-responsive.blame-table .blame-table-wrapper = render partial: 'page' |