Commit bfa4e0b4 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@13-4-stable-ee

parent 6689552c
<script> <script>
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { GlButton, GlLoadingIcon, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui'; import { GlLoadingIcon, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { hasDiff } from '~/helpers/diffs_helper'; import { hasDiff } from '~/helpers/diffs_helper';
import eventHub from '../../notes/event_hub'; import eventHub from '../../notes/event_hub';
import DiffFileHeader from './diff_file_header.vue'; import DiffFileHeader from './diff_file_header.vue';
import DiffContent from './diff_content.vue'; import DiffContent from './diff_content.vue';
import { diffViewerErrors } from '~/ide/constants'; import { diffViewerErrors } from '~/ide/constants';
import { GENERIC_ERROR, DIFF_FILE } from '../i18n';
export default { export default {
components: { components: {
DiffFileHeader, DiffFileHeader,
DiffContent, DiffContent,
GlButton,
GlLoadingIcon, GlLoadingIcon,
}, },
directives: { directives: {
SafeHtml, SafeHtml,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
i18n: {
genericError: GENERIC_ERROR,
...DIFF_FILE,
},
props: { props: {
file: { file: {
type: Object, type: Object,
...@@ -59,7 +53,7 @@ export default { ...@@ -59,7 +53,7 @@ export default {
...mapGetters('diffs', ['getDiffFileDiscussions']), ...mapGetters('diffs', ['getDiffFileDiscussions']),
viewBlobLink() { viewBlobLink() {
return sprintf( return sprintf(
this.$options.i18n.blobView, __('You can %{linkStart}view the blob%{linkEnd} instead.'),
{ {
linkStart: `<a href="${escape(this.file.view_path)}">`, linkStart: `<a href="${escape(this.file.view_path)}">`,
linkEnd: '</a>', linkEnd: '</a>',
...@@ -81,7 +75,9 @@ export default { ...@@ -81,7 +75,9 @@ export default {
}, },
forkMessage() { forkMessage() {
return sprintf( return sprintf(
this.$options.i18n.editInFork, __(
"You're not allowed to %{tag_start}edit%{tag_end} files in this project directly. Please fork this project, make your changes there, and submit a merge request.",
),
{ {
tag_start: '<span class="js-file-fork-suggestion-section-action">', tag_start: '<span class="js-file-fork-suggestion-section-action">',
tag_end: '</span>', tag_end: '</span>',
...@@ -152,7 +148,7 @@ export default { ...@@ -152,7 +148,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.isLoadingCollapsedDiff = false; this.isLoadingCollapsedDiff = false;
createFlash(this.$options.i18n.genericError); createFlash(__('Something went wrong on our end. Please try again!'));
}); });
}, },
showForkMessage() { showForkMessage() {
...@@ -192,14 +188,14 @@ export default { ...@@ -192,14 +188,14 @@ export default {
<a <a
:href="file.fork_path" :href="file.fork_path"
class="js-fork-suggestion-button btn btn-grouped btn-inverted btn-success" class="js-fork-suggestion-button btn btn-grouped btn-inverted btn-success"
>{{ $options.i18n.fork }}</a >{{ __('Fork') }}</a
> >
<button <button
class="js-cancel-fork-suggestion-button btn btn-grouped" class="js-cancel-fork-suggestion-button btn btn-grouped"
type="button" type="button"
@click="hideForkMessage" @click="hideForkMessage"
> >
{{ $options.i18n.cancel }} {{ __('Cancel') }}
</button> </button>
</div> </div>
<gl-loading-icon v-if="showLoadingIcon" class="diff-content loading" /> <gl-loading-icon v-if="showLoadingIcon" class="diff-content loading" />
...@@ -209,17 +205,11 @@ export default { ...@@ -209,17 +205,11 @@ export default {
<div v-safe-html="errorMessage" class="nothing-here-block"></div> <div v-safe-html="errorMessage" class="nothing-here-block"></div>
</div> </div>
<template v-else> <template v-else>
<div v-show="isCollapsed" class="gl-p-7 gl-text-center collapsed-file-warning"> <div v-show="isCollapsed" class="nothing-here-block diff-collapsed">
<p class="gl-mb-8 gl-mt-5"> {{ __('This diff is collapsed.') }}
{{ $options.i18n.collapsed }} <a class="click-to-expand js-click-to-expand" href="#" @click.prevent="handleToggle">{{
</p> __('Click to expand it.')
<gl-button }}</a>
class="gl-alert-action gl-mb-5"
data-testid="expandButton"
@click="handleToggle"
>
{{ $options.i18n.expand }}
</gl-button>
</div> </div>
<diff-content <diff-content
v-show="!isCollapsed && !isFileTooLarge" v-show="!isCollapsed && !isFileTooLarge"
......
import { __ } from '~/locale';
export const GENERIC_ERROR = __('Something went wrong on our end. Please try again!');
export const DIFF_FILE = {
blobView: __('You can %{linkStart}view the blob%{linkEnd} instead.'),
editInFork: __(
"You're not allowed to %{tag_start}edit%{tag_end} files in this project directly. Please fork this project, make your changes there, and submit a merge request.",
),
fork: __('Fork'),
cancel: __('Cancel'),
collapsed: __('This file is collapsed.'),
expand: __('Expand file'),
};
---
title: Fix rollback portion of migration that adds temporary index for container scanning findings
merge_request: 44593
author:
type: fixed
---
title: 'Revert 42465 and 42343: Expanded collapsed diff files'
merge_request: 43361
author:
type: other
---
title: Improve merge error when pre-receive hooks fail in fast-forward merge
merge_request: 44843
author:
type: fixed
...@@ -15,6 +15,6 @@ class AddIndexToContainerScanningFindings < ActiveRecord::Migration[6.0] ...@@ -15,6 +15,6 @@ class AddIndexToContainerScanningFindings < ActiveRecord::Migration[6.0]
end end
def down def down
remove_concurrent_index_by_name(:project_registry, INDEX_NAME) remove_concurrent_index_by_name(:vulnerability_occurrences, INDEX_NAME)
end end
end end
...@@ -18,13 +18,15 @@ module Gitlab ...@@ -18,13 +18,15 @@ module Gitlab
attr_reader :raw_message attr_reader :raw_message
def initialize(message = '', user_message = '') def initialize(message = '', fallback_message: '')
@raw_message = message @raw_message = message
if user_message.present? sanitized_msg = sanitize(message)
super(sanitize(user_message))
if sanitized_msg.present?
super(sanitized_msg)
else else
super(sanitize(message)) super(fallback_message)
end end
end end
......
...@@ -179,7 +179,7 @@ module Gitlab ...@@ -179,7 +179,7 @@ module Gitlab
) )
if response.pre_receive_error.present? if response.pre_receive_error.present?
raise Gitlab::Git::PreReceiveError.new(response.pre_receive_error, "GL-HOOK-ERR: pre-receive hook failed.") raise Gitlab::Git::PreReceiveError.new(response.pre_receive_error, fallback_message: "pre-receive hook failed.")
end end
Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update) Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update)
......
...@@ -10364,9 +10364,6 @@ msgstr "" ...@@ -10364,9 +10364,6 @@ msgstr ""
msgid "Expand approvers" msgid "Expand approvers"
msgstr "" msgstr ""
msgid "Expand file"
msgstr ""
msgid "Expand milestones" msgid "Expand milestones"
msgstr "" msgstr ""
...@@ -25857,9 +25854,6 @@ msgstr "" ...@@ -25857,9 +25854,6 @@ msgstr ""
msgid "This field is required." msgid "This field is required."
msgstr "" msgstr ""
msgid "This file is collapsed."
msgstr ""
msgid "This group" msgid "This group"
msgstr "" msgstr ""
......
...@@ -14,11 +14,11 @@ RSpec.describe 'User expands diff', :js do ...@@ -14,11 +14,11 @@ RSpec.describe 'User expands diff', :js do
it 'allows user to expand diff' do it 'allows user to expand diff' do
page.within find('[id="19763941ab80e8c09871c0a425f0560d9053bcb3"]') do page.within find('[id="19763941ab80e8c09871c0a425f0560d9053bcb3"]') do
find('[data-testid="expandButton"]').click click_link 'Click to expand it.'
wait_for_requests wait_for_requests
expect(page).not_to have_content('Expand File') expect(page).not_to have_content('Click to expand it.')
expect(page).to have_selector('.code') expect(page).to have_selector('.code')
end end
end end
......
...@@ -90,8 +90,8 @@ describe('DiffFile', () => { ...@@ -90,8 +90,8 @@ describe('DiffFile', () => {
vm.isCollapsed = true; vm.isCollapsed = true;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.innerText).toContain('This file is collapsed.'); expect(vm.$el.innerText).toContain('This diff is collapsed');
expect(vm.$el.querySelector('[data-testid="expandButton"]')).not.toBeFalsy(); expect(vm.$el.querySelectorAll('.js-click-to-expand').length).toEqual(1);
done(); done();
}); });
...@@ -102,8 +102,8 @@ describe('DiffFile', () => { ...@@ -102,8 +102,8 @@ describe('DiffFile', () => {
vm.isCollapsed = true; vm.isCollapsed = true;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.innerText).toContain('This file is collapsed.'); expect(vm.$el.innerText).toContain('This diff is collapsed');
expect(vm.$el.querySelector('[data-testid="expandButton"]')).not.toBeFalsy(); expect(vm.$el.querySelectorAll('.js-click-to-expand').length).toEqual(1);
done(); done();
}); });
...@@ -121,8 +121,8 @@ describe('DiffFile', () => { ...@@ -121,8 +121,8 @@ describe('DiffFile', () => {
vm.isCollapsed = true; vm.isCollapsed = true;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.innerText).toContain('This file is collapsed.'); expect(vm.$el.innerText).toContain('This diff is collapsed');
expect(vm.$el.querySelector('[data-testid="expandButton"]')).not.toBeFalsy(); expect(vm.$el.querySelectorAll('.js-click-to-expand').length).toEqual(1);
done(); done();
}); });
...@@ -135,7 +135,7 @@ describe('DiffFile', () => { ...@@ -135,7 +135,7 @@ describe('DiffFile', () => {
vm.file.viewer.name = diffViewerModes.renamed; vm.file.viewer.name = diffViewerModes.renamed;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.innerText).not.toContain('This file is collapsed.'); expect(vm.$el.innerText).not.toContain('This diff is collapsed');
done(); done();
}); });
...@@ -148,7 +148,7 @@ describe('DiffFile', () => { ...@@ -148,7 +148,7 @@ describe('DiffFile', () => {
vm.file.viewer.name = diffViewerModes.mode_changed; vm.file.viewer.name = diffViewerModes.mode_changed;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.innerText).not.toContain('This file is collapsed.'); expect(vm.$el.innerText).not.toContain('This diff is collapsed');
done(); done();
}); });
......
...@@ -21,13 +21,21 @@ RSpec.describe Gitlab::Git::PreReceiveError do ...@@ -21,13 +21,21 @@ RSpec.describe Gitlab::Git::PreReceiveError do
expect(ex.raw_message).to eq(raw_message) expect(ex.raw_message).to eq(raw_message)
end end
it 'sanitizes the user message' do it 'prefers the original message over the fallback' do
raw_message = 'Raw message' raw_message = "#{prefix} Hello,\nworld!"
ex = described_class.new(raw_message, "#{prefix} User message") ex = described_class.new(raw_message, fallback_message: "User message")
expect(ex.message).to eq('Hello,')
expect(ex.raw_message).to eq(raw_message) expect(ex.raw_message).to eq(raw_message)
expect(ex.message).to eq('User message')
end end
end end
it 'uses the fallback message' do
raw_message = 'Hello\n'
ex = described_class.new(raw_message, fallback_message: "User message")
expect(ex.raw_message).to eq(raw_message)
expect(ex.message).to eq('User message')
end
end end
end end
...@@ -116,7 +116,7 @@ RSpec.describe MergeRequests::FfMergeService do ...@@ -116,7 +116,7 @@ RSpec.describe MergeRequests::FfMergeService do
error_message = 'error message' error_message = 'error message'
raw_message = 'The truth is out there' raw_message = 'The truth is out there'
pre_receive_error = Gitlab::Git::PreReceiveError.new(raw_message, "GitLab: #{error_message}") pre_receive_error = Gitlab::Git::PreReceiveError.new(raw_message, fallback_message: error_message)
allow(service).to receive(:repository).and_raise(pre_receive_error) allow(service).to receive(:repository).and_raise(pre_receive_error)
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
expect(Gitlab::ErrorTracking).to receive(:track_exception).with( expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
......
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