Commit 06be418a authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent eb1f5a3e
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
*/ */
import FileRow from '~/vue_shared/components/file_row.vue'; import FileRow from '~/vue_shared/components/file_row.vue';
import FileRowStats from './file_row_stats.vue'; import FileRowStats from './file_row_stats.vue';
import ChangedFileIcon from '~/vue_shared/components/changed_file_icon.vue';
export default { export default {
name: 'DiffFileRow', name: 'DiffFileRow',
components: { components: {
FileRow, FileRow,
FileRowStats, FileRowStats,
ChangedFileIcon,
}, },
props: { props: {
file: { file: {
...@@ -31,7 +33,8 @@ export default { ...@@ -31,7 +33,8 @@ export default {
</script> </script>
<template> <template>
<file-row :file="file" :hide-file-stats="hideFileStats" v-bind="$attrs" v-on="$listeners"> <file-row :file="file" v-bind="$attrs" v-on="$listeners">
<file-row-stats v-if="showFileRowStats" :file="file" /> <file-row-stats v-if="showFileRowStats" :file="file" class="mr-1" />
<changed-file-icon :file="file" :size="16" />
</file-row> </file-row>
</template> </template>
...@@ -95,8 +95,6 @@ export default { ...@@ -95,8 +95,6 @@ export default {
:file="file" :file="file"
:level="0" :level="0"
:hide-file-stats="hideFileStats" :hide-file-stats="hideFileStats"
:hide-extra-on-tree="true"
:show-changed-icon="true"
:file-row-component="$options.DiffFileRow" :file-row-component="$options.DiffFileRow"
@toggleTreeOpen="toggleTreeOpen" @toggleTreeOpen="toggleTreeOpen"
@clickFile="scrollToFile" @clickFile="scrollToFile"
......
...@@ -106,7 +106,7 @@ export default { ...@@ -106,7 +106,7 @@ export default {
saveChangesSelfMonitorProject() { saveChangesSelfMonitorProject() {
if (this.projectCreated && !this.projectEnabled) { if (this.projectCreated && !this.projectEnabled) {
this.showSelfMonitorModal(); this.showSelfMonitorModal();
} else { } else if (!this.projectCreated && !this.loading) {
this.createProject(); this.createProject();
} }
}, },
......
...@@ -60,7 +60,9 @@ export default (elements = document.querySelectorAll('.js-user-link')) => { ...@@ -60,7 +60,9 @@ export default (elements = document.querySelectorAll('.js-user-link')) => {
const userLinks = Array.from(elements); const userLinks = Array.from(elements);
const UserPopoverComponent = Vue.extend(UserPopover); const UserPopoverComponent = Vue.extend(UserPopover);
return userLinks.map(el => { return userLinks
.filter(({ dataset }) => dataset.user || dataset.userId)
.map(el => {
if (initializedPopovers.has(el)) { if (initializedPopovers.has(el)) {
return initializedPopovers.get(el); return initializedPopovers.get(el);
} }
......
<script> <script>
import FileHeader from '~/vue_shared/components/file_row_header.vue'; import FileHeader from '~/vue_shared/components/file_row_header.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue';
import ChangedFileIcon from '~/vue_shared/components/changed_file_icon.vue';
export default { export default {
name: 'FileRow', name: 'FileRow',
components: { components: {
FileHeader, FileHeader,
FileIcon, FileIcon,
ChangedFileIcon,
}, },
props: { props: {
file: { file: {
...@@ -19,11 +17,6 @@ export default { ...@@ -19,11 +17,6 @@ export default {
type: Number, type: Number,
required: true, required: true,
}, },
showChangedIcon: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
isTree() { isTree() {
...@@ -121,15 +114,14 @@ export default { ...@@ -121,15 +114,14 @@ export default {
<div class="file-row-name-container"> <div class="file-row-name-container">
<span ref="textOutput" :style="levelIndentation" class="file-row-name str-truncated"> <span ref="textOutput" :style="levelIndentation" class="file-row-name str-truncated">
<file-icon <file-icon
v-if="!showChangedIcon || file.type === 'tree'"
class="file-row-icon" class="file-row-icon"
:class="{ 'text-secondary': file.type === 'tree' }"
:file-name="file.name" :file-name="file.name"
:loading="file.loading" :loading="file.loading"
:folder="isTree" :folder="isTree"
:opened="file.opened" :opened="file.opened"
:size="16" :size="16"
/> />
<changed-file-icon v-else :file="file" :size="16" class="append-right-5" />
{{ file.name }} {{ file.name }}
</span> </span>
<slot></slot> <slot></slot>
......
---
title: Restyle Merge Request diffs file tree
merge_request: 24342
author:
type: changed
...@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import DiffFileRow from '~/diffs/components/diff_file_row.vue'; import DiffFileRow from '~/diffs/components/diff_file_row.vue';
import FileRow from '~/vue_shared/components/file_row.vue'; import FileRow from '~/vue_shared/components/file_row.vue';
import FileRowStats from '~/diffs/components/file_row_stats.vue'; import FileRowStats from '~/diffs/components/file_row_stats.vue';
import ChangedFileIcon from '~/vue_shared/components/changed_file_icon.vue';
describe('Diff File Row component', () => { describe('Diff File Row component', () => {
let wrapper; let wrapper;
...@@ -38,6 +39,21 @@ describe('Diff File Row component', () => { ...@@ -38,6 +39,21 @@ describe('Diff File Row component', () => {
); );
}); });
it('renders ChangedFileIcon component', () => {
createComponent({
level: 4,
file: {},
hideFileStats: false,
});
expect(wrapper.find(ChangedFileIcon).props()).toEqual(
expect.objectContaining({
file: {},
size: 16,
}),
);
});
describe('FileRowStats components', () => { describe('FileRowStats components', () => {
it.each` it.each`
type | hideFileStats | value | desc type | hideFileStats | value | desc
......
...@@ -10,20 +10,24 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -10,20 +10,24 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
# rubocop: disable Layout/TrailingWhitespace # rubocop: disable Layout/TrailingWhitespace
let(:description) do
<<~MARKDOWN.strip_heredoc
- [ ] Task List Item
- [ ]
- [ ] Task List Item 2
MARKDOWN
end
# rubocop: enable Layout/TrailingWhitespace
let(:merge_request) do let(:merge_request) do
create( create(
:merge_request, :merge_request,
:with_diffs, :with_diffs,
source_project: project, source_project: project,
target_project: project, target_project: project,
description: <<~MARKDOWN.strip_heredoc description: description
- [ ] Task List Item
- [ ]
- [ ] Task List Item 2
MARKDOWN
) )
end end
# rubocop: enable Layout/TrailingWhitespace
let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) } let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) }
let(:pipeline) do let(:pipeline) do
...@@ -122,6 +126,15 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -122,6 +126,15 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
end end
end end
context 'with mentions' do
let(:group) { create(:group) }
let(:description) { "@#{group.full_path} @all @#{admin.username}" }
it 'merge_requests/merge_request_with_mentions.html' do
render_merge_request(merge_request)
end
end
private private
def render_discussions_json(merge_request) def render_discussions_json(merge_request)
......
...@@ -2,10 +2,10 @@ import initUserPopovers from '~/user_popovers'; ...@@ -2,10 +2,10 @@ import initUserPopovers from '~/user_popovers';
import UsersCache from '~/lib/utils/users_cache'; import UsersCache from '~/lib/utils/users_cache';
describe('User Popovers', () => { describe('User Popovers', () => {
const fixtureTemplate = 'merge_requests/diff_comment.html'; const fixtureTemplate = 'merge_requests/merge_request_with_mentions.html';
preloadFixtures(fixtureTemplate); preloadFixtures(fixtureTemplate);
const selector = '.js-user-link'; const selector = '.js-user-link, .gfm-project_member';
const dummyUser = { name: 'root' }; const dummyUser = { name: 'root' };
const dummyUserStatus = { message: 'active' }; const dummyUserStatus = { message: 'active' };
...@@ -34,8 +34,12 @@ describe('User Popovers', () => { ...@@ -34,8 +34,12 @@ describe('User Popovers', () => {
popovers = initUserPopovers(document.querySelectorAll(selector)); popovers = initUserPopovers(document.querySelectorAll(selector));
}); });
it('initializes a popover for each js-user-link element found in the document', () => { it('initializes a popover for each user link with a user id', () => {
expect(document.querySelectorAll(selector).length).toBe(popovers.length); const linksWithUsers = Array.from(document.querySelectorAll(selector)).filter(
({ dataset }) => dataset.user || dataset.userId,
);
expect(linksWithUsers.length).toBe(popovers.length);
}); });
it('does not initialize the user popovers twice for the same element', () => { it('does not initialize the user popovers twice for the same element', () => {
......
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