summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-10 18:08:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-10 18:08:17 +0000
commit219eead23f9feb5da9ec378c451d773aea2dfe61 (patch)
treeeec14421a05ca8eb79f3cc782abe99532bb6070c /app
parent7c38405be9e79099f399aa429503ea7b463bbf5a (diff)
downloadgitlab-ce-219eead23f9feb5da9ec378c451d773aea2dfe61.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/error_tracking/components/error_details.vue26
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb30
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/models/concerns/bulk_insert_safe.rb4
-rw-r--r--app/models/concerns/bulk_insertable_associations.rb9
-rw-r--r--app/services/notification_recipients/build_service.rb10
-rw-r--r--app/views/layouts/_page.html.haml2
-rw-r--r--app/views/layouts/fullscreen.html.haml2
-rw-r--r--app/views/shared/_outdated_browser.html.haml19
9 files changed, 83 insertions, 21 deletions
diff --git a/app/assets/javascripts/error_tracking/components/error_details.vue b/app/assets/javascripts/error_tracking/components/error_details.vue
index 43fa97e4095..6c4f59eb49f 100644
--- a/app/assets/javascripts/error_tracking/components/error_details.vue
+++ b/app/assets/javascripts/error_tracking/components/error_details.vue
@@ -25,6 +25,8 @@ import { severityLevel, severityLevelVariant, errorStatus } from './constants';
import query from '../queries/details.query.graphql';
+const SENTRY_TIMEOUT = 10000;
+
export default {
components: {
GlButton,
@@ -87,6 +89,8 @@ export default {
if (res.data.project?.sentryErrors?.detailedError) {
this.$apollo.queries.error.stopPolling();
this.setStatus(this.error.status);
+ } else {
+ this.onNoApolloResult();
}
},
},
@@ -94,6 +98,8 @@ export default {
data() {
return {
error: null,
+ errorLoading: true,
+ errorPollTimeout: 0,
issueCreationInProgress: false,
isAlertVisible: false,
closedIssueId: null,
@@ -158,8 +164,19 @@ export default {
return this.errorStatus !== errorStatus.RESOLVED ? __('Resolve') : __('Unresolve');
},
},
+ watch: {
+ error(val) {
+ if (val) {
+ this.errorLoading = false;
+ }
+ },
+ },
mounted() {
this.startPollingStacktrace(this.issueStackTracePath);
+ this.errorPollTimeout = Date.now() + SENTRY_TIMEOUT;
+ this.$apollo.queries.error.setOptions({
+ fetchPolicy: 'cache-and-network',
+ });
},
methods: {
...mapActions('details', [
@@ -191,6 +208,13 @@ export default {
}
});
},
+ onNoApolloResult() {
+ if (Date.now() > this.errorPollTimeout) {
+ this.$apollo.queries.error.stopPolling();
+ this.errorLoading = false;
+ createFlash(__('Could not connect to Sentry. Refresh the page to try again.'), 'warning');
+ }
+ },
formatDate(date) {
return `${this.timeFormatted(date)} (${dateFormat(date, 'UTC:yyyy-mm-dd h:MM:ssTT Z')})`;
},
@@ -200,7 +224,7 @@ export default {
<template>
<div>
- <div v-if="$apollo.queries.error.loading" class="py-3">
+ <div v-if="errorLoading" class="py-3">
<gl-loading-icon :size="3" />
</div>
<div v-else-if="error" class="error-details">
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index c9c487cec26..6b8436d766c 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -1,9 +1,14 @@
# frozen_string_literal: true
class Import::GitlabProjectsController < Import::BaseController
+ include WorkhorseRequest
+
before_action :whitelist_query_limiting, only: [:create]
before_action :verify_gitlab_project_import_enabled
+ skip_before_action :verify_authenticity_token, only: [:authorize]
+ before_action :verify_workhorse_api!, only: [:authorize]
+
def new
@namespace = Namespace.find(project_params[:namespace_id])
return render_404 unless current_user.can?(:create_projects, @namespace)
@@ -28,10 +33,29 @@ class Import::GitlabProjectsController < Import::BaseController
end
end
+ def authorize
+ set_workhorse_internal_api_content_type
+
+ authorized = ImportExportUploader.workhorse_authorize(
+ has_length: false,
+ maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i)
+
+ render json: authorized
+ rescue SocketError
+ render json: _("Error uploading file"), status: :internal_server_error
+ end
+
private
def file_is_valid?
- return false unless project_params[:file] && project_params[:file].respond_to?(:read)
+ # TODO: remove the condition and the private method after the WH version including
+ # https://gitlab.com/gitlab-org/gitlab-workhorse/-/merge_requests/470
+ # is released and GITLAB_WORKHORSE_VERSION is updated accordingly.
+ if with_workhorse_upload_acceleration?
+ return false unless project_params[:file].is_a?(::UploadedFile)
+ else
+ return false unless project_params[:file] && project_params[:file].respond_to?(:read)
+ end
filename = project_params[:file].original_filename
@@ -51,4 +75,8 @@ class Import::GitlabProjectsController < Import::BaseController
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42437')
end
+
+ def with_workhorse_upload_acceleration?
+ request.headers[Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER].present?
+ end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8833b36c42d..83ecc7753b6 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -227,7 +227,7 @@ module ApplicationHelper
end
def outdated_browser?
- browser.ie? && browser.version.to_i < 10
+ browser.ie?
end
def path_to_key(key, admin = false)
diff --git a/app/models/concerns/bulk_insert_safe.rb b/app/models/concerns/bulk_insert_safe.rb
index 0d022418b1a..d8587ea78ec 100644
--- a/app/models/concerns/bulk_insert_safe.rb
+++ b/app/models/concerns/bulk_insert_safe.rb
@@ -111,8 +111,8 @@ module BulkInsertSafe
end
def _bulk_insert_reject_primary_key!(attributes, primary_key)
- if attributes.delete(primary_key)
- raise PrimaryKeySetError, "Primary key set: #{primary_key}:#{attributes[primary_key]}\n" \
+ if existing_pk = attributes.delete(primary_key)
+ raise PrimaryKeySetError, "Primary key set: #{primary_key}:#{existing_pk}\n" \
"Bulk-inserts are only supported for rows that don't already have PK set"
end
end
diff --git a/app/models/concerns/bulk_insertable_associations.rb b/app/models/concerns/bulk_insertable_associations.rb
index 35bdabbcefd..5ee2e8356bd 100644
--- a/app/models/concerns/bulk_insertable_associations.rb
+++ b/app/models/concerns/bulk_insertable_associations.rb
@@ -93,11 +93,14 @@ module BulkInsertableAssociations
end
def _bulk_insert_configure_foreign_key(reflection, items)
- primary_key = self[reflection.active_record_primary_key]
- raise "Classes including `BulkInsertableAssociations` must define a `primary_key`" unless primary_key
+ primary_key_column = reflection.active_record_primary_key
+ raise "Classes including `BulkInsertableAssociations` must define a `primary_key`" unless primary_key_column
+
+ primary_key_value = self[primary_key_column]
+ raise "No value found for primary key `#{primary_key_column}`" unless primary_key_value
items.each do |item|
- item[reflection.foreign_key] = primary_key
+ item[reflection.foreign_key] = primary_key_value
if reflection.type
item[reflection.type] = self.class.polymorphic_name
diff --git a/app/services/notification_recipients/build_service.rb b/app/services/notification_recipients/build_service.rb
index 67f9849aece..df807f11e1b 100644
--- a/app/services/notification_recipients/build_service.rb
+++ b/app/services/notification_recipients/build_service.rb
@@ -14,23 +14,23 @@ module NotificationRecipients
end
def self.build_recipients(*args)
- Builder::Default.new(*args).notification_recipients
+ ::NotificationRecipients::Builder::Default.new(*args).notification_recipients
end
def self.build_new_note_recipients(*args)
- Builder::NewNote.new(*args).notification_recipients
+ ::NotificationRecipients::Builder::NewNote.new(*args).notification_recipients
end
def self.build_merge_request_unmergeable_recipients(*args)
- Builder::MergeRequestUnmergeable.new(*args).notification_recipients
+ ::NotificationRecipients::Builder::MergeRequestUnmergeable.new(*args).notification_recipients
end
def self.build_project_maintainers_recipients(*args)
- Builder::ProjectMaintainers.new(*args).notification_recipients
+ ::NotificationRecipients::Builder::ProjectMaintainers.new(*args).notification_recipients
end
def self.build_new_release_recipients(*args)
- Builder::NewRelease.new(*args).notification_recipients
+ ::NotificationRecipients::Builder::NewRelease.new(*args).notification_recipients
end
end
end
diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml
index 2b2ffd6abeb..06e3bca99a1 100644
--- a/app/views/layouts/_page.html.haml
+++ b/app/views/layouts/_page.html.haml
@@ -2,9 +2,9 @@
- if defined?(nav) && nav
= render "layouts/nav/sidebar/#{nav}"
.content-wrapper{ class: "#{@content_wrapper_class}" }
- = render 'shared/outdated_browser'
.mobile-overlay
.alert-wrapper
+ = render 'shared/outdated_browser'
= render_if_exists "layouts/header/ee_license_banner"
= render "layouts/broadcast"
= render "layouts/header/read_only_banner"
diff --git a/app/views/layouts/fullscreen.html.haml b/app/views/layouts/fullscreen.html.haml
index 8d0775f6f27..63bb9f8fff5 100644
--- a/app/views/layouts/fullscreen.html.haml
+++ b/app/views/layouts/fullscreen.html.haml
@@ -5,9 +5,9 @@
= render 'peek/bar'
= header_message
= render partial: "layouts/header/default", locals: { project: @project, group: @group }
- = render 'shared/outdated_browser'
.mobile-overlay
.alert-wrapper
+ = render 'shared/outdated_browser'
= render "layouts/broadcast"
= yield :flash_message
= render "layouts/flash"
diff --git a/app/views/shared/_outdated_browser.html.haml b/app/views/shared/_outdated_browser.html.haml
index 8ddb1b2bc99..30255e18f04 100644
--- a/app/views/shared/_outdated_browser.html.haml
+++ b/app/views/shared/_outdated_browser.html.haml
@@ -1,8 +1,15 @@
- if outdated_browser?
- .flash-container
- .flash-alert.text-center
- GitLab may not work properly because you are using an outdated web browser.
+ .gl-alert.gl-alert-danger.outdated-browser{ :role => "alert" }
+ = sprite_icon('error', size: 16, css_class: "gl-alert-icon gl-alert-icon-no-title gl-icon")
+ .gl-alert-body
+ - if browser.ie? && browser.version.to_i == 11
+ - feedback_link_url = 'https://gitlab.com/gitlab-org/gitlab/issues/197987'
+ - feedback_link_start = '<a href="%{url}" class="gl-link" target="_blank" rel="noopener noreferrer">'.html_safe % { url: feedback_link_url }
+ = s_('OutdatedBrowser|From May 2020 GitLab no longer supports Internet Explorer 11.')
+ %br
+ = s_('OutdatedBrowser|You can provide feedback %{feedback_link_start}on this issue%{feedback_link_end} or via your usual support channels.').html_safe % { feedback_link_start: feedback_link_start, feedback_link_end: '</a>'.html_safe }
+ - else
+ = s_('OutdatedBrowser|GitLab may not work properly, because you are using an outdated web browser.')
%br
- Please install a
- = link_to 'supported web browser', help_page_path('install/requirements', anchor: 'supported-web-browsers')
- for a better experience.
+ - browser_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_path('install/requirements', anchor: 'supported-web-browsers') }
+ = s_('OutdatedBrowser|Please install a %{browser_link_start}supported web browser%{browser_link_end} for a better experience.').html_safe % { browser_link_start: browser_link_start, browser_link_end: '</a>'.html_safe }