Commit 620d296f authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 8be3e23ca0a3
......@@ -6,6 +6,7 @@
<!-- Who will use this feature? If known, include any of the following: types of users (e.g. Developer), personas, or specific company roles (e.g. Release Manager). It's okay to write "Unknown" and fill this field in later.
* [Rachel (Release Manager)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#rachel-release-manager)
* [Parker (Product Manager)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#parker-product-manager)
* [Delaney (Development Team Lead)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#delaney-development-team-lead)
* [Sasha (Software Developer)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#sasha-software-developer)
......
......@@ -32,7 +32,13 @@ export default {
...mapState('rightPane', {
rightPaneIsOpen: 'isOpen',
}),
...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing', 'currentActivityView']),
...mapState([
'rightPanelCollapsed',
'viewer',
'panelResizing',
'currentActivityView',
'renderWhitespaceInCode',
]),
...mapGetters([
'currentMergeRequest',
'getStagedFile',
......@@ -76,6 +82,11 @@ export default {
showEditor() {
return !this.shouldHideEditor && this.isEditorViewMode;
},
editorOptions() {
return {
renderWhitespace: this.renderWhitespaceInCode ? 'all' : 'none',
};
},
},
watch: {
file(newVal, oldVal) {
......@@ -131,7 +142,7 @@ export default {
},
mounted() {
if (!this.editor) {
this.editor = Editor.create();
this.editor = Editor.create(this.editorOptions);
}
this.initEditor();
},
......
......@@ -50,6 +50,7 @@ export function initIde(el, options = {}) {
});
this.setInitialData({
clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled),
renderWhitespaceInCode: parseBoolean(el.dataset.renderWhitespaceInCode),
});
},
methods: {
......
......@@ -23,20 +23,24 @@ export const clearDomElement = el => {
};
export default class Editor {
static create() {
static create(options = {}) {
if (!this.editorInstance) {
this.editorInstance = new Editor();
this.editorInstance = new Editor(options);
}
return this.editorInstance;
}
constructor() {
constructor(options = {}) {
this.currentModel = null;
this.instance = null;
this.dirtyDiffController = null;
this.disposable = new Disposable();
this.modelManager = new ModelManager();
this.decorationsController = new DecorationsController(this);
this.options = {
...defaultEditorOptions,
...options,
};
setupMonacoTheme();
......@@ -51,7 +55,7 @@ export default class Editor {
this.disposable.add(
(this.instance = monacoEditor.create(domElement, {
...defaultEditorOptions,
...this.options,
})),
(this.dirtyDiffController = new DirtyDiffController(
this.modelManager,
......@@ -71,7 +75,7 @@ export default class Editor {
this.disposable.add(
(this.instance = monacoEditor.createDiffEditor(domElement, {
...defaultEditorOptions,
...this.options,
quickSuggestions: false,
occurrencesHighlight: false,
renderSideBySide: Editor.renderSideBySide(domElement),
......
......@@ -31,4 +31,5 @@ export default () => ({
entry: {},
},
clientsidePreviewEnabled: false,
renderWhitespaceInCode: false,
});
......@@ -48,7 +48,8 @@ def preferences_param_names
:time_display_relative,
:time_format_in_24h,
:show_whitespace_in_diffs,
:sourcegraph_enabled
:sourcegraph_enabled,
:render_whitespace_in_code
]
end
end
......
......@@ -10,7 +10,8 @@ def ide_data
"promotion-svg-path": image_path('illustrations/web-ide_promotion.svg'),
"ci-help-page-path" => help_page_path('ci/quick_start/README'),
"web-ide-help-page-path" => help_page_path('user/project/web_ide/index.html'),
"clientside-preview-enabled": Gitlab::CurrentSettings.current_application_settings.web_ide_clientside_preview_enabled.to_s
"clientside-preview-enabled": Gitlab::CurrentSettings.current_application_settings.web_ide_clientside_preview_enabled.to_s,
"render-whitespace-in-code": current_user.render_whitespace_in_code.to_s
}
end
end
......@@ -331,7 +331,7 @@ class Project < ApplicationRecord
delegate :add_guest, :add_reporter, :add_developer, :add_maintainer, :add_role, to: :team
delegate :add_master, to: :team # @deprecated
delegate :group_runners_enabled, :group_runners_enabled=, :group_runners_enabled?, to: :ci_cd_settings
delegate :root_ancestor, :actual_limits, to: :namespace, allow_nil: true
delegate :root_ancestor, to: :namespace, allow_nil: true
delegate :last_pipeline, to: :commit, allow_nil: true
delegate :external_dashboard_url, to: :metrics_setting, allow_nil: true, prefix: true
delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci
......
......@@ -246,6 +246,7 @@ def update_tracked_fields!(request)
delegate :show_whitespace_in_diffs, :show_whitespace_in_diffs=, to: :user_preference
delegate :sourcegraph_enabled, :sourcegraph_enabled=, to: :user_preference
delegate :setup_for_company, :setup_for_company=, to: :user_preference
delegate :render_whitespace_in_code, :render_whitespace_in_code=, to: :user_preference
accepts_nested_attributes_for :user_preference, update_only: true
......
......@@ -13,6 +13,7 @@ class UserPreference < ApplicationRecord
default_value_for :timezone, value: Time.zone.tzinfo.name, allows_nil: false
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
class << self
def notes_filters
......
......@@ -61,10 +61,14 @@
= f.select :project_view, project_view_choices, {}, class: 'select2'
.form-text.text-muted
= s_('Preferences|Choose what content you want to see on a project’s overview page.')
.form-group.form-check
= f.check_box :render_whitespace_in_code, class: 'form-check-input'
= f.label :render_whitespace_in_code, class: 'form-check-label' do
= s_('Preferences|Render whitespace characters in the Web IDE')
.form-group.form-check
= f.check_box :show_whitespace_in_diffs, class: 'form-check-input'
= f.label :show_whitespace_in_diffs, class: 'form-check-label' do
= s_('Preferences|Show whitespace in diffs')
= s_('Preferences|Show whitespace changes in diffs')
.col-sm-12
%hr
......
---
title: Render whitespaces in code
merge_request: 17244
author: Mathieu Parent
type: added
# frozen_string_literal: true
class AddRenderWhitespaceInCodeToUserPreference < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column(:user_preferences, :render_whitespace_in_code, :boolean)
end
def down
remove_column(:user_preferences, :render_whitespace_in_code)
end
end
......@@ -4038,6 +4038,7 @@
t.boolean "show_whitespace_in_diffs", default: true, null: false
t.boolean "sourcegraph_enabled"
t.boolean "setup_for_company"
t.boolean "render_whitespace_in_code"
t.index ["user_id"], name: "index_user_preferences_on_user_id", unique: true
end
......
# Feature Flags **(PREMIUM)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/11845) in GitLab 11.4.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/7433) in GitLab 11.4.
Feature flags allow you to ship a project in different flavors by
dynamically toggling certain functionality.
......
......@@ -13299,7 +13299,10 @@ msgstr ""
msgid "Preferences|Project overview content"
msgstr ""
msgid "Preferences|Show whitespace in diffs"
msgid "Preferences|Render whitespace characters in the Web IDE"
msgstr ""
msgid "Preferences|Show whitespace changes in diffs"
msgstr ""
msgid "Preferences|Sourcegraph"
......@@ -18692,12 +18695,18 @@ msgstr ""
msgid "ThreatMonitoring|A Web Application Firewall (WAF) provides monitoring and rules to protect production applications. GitLab adds the modsecurity WAF plug-in when you install the Ingress app in your Kubernetes cluster."
msgstr ""
msgid "ThreatMonitoring|Anomalous Requests"
msgstr ""
msgid "ThreatMonitoring|At this time, threat monitoring only supports WAF data."
msgstr ""
msgid "ThreatMonitoring|Environment"
msgstr ""
msgid "ThreatMonitoring|Requests"
msgstr ""
msgid "ThreatMonitoring|Something went wrong, unable to fetch WAF statistics"
msgstr ""
......@@ -18713,7 +18722,10 @@ msgstr ""
msgid "ThreatMonitoring|Threat Monitoring help page link"
msgstr ""
msgid "ThreatMonitoring|View WAF documentation"
msgid "ThreatMonitoring|Time"
msgstr ""
msgid "ThreatMonitoring|Total Requests"
msgstr ""
msgid "ThreatMonitoring|Web Application Firewall not enabled"
......@@ -21319,14 +21331,6 @@ msgstr ""
msgid "ciReport|%{reportType} %{status} detected no vulnerabilities for the source branch only"
msgstr ""
msgid "ciReport|%{reportType} detected %{vulnerabilityCount} vulnerability"
msgid_plural "ciReport|%{reportType} detected %{vulnerabilityCount} vulnerabilities"
msgstr[0] ""
msgstr[1] ""
msgid "ciReport|%{reportType} detected no vulnerabilities"
msgstr ""
msgid "ciReport|%{reportType} is loading"
msgstr ""
......@@ -21486,18 +21490,6 @@ msgstr ""
msgid "ciReport|There was an error dismissing the vulnerability. Please try again."
msgstr ""
msgid "ciReport|There was an error loading DAST report"
msgstr ""
msgid "ciReport|There was an error loading SAST report"
msgstr ""
msgid "ciReport|There was an error loading container scanning report"
msgstr ""
msgid "ciReport|There was an error loading dependency scanning report"
msgstr ""
msgid "ciReport|There was an error reverting the dismissal. Please try again."
msgstr ""
......
......@@ -146,7 +146,7 @@
"@gitlab/eslint-config": "^2.0.0",
"@gitlab/eslint-plugin-i18n": "^1.1.0",
"@gitlab/eslint-plugin-vue-i18n": "^1.2.0",
"@vue/test-utils": "^1.0.0-beta.25",
"@vue/test-utils": "^1.0.0-beta.30",
"axios-mock-adapter": "^1.15.0",
"babel-jest": "^24.1.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
......@@ -201,7 +201,7 @@
},
"resolutions": {
"vue-jest/ts-jest": "24.0.0",
"monaco-editor" : "0.18.1"
"monaco-editor": "0.18.1"
},
"engines": {
"node": ">=8.10.0",
......
......@@ -46,7 +46,8 @@ def go(params: {}, format: :js)
dashboard: 'stars',
theme_id: '2',
first_day_of_week: '1',
preferred_language: 'jp'
preferred_language: 'jp',
render_whitespace_in_code: 'true'
}.with_indifferent_access
expect(user).to receive(:assign_attributes).with(ActionController::Parameters.new(prefs).permit!)
......
......@@ -86,6 +86,23 @@
end
end
describe 'User changes whitespace in code' do
it 'updates their preference' do
expect(user.render_whitespace_in_code).to be(false)
expect(render_whitespace_field).not_to be_checked
render_whitespace_field.click
click_button 'Save changes'
expect(user.reload.render_whitespace_in_code).to be(true)
expect(render_whitespace_field).to be_checked
end
end
def render_whitespace_field
find_field('user[render_whitespace_in_code]')
end
def expect_preferences_saved_message
page.within('.flash-container') do
expect(page).to have_content('Preferences saved.')
......
......@@ -5,7 +5,7 @@ exports[`Branch divergence graph component renders ahead and behind count 1`] =
class="divergence-graph px-2 d-none d-md-block"
title="10 commits behind master, 10 commits ahead"
>
<graphbar-stub
<graph-bar-stub
count="10"
maxcommits="100"
position="left"
......@@ -15,7 +15,7 @@ exports[`Branch divergence graph component renders ahead and behind count 1`] =
class="graph-separator pull-left mt-1"
/>
<graphbar-stub
<graph-bar-stub
count="10"
maxcommits="100"
position="right"
......@@ -28,7 +28,7 @@ exports[`Branch divergence graph component renders distance count 1`] = `
class="divergence-graph px-2 d-none d-md-block"
title="More than 900 commits different with master"
>
<graphbar-stub
<graph-bar-stub
count="900"
maxcommits="100"
position="full"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment