diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 00:07:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 00:07:40 +0300 |
commit | 134fe182008dc13a16f12d723aa73771efb1a6a2 (patch) | |
tree | 727c94937346d31a5e2692546d16296f069d09fe /app | |
parent | 6a7cc8c14727f6fac64a5be6838764d8d5d41468 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/pages/snippets/show/index.js | 12 | ||||
-rw-r--r-- | app/assets/stylesheets/components/toast.scss | 52 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/variables.scss | 10 | ||||
-rw-r--r-- | app/controllers/projects/pipeline_schedules_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/projects/raw_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 18 | ||||
-rw-r--r-- | app/views/snippets/show.html.haml | 17 |
7 files changed, 50 insertions, 85 deletions
diff --git a/app/assets/javascripts/pages/snippets/show/index.js b/app/assets/javascripts/pages/snippets/show/index.js index 26936110402..5efcc901fde 100644 --- a/app/assets/javascripts/pages/snippets/show/index.js +++ b/app/assets/javascripts/pages/snippets/show/index.js @@ -5,9 +5,11 @@ import initNotes from '~/init_notes'; import snippetEmbed from '~/snippet/snippet_embed'; document.addEventListener('DOMContentLoaded', () => { - new LineHighlighter(); // eslint-disable-line no-new - new BlobViewer(); // eslint-disable-line no-new - initNotes(); - new ZenMode(); // eslint-disable-line no-new - snippetEmbed(); + if (!gon.features.snippetsVue) { + new LineHighlighter(); // eslint-disable-line no-new + new BlobViewer(); // eslint-disable-line no-new + initNotes(); + new ZenMode(); // eslint-disable-line no-new + snippetEmbed(); + } }); diff --git a/app/assets/stylesheets/components/toast.scss b/app/assets/stylesheets/components/toast.scss deleted file mode 100644 index e27bf282247..00000000000 --- a/app/assets/stylesheets/components/toast.scss +++ /dev/null @@ -1,52 +0,0 @@ -/* -* These styles are specific to the gl-toast component. -* Documentation: https://design.gitlab.com/components/toasts -* Note: Styles below are nested in order to override some of vue-toasted's default styling -*/ -.toasted-container { - - max-width: $toast-max-width; - - @include media-breakpoint-down(xs) { - width: 100%; - padding-right: $toast-padding-right; - } - - .toasted.gl-toast { - border-radius: $border-radius-default; - font-size: $gl-font-size; - padding: $gl-padding-8 $gl-padding $gl-padding-8 $gl-padding-24; - margin-top: $toast-default-margin; - line-height: $gl-line-height; - background-color: rgba($gray-900, $toast-background-opacity); - - span { - padding-right: $gl-padding-8; - } - - @include media-breakpoint-down(xs) { - .action:first-of-type { - // Ensures actions buttons are right aligned on mobile - margin-left: auto; - } - } - - .action { - color: $blue-300; - margin: 0 0 0 $toast-default-margin; - text-transform: none; - font-size: $gl-font-size; - } - - .toast-close { - font-size: $default-icon-size; - margin-left: $toast-default-margin; - } - } -} - -// Overrides the default positioning of toasts -body .toasted-container.bottom-left { - bottom: $toast-offset; - left: $toast-offset; -} diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 0f77c451fac..a833e104b49 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -529,16 +529,6 @@ $pagination-line-height: 20px; $pagination-disabled-color: #cdcdcd; /* -* Toasts -*/ -$toast-offset: 24px; -$toast-height: 48px; -$toast-max-width: 586px; -$toast-padding-right: 42px; -$toast-default-margin: 8px; -$toast-background-opacity: 0.95; - -/* * Status icons */ $status-icon-size: 22px; diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index 72e939a3310..6a7e2b69652 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -83,12 +83,14 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController def play_rate_limit return unless current_user - limiter = ::Gitlab::ActionRateLimiter.new(action: :play_pipeline_schedule) - - return unless limiter.throttled?([current_user, schedule], 1) + if rate_limiter.throttled?(:play_pipeline_schedule, scope: [current_user, schedule]) + flash[:alert] = _('You cannot play this scheduled pipeline at the moment. Please wait a minute.') + redirect_to pipeline_schedules_path(@project) + end + end - flash[:alert] = _('You cannot play this scheduled pipeline at the moment. Please wait a minute.') - redirect_to pipeline_schedules_path(@project) + def rate_limiter + ::Gitlab::ApplicationRateLimiter end def schedule diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index c94fdd9483d..985587268c5 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -19,14 +19,16 @@ class Projects::RawController < Projects::ApplicationController private def show_rate_limit - limiter = ::Gitlab::ActionRateLimiter.new(action: :show_raw_controller) + if rate_limiter.throttled?(:show_raw_controller, scope: [@project, @commit, @path], threshold: raw_blob_request_limit) + rate_limiter.log_request(request, :raw_blob_request_limit, current_user) - return unless limiter.throttled?([@project, @commit, @path], raw_blob_request_limit) - - limiter.log_request(request, :raw_blob_request_limit, current_user) + flash[:alert] = _('You cannot access the raw file. Please wait a minute.') + redirect_to project_blob_path(@project, File.join(@ref, @path)), status: :too_many_requests + end + end - flash[:alert] = _('You cannot access the raw file. Please wait a minute.') - redirect_to project_blob_path(@project, File.join(@ref, @path)), status: :too_many_requests + def rate_limiter + ::Gitlab::ApplicationRateLimiter end def raw_blob_request_limit diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e5dea031bb5..47d6fb67108 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -32,6 +32,9 @@ class ProjectsController < Projects::ApplicationController before_action :authorize_archive_project!, only: [:archive, :unarchive] before_action :event_filter, only: [:show, :activity] + # Project Export Rate Limit + before_action :export_rate_limit, only: [:export, :download_export, :generate_new_export] + layout :determine_layout def index @@ -465,6 +468,21 @@ class ProjectsController < Projects::ApplicationController def present_project @project = @project.present(current_user: current_user) end + + def export_rate_limit + prefixed_action = "project_#{params[:action]}".to_sym + + if rate_limiter.throttled?(prefixed_action, scope: [current_user, prefixed_action, @project]) + rate_limiter.log_request(request, "#{prefixed_action}_request_limit".to_sym, current_user) + + flash[:alert] = _('This endpoint has been requested too many times. Try again later.') + redirect_to edit_project_path(@project) + end + end + + def rate_limiter + ::Gitlab::ApplicationRateLimiter + end end ProjectsController.prepend_if_ee('EE::ProjectsController') diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index 36b4e00e8d5..c77b05e3ea8 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -4,13 +4,16 @@ - breadcrumb_title @snippet.to_reference - page_title "#{@snippet.title} (#{@snippet.to_reference})", _("Snippets") -= render 'shared/snippets/header' +- if Feature.enabled?(:snippets_vue) + #js-snippet-view{ 'data-qa-selector': 'snippet_view' } +- else + = render 'shared/snippets/header' -.personal-snippets - %article.file-holder.snippet-file-content - = render 'shared/snippets/blob' + .personal-snippets + %article.file-holder.snippet-file-content + = render 'shared/snippets/blob' - .row-content-block.top-block.content-component-block - = render 'award_emoji/awards_block', awardable: @snippet, inline: true + .row-content-block.top-block.content-component-block + = render 'award_emoji/awards_block', awardable: @snippet, inline: true - #notes.limited-width-notes= render "shared/notes/notes_with_form", :autocomplete => false + #notes.limited-width-notes= render "shared/notes/notes_with_form", :autocomplete => false |