Commit effa7025 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 5238f517eeb4
......@@ -235,12 +235,6 @@ RSpec/FactoriesInMigrationSpecs:
- 'spec/lib/ee/gitlab/background_migration/**/*.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/**/*.rb'
Cop/IncludeActionViewContext:
Enabled: true
Exclude:
- 'spec/**/*'
- 'ee/spec/**/*'
Cop/IncludeSidekiqWorker:
Enabled: true
Exclude:
......
source 'https://rubygems.org'
gem 'rails', '5.2.3'
gem 'rails', '6.0.2'
gem 'bootsnap', '~> 1.4'
......@@ -305,7 +305,7 @@ gem 'gitlab-labkit', '0.9.1'
# I18n
gem 'ruby_parser', '~> 3.8', require: false
gem 'rails-i18n', '~> 5.1'
gem 'rails-i18n', '~> 6.0'
gem 'gettext_i18n_rails', '~> 1.8.0'
gem 'gettext_i18n_rails_js', '~> 1.3'
gem 'gettext', '~> 3.2.2', require: false, group: :development
......@@ -332,6 +332,7 @@ group :metrics do
end
group :development do
gem 'listen', '~> 3.0'
gem 'brakeman', '~> 4.2', require: false
gem 'danger', '~> 6.0', require: false
......
......@@ -6,50 +6,64 @@ GEM
ace-rails-ap (4.1.2)
acme-client (2.0.5)
faraday (~> 0.9, >= 0.9.1)
actioncable (5.2.3)
actionpack (= 5.2.3)
actioncable (6.0.2)
actionpack (= 6.0.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
actionmailbox (6.0.2)
actionpack (= 6.0.2)
activejob (= 6.0.2)
activerecord (= 6.0.2)
activestorage (= 6.0.2)
activesupport (= 6.0.2)
mail (>= 2.7.1)
actionmailer (6.0.2)
actionpack (= 6.0.2)
actionview (= 6.0.2)
activejob (= 6.0.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
actionpack (6.0.2)
actionview (= 6.0.2)
activesupport (= 6.0.2)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.3)
activesupport (= 5.2.3)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.2)
actionpack (= 6.0.2)
activerecord (= 6.0.2)
activestorage (= 6.0.2)
activesupport (= 6.0.2)
nokogiri (>= 1.8.5)
actionview (6.0.2)
activesupport (= 6.0.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.3)
activesupport (= 5.2.3)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.2)
activesupport (= 6.0.2)
globalid (>= 0.3.6)
activemodel (5.2.3)
activesupport (= 5.2.3)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activemodel (6.0.2)
activesupport (= 6.0.2)
activerecord (6.0.2)
activemodel (= 6.0.2)
activesupport (= 6.0.2)
activerecord-explain-analyze (0.1.0)
activerecord (>= 4)
pg
activestorage (5.2.3)
actionpack (= 5.2.3)
activerecord (= 5.2.3)
activestorage (6.0.2)
actionpack (= 6.0.2)
activejob (= 6.0.2)
activerecord (= 6.0.2)
marcel (~> 0.3.1)
activesupport (5.2.3)
activesupport (6.0.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
acts-as-taggable-on (6.5.0)
activerecord (>= 5.0, < 6.1)
adamantium (0.2.0)
......@@ -62,7 +76,6 @@ GEM
apollo_upload_server (2.0.0.beta.3)
graphql (>= 1.8)
rails (>= 4.2)
arel (9.0.0)
asana (0.9.3)
faraday (~> 0.9)
faraday_middleware (~> 0.9)
......@@ -198,13 +211,14 @@ GEM
declarative-option (0.1.0)
default_value_for (3.3.0)
activerecord (>= 3.2.0, < 6.1)
derailed_benchmarks (1.3.5)
derailed_benchmarks (1.4.2)
benchmark-ips (~> 2)
get_process_mem (~> 0)
heapy (~> 0)
memory_profiler (~> 0)
rack (>= 1)
rake (> 10, < 13)
rake (> 10, < 14)
ruby-statistics (>= 2.1)
thor (~> 0.19)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
......@@ -348,7 +362,8 @@ GEM
gemoji (3.0.1)
gemojione (3.3.0)
json
get_process_mem (0.2.3)
get_process_mem (0.2.5)
ffi (~> 1.0)
gettext (3.2.9)
locale (>= 2.0.5)
text (>= 1.3.0)
......@@ -434,8 +449,9 @@ GEM
activesupport
grape (~> 1.0)
rake (~> 12)
grape_logging (1.7.0)
grape_logging (1.8.3)
grape
rack
graphiql-rails (1.4.10)
railties
sprockets-rails
......@@ -510,7 +526,7 @@ GEM
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.7.1)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
icalendar (2.4.1)
......@@ -609,12 +625,12 @@ GEM
memoist (0.16.0)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
memory_profiler (0.9.13)
memory_profiler (0.9.14)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
mimemagic (0.3.2)
mimemagic (0.3.3)
mini_magick (4.9.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
......@@ -787,18 +803,20 @@ GEM
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack-timeout (0.5.1)
rails (5.2.3)
actioncable (= 5.2.3)
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activestorage (= 5.2.3)
activesupport (= 5.2.3)
rails (6.0.2)
actioncable (= 6.0.2)
actionmailbox (= 6.0.2)
actionmailer (= 6.0.2)
actionpack (= 6.0.2)
actiontext (= 6.0.2)
actionview (= 6.0.2)
activejob (= 6.0.2)
activemodel (= 6.0.2)
activerecord (= 6.0.2)
activestorage (= 6.0.2)
activesupport (= 6.0.2)
bundler (>= 1.3.0)
railties (= 5.2.3)
railties (= 6.0.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
......@@ -809,15 +827,15 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (5.1.1)
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
railties (>= 6.0.0, < 7)
railties (6.0.2)
actionpack (= 6.0.2)
activesupport (= 6.0.2)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.3)
......@@ -937,6 +955,7 @@ GEM
ruby-progressbar (1.10.1)
ruby-saml (1.7.2)
nokogiri (>= 1.5.10)
ruby-statistics (2.1.1)
ruby_dep (1.5.0)
ruby_parser (3.13.1)
sexp_processor (~> 4.9)
......@@ -1111,9 +1130,9 @@ GEM
hashdiff
webpack-rails (0.9.11)
railties (>= 3.2.0)
websocket-driver (0.7.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.4)
wikicloth (0.8.1)
builder
expression_parser
......@@ -1122,6 +1141,7 @@ GEM
xml-simple (1.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.2.2)
PLATFORMS
ruby
......@@ -1259,6 +1279,7 @@ DEPENDENCIES
license_finder (~> 5.4)
licensee (~> 8.9)
liquid (~> 4.0)
listen (~> 3.0)
lograge (~> 0.5)
loofah (~> 2.2)
lru_redux
......@@ -1309,9 +1330,9 @@ DEPENDENCIES
rack-oauth2 (~> 1.9.3)
rack-proxy (~> 0.6.0)
rack-timeout
rails (= 5.2.3)
rails (= 6.0.2)
rails-controller-testing
rails-i18n (~> 5.1)
rails-i18n (~> 6.0)
rainbow (~> 3.0)
raindrops (~> 0.18)
rblineprof (~> 0.3.6)
......
import { editor as monacoEditor, languages as monacoLanguages, Uri } from 'monaco-editor';
import gitlabTheme from '~/ide/lib/themes/gl_theme';
import { defaultEditorOptions } from '~/ide/lib/editor_options';
import { clearDomElement } from './utils';
export default class Editor {
constructor(options = {}) {
this.editorEl = null;
this.blobContent = '';
this.blobPath = '';
this.instance = null;
this.model = null;
this.options = {
...defaultEditorOptions,
...options,
};
Editor.setupMonacoTheme();
}
static setupMonacoTheme() {
monacoEditor.defineTheme(gitlabTheme.themeName, gitlabTheme.monacoTheme);
monacoEditor.setTheme('gitlab');
}
createInstance({ el = undefined, blobPath = '', blobContent = '' } = {}) {
if (!el) return;
this.editorEl = el;
this.blobContent = blobContent;
this.blobPath = blobPath;
clearDomElement(this.editorEl);
this.model = monacoEditor.createModel(
this.blobContent,
undefined,
new Uri('gitlab', false, this.blobPath),
);
monacoEditor.onDidCreateEditor(this.renderEditor.bind(this));
this.instance = monacoEditor.create(this.editorEl, this.options);
this.instance.setModel(this.model);
}
dispose() {
return this.instance && this.instance.dispose();
}
renderEditor() {
delete this.editorEl.dataset.editorLoading;
}
updateModelLanguage(path) {
if (path === this.blobPath) return;
this.blobPath = path;
const ext = `.${path.split('.').pop()}`;
const language = monacoLanguages
.getLanguages()
.find(lang => lang.extensions.indexOf(ext) !== -1);
const id = language ? language.id : 'plaintext';
monacoEditor.setModelLanguage(this.model, id);
}
getValue() {
return this.model.getValue();
}
}
export const clearDomElement = el => {
if (!el || !el.firstChild) return;
while (el.firstChild) {
el.removeChild(el.firstChild);
}
};
export default () => ({
clearDomElement,
});
......@@ -8,20 +8,13 @@ import ModelManager from './common/model_manager';
import editorOptions, { defaultEditorOptions } from './editor_options';
import gitlabTheme from './themes/gl_theme';
import keymap from './keymap.json';
import { clearDomElement } from '~/editor/utils';
function setupMonacoTheme() {
monacoEditor.defineTheme(gitlabTheme.themeName, gitlabTheme.monacoTheme);
monacoEditor.setTheme('gitlab');
}
export const clearDomElement = el => {
if (!el || !el.firstChild) return;
while (el.firstChild) {
el.removeChild(el.firstChild);
}
};
export default class Editor {
static create(options = {}) {
if (!this.editorInstance) {
......
......@@ -41,7 +41,7 @@ export default {
changedIcon() {
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
const suffix = !this.file.changed && this.file.staged && this.showStagedIcon ? '-solid' : '';
const suffix = this.file.staged && this.showStagedIcon ? '-solid' : '';
return `${getCommitIconMap(this.file).icon}${suffix}`;
},
......@@ -49,25 +49,19 @@ export default {
return `${this.changedIcon} float-left d-block`;
},
tooltipTitle() {
if (!this.showTooltip) return undefined;
if (!this.showTooltip || !this.file.changed) return undefined;
const type = this.file.tempFile ? 'addition' : 'modification';
if (this.file.changed && !this.file.staged) {
return sprintf(__('Unstaged %{type}'), {
type,
});
} else if (!this.file.changed && this.file.staged) {
if (this.file.staged) {
return sprintf(__('Staged %{type}'), {
type,
});
} else if (this.file.changed && this.file.staged) {
return sprintf(__('Unstaged and staged %{type}'), {
type,
});
}
return undefined;
return sprintf(__('Unstaged %{type}'), {
type,
});
},
showIcon() {
return (
......
......@@ -21,10 +21,6 @@
margin-left: 8px;
}
.btn-group {
margin-left: 10px;
}
.control {
float: left;
margin-left: 10px;
......
......@@ -120,7 +120,7 @@ def route_not_found
def render(*args)
super.tap do
# Set a header for custom error pages to prevent them from being intercepted by gitlab-workhorse
if (400..599).cover?(response.status) && workhorse_excluded_content_types.include?(response.content_type)
if (400..599).cover?(response.status) && workhorse_excluded_content_types.include?(response.media_type)
response.headers['X-GitLab-Custom-Error'] = '1'
end
end
......
......@@ -21,9 +21,9 @@ def update
member = Members::UpdateService
.new(current_user, update_params)
.execute(member)
.present(current_user: current_user)
present_members([member])
member = present_members([member]).first
respond_to do |format|
format.js { render 'shared/members/update', locals: { member: member } }
end
......
......@@ -3,7 +3,7 @@
module SendFileUpload
def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, proxy: false, disposition: 'attachment')
if attachment
response_disposition = ::Gitlab::ContentDisposition.format(disposition: disposition, filename: attachment)
response_disposition = ActionDispatch::Http::ContentDisposition.format(disposition: disposition, filename: attachment)
# Response-Content-Type will not override an existing Content-Type in
# Google Cloud Storage, so the metadata needs to be cleared on GCS for
......@@ -15,7 +15,7 @@ def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: n
# cross-origin JavaScript protection.
send_params[:content_type] = 'text/plain' if File.extname(attachment) == '.js'
send_params.merge!(filename: attachment, disposition: utf8_encoded_disposition(disposition, attachment))
send_params.merge!(filename: attachment, disposition: disposition)
end
if file_upload.file_storage?
......@@ -28,18 +28,6 @@ def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: n
end
end
# Since Rails 5 doesn't properly support support non-ASCII filenames,
# we have to add our own to ensure RFC 5987 compliance. However, Rails
# 5 automatically appends `filename#{filename}` here:
# https://github.com/rails/rails/blob/v5.0.7/actionpack/lib/action_controller/metal/data_streaming.rb#L137
# Rails 6 will have https://github.com/rails/rails/pull/33829, so we
# can get rid of this special case handling when we upgrade.
def utf8_encoded_disposition(disposition, filename)
content = ::Gitlab::ContentDisposition.new(disposition: disposition, filename: filename)
"#{disposition}; #{content.utf8_filename}"
end
def guess_content_type(filename)
types = MIME::Types.type_for(filename)
......
......@@ -3,11 +3,12 @@
class Projects::ReleasesController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project, except: [:index]
before_action :release, only: %i[edit update]
before_action :release, only: %i[edit show update]
before_action :authorize_read_release!
before_action do
push_frontend_feature_flag(:release_issue_summary, project)
push_frontend_feature_flag(:release_evidence_collection, project, default_enabled: true)
push_frontend_feature_flag(:release_show_page, project)
end
before_action :authorize_update_release!, only: %i[edit update]
before_action :authorize_read_release_evidence!, only: [:evidence]
......@@ -29,6 +30,16 @@ def evidence
end
end
def show
return render_404 unless Feature.enabled?(:release_show_page, project)
respond_to do |format|
format.html do
render :show
end
end
end
protected
def releases
......@@ -37,7 +48,9 @@ def releases
def edit
respond_to do |format|
format.html { render 'edit' }
format.html do
render :edit
end
end
end
......
......@@ -4,7 +4,7 @@
module MarkupHelper
include ActionView::Helpers::TextHelper
include ::Gitlab::ActionViewOutput::Context
include ActionView::Context
def plain?(filename)
Gitlab::MarkupHelper.plain?(filename)
......
......@@ -200,6 +200,10 @@ def self.update_as_processed!
update_all('processed=TRUE, lock_version=COALESCE(lock_version,0)+1')
end
def self.locking_enabled?
false
end
def locking_enabled?
will_save_change_to_status?
end
......
......@@ -130,6 +130,10 @@ def award_emojis_loaded?
strip_attributes :title
def self.locking_enabled?
false
end
# We want to use optimistic lock for cases when only title or description are involved
# http://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html
def locking_enabled?
......
......@@ -37,6 +37,8 @@ def credentials_field(name, reader: true)
end
define_method("#{name}=") do |value|
credentials_will_change!
self.credentials ||= {}
# Removal of the password, username, etc, generally causes an update of
......
......@@ -712,7 +712,7 @@ def validate_branches
end
def validate_branch_name(attr)
return unless changes_include?(attr)
return unless will_save_change_to_attribute?(attr)
branch = read_attribute(attr)
......
......@@ -21,7 +21,10 @@ class NotificationSetting < ApplicationRecord
# pending delete).
#
scope :for_projects, -> do
includes(:project).references(:projects).where(source_type: 'Project').where.not(projects: { id: nil, pending_delete: true })
includes(:project).references(:projects)
.where(source_type: 'Project')
.where.not(projects: { id: nil })
.where.not(projects: { pending_delete: true })
end
EMAIL_EVENTS = [
......
......@@ -208,7 +208,7 @@ def new_file_anchor_data
AnchorData.new(false,
statistic_icon + _('New file'),
project_new_blob_path(project, default_branch || 'master'),
'success')
'missing')