Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
30b8ad35fe
commit
8f57ac0a38
|
@ -283,9 +283,9 @@ function updateText({ textArea, tag, cursorOffset, blockTag, wrap, select, tagCo
|
|||
|
||||
/* eslint-disable @gitlab/require-i18n-strings */
|
||||
export function keypressNoteText(e) {
|
||||
if (this.selectionStart === this.selectionEnd) {
|
||||
return;
|
||||
}
|
||||
if (!gon.markdown_surround_selection) return;
|
||||
if (this.selectionStart === this.selectionEnd) return;
|
||||
|
||||
const keys = {
|
||||
'*': '**{text}**', // wraps with bold character
|
||||
_: '_{text}_', // wraps with italic character
|
||||
|
|
|
@ -49,7 +49,8 @@ class Profiles::PreferencesController < Profiles::ApplicationController
|
|||
:tab_width,
|
||||
:sourcegraph_enabled,
|
||||
:gitpod_enabled,
|
||||
:render_whitespace_in_code
|
||||
:render_whitespace_in_code,
|
||||
:markdown_surround_selection
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -294,6 +294,7 @@ class User < ApplicationRecord
|
|||
:setup_for_company, :setup_for_company=,
|
||||
:render_whitespace_in_code, :render_whitespace_in_code=,
|
||||
:experience_level, :experience_level=,
|
||||
:markdown_surround_selection, :markdown_surround_selection=,
|
||||
to: :user_preference
|
||||
|
||||
delegate :path, to: :namespace, allow_nil: true, prefix: true
|
||||
|
|
|
@ -27,6 +27,7 @@ class UserPreference < ApplicationRecord
|
|||
default_value_for :time_display_relative, value: true, allows_nil: false
|
||||
default_value_for :time_format_in_24h, value: false, allows_nil: false
|
||||
default_value_for :render_whitespace_in_code, value: false, allows_nil: false
|
||||
default_value_for :markdown_surround_selection, value: true, allows_nil: false
|
||||
|
||||
class << self
|
||||
def notes_filters
|
||||
|
|
|
@ -88,6 +88,15 @@
|
|||
= s_("Preferences|Show one file at a time on merge request's Changes tab")
|
||||
.form-text.text-muted
|
||||
= s_("Preferences|Instead of all the files changed, show only one file at a time. To switch between files, use the file browser.")
|
||||
.form-group.form-check
|
||||
= f.check_box :markdown_surround_selection, class: 'form-check-input'
|
||||
= f.label :markdown_surround_selection, class: 'form-check-label' do
|
||||
= s_('Preferences|Surround text selection when typing quotes or brackets')
|
||||
.form-text.text-muted
|
||||
- supported_characters = %w(" ' ` \( [ { < * _).map {|char| "<code>#{char}</code>" }.join(', ')
|
||||
- msg = "Preferences|When you type in a description or comment box, selected text is surrounded by the corresponding character after typing one of the following characters: #{supported_characters}."
|
||||
= s_(msg).html_safe
|
||||
|
||||
.form-group
|
||||
= f.label :tab_width, s_('Preferences|Tab width'), class: 'label-bold'
|
||||
= f.number_field :tab_width,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Add user preference to turn off selected text keystroke formatting
|
||||
merge_request: 53079
|
||||
author:
|
||||
type: added
|
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMarkdownSurroundSelectionToUserPreferences < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :user_preferences, :markdown_surround_selection, :boolean, default: true, null: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :user_preferences, :markdown_surround_selection, :boolean
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
484751de711e873e0f0f22d5951e36bf60d4826ebc95afa45e4f6cdaa0e3c024
|
|
@ -17928,7 +17928,8 @@ CREATE TABLE user_preferences (
|
|||
tab_width smallint,
|
||||
experience_level smallint,
|
||||
view_diffs_file_by_file boolean DEFAULT false NOT NULL,
|
||||
gitpod_enabled boolean DEFAULT false NOT NULL
|
||||
gitpod_enabled boolean DEFAULT false NOT NULL,
|
||||
markdown_surround_selection boolean DEFAULT true NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE user_preferences_id_seq
|
||||
|
|
|
@ -31,6 +31,8 @@ GitLab has been tested on a number of object storage providers:
|
|||
HTTP Range Requests from working with CI job artifacts](https://gitlab.com/gitlab-org/gitlab/-/issues/223806).
|
||||
Be sure to upgrade to GitLab v13.3.0 or above if you use S3 storage with this hardware.
|
||||
|
||||
- Ceph S3 prior to [Kraken 11.0.2](https://ceph.com/releases/kraken-11-0-2-released/) does not support the [Upload Copy Part API](https://gitlab.com/gitlab-org/gitlab/-/issues/300604). You may need to [disable multi-threaded copying](#multi-threaded-copying).
|
||||
|
||||
## Configuration guides
|
||||
|
||||
There are two ways of specifying object storage configuration in GitLab:
|
||||
|
@ -737,7 +739,22 @@ following command:
|
|||
Feature.disable(:use_workhorse_s3_client)
|
||||
```
|
||||
|
||||
#### IAM Permissions
|
||||
### Multi-threaded copying
|
||||
|
||||
GitLab uses the [S3 Upload Part Copy API](https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html)
|
||||
to accelerate the copying of files within a bucket. Ceph S3 [prior to Kraken 11.0.2](https://ceph.com/releases/kraken-11-0-2-released/)
|
||||
does not support this and [returns a 404 error when files are copied during the upload process](https://gitlab.com/gitlab-org/gitlab/-/issues/300604).
|
||||
|
||||
The feature can be disabled using the `:s3_multithreaded_uploads`
|
||||
feature flag. To disable the feature, ask a GitLab administrator with
|
||||
[Rails console access](feature_flags.md#how-to-enable-and-disable-features-behind-flags)
|
||||
to run the following command:
|
||||
|
||||
```ruby
|
||||
Feature.disable(:s3_multithreaded_uploads)
|
||||
```
|
||||
|
||||
### IAM Permissions
|
||||
|
||||
To set up an instance profile:
|
||||
|
||||
|
@ -754,7 +771,6 @@ To set up an instance profile:
|
|||
"Action": [
|
||||
"s3:PutObject",
|
||||
"s3:GetObject",
|
||||
"s3:AbortMultipartUpload",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": "arn:aws:s3:::test-bucket/*"
|
||||
|
|
|
@ -7,13 +7,14 @@ module Gitlab
|
|||
include WebpackHelper
|
||||
|
||||
def add_gon_variables
|
||||
gon.api_version = 'v4'
|
||||
gon.default_avatar_url = default_avatar_url
|
||||
gon.max_file_size = Gitlab::CurrentSettings.max_attachment_size
|
||||
gon.asset_host = ActionController::Base.asset_host
|
||||
gon.webpack_public_path = webpack_public_path
|
||||
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
|
||||
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
|
||||
gon.api_version = 'v4'
|
||||
gon.default_avatar_url = default_avatar_url
|
||||
gon.max_file_size = Gitlab::CurrentSettings.max_attachment_size
|
||||
gon.asset_host = ActionController::Base.asset_host
|
||||
gon.webpack_public_path = webpack_public_path
|
||||
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
|
||||
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
|
||||
gon.markdown_surround_selection = current_user&.markdown_surround_selection
|
||||
|
||||
if Gitlab.config.sentry.enabled
|
||||
gon.sentry_dsn = Gitlab.config.sentry.clientside_dsn
|
||||
|
|
|
@ -22615,6 +22615,9 @@ msgstr ""
|
|||
msgid "Preferences|Sourcegraph"
|
||||
msgstr ""
|
||||
|
||||
msgid "Preferences|Surround text selection when typing quotes or brackets"
|
||||
msgstr ""
|
||||
|
||||
msgid "Preferences|Syntax highlighting theme"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -171,27 +171,40 @@ describe('init markdown', () => {
|
|||
expect(textArea.value).toEqual(text.replace(selected, `[${selected}](url)`));
|
||||
});
|
||||
|
||||
it.each`
|
||||
key | expected
|
||||
${'['} | ${`[${selected}]`}
|
||||
${'*'} | ${`**${selected}**`}
|
||||
${"'"} | ${`'${selected}'`}
|
||||
${'_'} | ${`_${selected}_`}
|
||||
${'`'} | ${`\`${selected}\``}
|
||||
${'"'} | ${`"${selected}"`}
|
||||
${'{'} | ${`{${selected}}`}
|
||||
${'('} | ${`(${selected})`}
|
||||
${'<'} | ${`<${selected}>`}
|
||||
`('generates $expected when $key is pressed', ({ key, expected }) => {
|
||||
const event = new KeyboardEvent('keydown', { key });
|
||||
describe('surrounds selected text with matching character', () => {
|
||||
it.each`
|
||||
key | expected
|
||||
${'['} | ${`[${selected}]`}
|
||||
${'*'} | ${`**${selected}**`}
|
||||
${"'"} | ${`'${selected}'`}
|
||||
${'_'} | ${`_${selected}_`}
|
||||
${'`'} | ${`\`${selected}\``}
|
||||
${'"'} | ${`"${selected}"`}
|
||||
${'{'} | ${`{${selected}}`}
|
||||
${'('} | ${`(${selected})`}
|
||||
${'<'} | ${`<${selected}>`}
|
||||
`('generates $expected when $key is pressed', ({ key, expected }) => {
|
||||
const event = new KeyboardEvent('keydown', { key });
|
||||
gon.markdown_surround_selection = true;
|
||||
|
||||
textArea.addEventListener('keydown', keypressNoteText);
|
||||
textArea.dispatchEvent(event);
|
||||
textArea.addEventListener('keydown', keypressNoteText);
|
||||
textArea.dispatchEvent(event);
|
||||
|
||||
expect(textArea.value).toEqual(text.replace(selected, expected));
|
||||
expect(textArea.value).toEqual(text.replace(selected, expected));
|
||||
|
||||
// cursor placement should be after selection + 2 tag lengths
|
||||
expect(textArea.selectionStart).toBe(selectedIndex + expected.length);
|
||||
// cursor placement should be after selection + 2 tag lengths
|
||||
expect(textArea.selectionStart).toBe(selectedIndex + expected.length);
|
||||
});
|
||||
|
||||
it('does nothing if user preference disabled', () => {
|
||||
const event = new KeyboardEvent('keydown', { key: '[' });
|
||||
gon.markdown_surround_selection = false;
|
||||
|
||||
textArea.addEventListener('keydown', keypressNoteText);
|
||||
textArea.dispatchEvent(event);
|
||||
|
||||
expect(textArea.value).toEqual(text);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and text to be selected', () => {
|
||||
|
|
|
@ -41,6 +41,9 @@ RSpec.describe User do
|
|||
it { is_expected.to delegate_method(:show_whitespace_in_diffs).to(:user_preference) }
|
||||
it { is_expected.to delegate_method(:show_whitespace_in_diffs=).to(:user_preference).with_arguments(:args) }
|
||||
|
||||
it { is_expected.to delegate_method(:view_diffs_file_by_file).to(:user_preference) }
|
||||
it { is_expected.to delegate_method(:view_diffs_file_by_file=).to(:user_preference).with_arguments(:args) }
|
||||
|
||||
it { is_expected.to delegate_method(:tab_width).to(:user_preference) }
|
||||
it { is_expected.to delegate_method(:tab_width=).to(:user_preference).with_arguments(:args) }
|
||||
|
||||
|
@ -59,6 +62,9 @@ RSpec.describe User do
|
|||
it { is_expected.to delegate_method(:experience_level).to(:user_preference) }
|
||||
it { is_expected.to delegate_method(:experience_level=).to(:user_preference).with_arguments(:args) }
|
||||
|
||||
it { is_expected.to delegate_method(:markdown_surround_selection).to(:user_preference) }
|
||||
it { is_expected.to delegate_method(:markdown_surround_selection=).to(:user_preference).with_arguments(:args) }
|
||||
|
||||
it { is_expected.to delegate_method(:job_title).to(:user_detail).allow_nil }
|
||||
it { is_expected.to delegate_method(:job_title=).to(:user_detail).with_arguments(:args).allow_nil }
|
||||
|
||||
|
|
Loading…
Reference in New Issue