debian-mirror-gitlab/app/assets/javascripts/diffs/components/app.vue

630 lines
19 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlLoadingIcon, GlPagination, GlSprintf } from '@gitlab/ui';
2021-02-22 17:27:13 +05:30
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
2020-01-01 13:55:28 +05:30
import Mousetrap from 'mousetrap';
2021-03-11 19:13:27 +05:30
import { mapState, mapGetters, mapActions } from 'vuex';
2021-06-08 01:23:25 +05:30
import { DynamicScroller, DynamicScrollerItem } from 'vendor/vue-virtual-scroller';
import api from '~/api';
2021-04-29 21:17:54 +05:30
import {
keysFor,
MR_PREVIOUS_FILE_IN_DIFF,
MR_NEXT_FILE_IN_DIFF,
MR_COMMITS_NEXT_COMMIT,
MR_COMMITS_PREVIOUS_COMMIT,
} from '~/behaviors/shortcuts/keybindings';
2020-10-24 23:57:45 +05:30
import { deprecatedCreateFlash as createFlash } from '~/flash';
2020-03-13 15:44:24 +05:30
import { isSingleViewStyle } from '~/helpers/diffs_helper';
2021-03-11 19:13:27 +05:30
import { getParameterByName, parseBoolean } from '~/lib/utils/common_utils';
2020-05-24 23:13:21 +05:30
import { updateHistory } from '~/lib/utils/url_utility';
2021-03-11 19:13:27 +05:30
import { __ } from '~/locale';
import PanelResizer from '~/vue_shared/components/panel_resizer.vue';
2021-02-22 17:27:13 +05:30
import notesEventHub from '../../notes/event_hub';
2019-07-07 11:18:12 +05:30
import {
TREE_LIST_WIDTH_STORAGE_KEY,
INITIAL_TREE_WIDTH,
MIN_TREE_WIDTH,
MAX_TREE_WIDTH,
TREE_HIDE_STATS_WIDTH,
MR_TREE_SHOW_KEY,
CENTERED_LIMITED_CONTAINER_CLASSES,
2020-11-24 15:15:51 +05:30
ALERT_OVERFLOW_HIDDEN,
ALERT_MERGE_CONFLICT,
ALERT_COLLAPSED_FILES,
2021-06-08 01:23:25 +05:30
INLINE_DIFF_VIEW_TYPE,
TRACKING_DIFF_VIEW_INLINE,
TRACKING_DIFF_VIEW_PARALLEL,
TRACKING_FILE_BROWSER_TREE,
TRACKING_FILE_BROWSER_LIST,
TRACKING_WHITESPACE_SHOW,
TRACKING_WHITESPACE_HIDE,
TRACKING_SINGLE_FILE_MODE,
TRACKING_MULTIPLE_FILES_MODE,
2019-07-07 11:18:12 +05:30
} from '../constants';
2021-03-11 19:13:27 +05:30
import { reviewStatuses } from '../utils/file_reviews';
import { diffsApp } from '../utils/performance';
import { fileByFile } from '../utils/preferences';
import CollapsedFilesWarning from './collapsed_files_warning.vue';
import CommitWidget from './commit_widget.vue';
import CompareVersions from './compare_versions.vue';
import DiffFile from './diff_file.vue';
import HiddenFilesWarning from './hidden_files_warning.vue';
import MergeConflictWarning from './merge_conflict_warning.vue';
import NoChanges from './no_changes.vue';
import TreeList from './tree_list.vue';
2018-11-08 19:23:39 +05:30
export default {
name: 'DiffsApp',
components: {
CompareVersions,
DiffFile,
NoChanges,
HiddenFilesWarning,
2020-11-24 15:15:51 +05:30
MergeConflictWarning,
CollapsedFilesWarning,
2018-12-05 23:21:45 +05:30
CommitWidget,
TreeList,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2019-07-07 11:18:12 +05:30
PanelResizer,
2020-11-24 15:15:51 +05:30
GlPagination,
GlSprintf,
2021-06-08 01:23:25 +05:30
DynamicScroller,
DynamicScrollerItem,
2018-11-08 19:23:39 +05:30
},
2020-11-24 15:15:51 +05:30
alerts: {
ALERT_OVERFLOW_HIDDEN,
ALERT_MERGE_CONFLICT,
ALERT_COLLAPSED_FILES,
},
2018-11-08 19:23:39 +05:30
props: {
endpoint: {
type: String,
required: true,
},
2020-01-01 13:55:28 +05:30
endpointMetadata: {
type: String,
required: true,
},
endpointBatch: {
type: String,
required: true,
},
2020-04-08 14:13:33 +05:30
endpointCoverage: {
type: String,
required: false,
default: '',
},
2021-04-29 21:17:54 +05:30
endpointCodequality: {
type: String,
required: false,
default: '',
},
endpointUpdateUser: {
type: String,
required: false,
default: '',
},
2018-11-08 19:23:39 +05:30
projectPath: {
type: String,
required: true,
},
shouldShow: {
type: Boolean,
required: false,
default: false,
},
currentUser: {
type: Object,
required: true,
},
2019-02-15 15:39:39 +05:30
helpPagePath: {
type: String,
required: false,
default: '',
},
changesEmptyStateIllustration: {
type: String,
required: false,
default: '',
},
2019-07-07 11:18:12 +05:30
isFluidLayout: {
type: Boolean,
required: false,
default: false,
},
2019-09-04 21:01:54 +05:30
dismissEndpoint: {
type: String,
required: false,
default: '',
},
showSuggestPopover: {
type: Boolean,
required: false,
default: false,
},
2021-02-22 17:27:13 +05:30
fileByFileUserPreference: {
2020-07-28 23:09:34 +05:30
type: Boolean,
required: false,
default: false,
},
2021-03-08 18:12:59 +05:30
defaultSuggestionCommitMessage: {
type: String,
required: false,
default: '',
},
2021-04-17 20:07:23 +05:30
rehydratedMrReviews: {
2021-03-08 18:12:59 +05:30
type: Object,
required: false,
default: () => ({}),
},
2018-11-08 19:23:39 +05:30
},
2018-12-13 13:39:08 +05:30
data() {
2019-07-07 11:18:12 +05:30
const treeWidth =
parseInt(localStorage.getItem(TREE_LIST_WIDTH_STORAGE_KEY), 10) || INITIAL_TREE_WIDTH;
2018-12-13 13:39:08 +05:30
return {
2019-07-07 11:18:12 +05:30
treeWidth,
2020-03-13 15:44:24 +05:30
diffFilesLength: 0,
2018-12-13 13:39:08 +05:30
};
},
2018-11-08 19:23:39 +05:30
computed: {
...mapState({
2021-03-08 18:12:59 +05:30
isLoading: (state) => state.diffs.isLoading,
isBatchLoading: (state) => state.diffs.isBatchLoading,
diffFiles: (state) => state.diffs.diffFiles,
diffViewType: (state) => state.diffs.diffViewType,
commit: (state) => state.diffs.commit,
renderOverflowWarning: (state) => state.diffs.renderOverflowWarning,
numTotalFiles: (state) => state.diffs.realSize,
numVisibleFiles: (state) => state.diffs.size,
plainDiffPath: (state) => state.diffs.plainDiffPath,
emailPatchPath: (state) => state.diffs.emailPatchPath,
retrievingBatches: (state) => state.diffs.retrievingBatches,
2021-04-29 21:17:54 +05:30
codequalityDiff: (state) => state.diffs.codequalityDiff,
2018-11-08 19:23:39 +05:30
}),
2020-10-24 23:57:45 +05:30
...mapState('diffs', [
'showTreeList',
'isLoading',
'startVersion',
'currentDiffFileId',
'isTreeLoaded',
'conflictResolutionPath',
'canMerge',
'hasConflicts',
2021-02-22 17:27:13 +05:30
'viewDiffsFileByFile',
2021-04-17 20:07:23 +05:30
'mrReviews',
2021-06-08 01:23:25 +05:30
'renderTreeList',
'showWhitespace',
]),
...mapGetters('diffs', [
'whichCollapsedTypes',
'isParallelView',
'currentDiffIndex',
'isVirtualScrollingEnabled',
2020-10-24 23:57:45 +05:30
]),
2021-04-29 21:17:54 +05:30
...mapGetters('batchComments', ['draftsCount']),
2018-12-13 13:39:08 +05:30
...mapGetters(['isNotesFetched', 'getNoteableData']),
2020-07-28 23:09:34 +05:30
diffs() {
if (!this.viewDiffsFileByFile) {
return this.diffFiles;
}
return this.diffFiles.filter((file, i) => {
return file.file_hash === this.currentDiffFileId || (i === 0 && !this.currentDiffFileId);
});
},
2018-11-08 19:23:39 +05:30
canCurrentUserFork() {
2019-02-15 15:39:39 +05:30
return this.currentUser.can_fork === true && this.currentUser.can_create_merge_request;
2018-11-08 19:23:39 +05:30
},
2019-02-15 15:39:39 +05:30
renderDiffFiles() {
2021-03-08 18:12:59 +05:30
return this.diffFiles.length > 0;
},
renderFileTree() {
return this.renderDiffFiles && this.showTreeList;
2019-02-15 15:39:39 +05:30
},
2019-07-07 11:18:12 +05:30
hideFileStats() {
return this.treeWidth <= TREE_HIDE_STATS_WIDTH;
},
isLimitedContainer() {
2021-03-08 18:12:59 +05:30
return !this.renderFileTree && !this.isParallelView && !this.isFluidLayout;
2019-07-07 11:18:12 +05:30
},
2020-10-24 23:57:45 +05:30
isDiffHead() {
return parseBoolean(getParameterByName('diff_head'));
},
2020-11-24 15:15:51 +05:30
showFileByFileNavigation() {
return this.diffFiles.length > 1 && this.viewDiffsFileByFile;
},
currentFileNumber() {
return this.currentDiffIndex + 1;
},
previousFileNumber() {
const { currentDiffIndex } = this;
return currentDiffIndex >= 1 ? currentDiffIndex : null;
},
nextFileNumber() {
const { currentFileNumber, diffFiles } = this;
return currentFileNumber < diffFiles.length ? currentFileNumber + 1 : null;
},
visibleWarning() {
let visible = false;
if (this.renderOverflowWarning) {
visible = this.$options.alerts.ALERT_OVERFLOW_HIDDEN;
} else if (this.isDiffHead && this.hasConflicts) {
visible = this.$options.alerts.ALERT_MERGE_CONFLICT;
2021-01-29 00:20:46 +05:30
} else if (this.whichCollapsedTypes.automatic && !this.viewDiffsFileByFile) {
2020-11-24 15:15:51 +05:30
visible = this.$options.alerts.ALERT_COLLAPSED_FILES;
}
return visible;
},
2021-03-11 19:13:27 +05:30
fileReviews() {
return reviewStatuses(this.diffFiles, this.mrReviews);
},
2018-11-08 19:23:39 +05:30
},
watch: {
2020-05-24 23:13:21 +05:30
commit(newCommit, oldCommit) {
const commitChangedAfterRender = newCommit && !this.isLoading;
const commitIsDifferent = oldCommit && newCommit.id !== oldCommit.id;
const url = window?.location ? String(window.location) : '';
if (commitChangedAfterRender && commitIsDifferent) {
updateHistory({
title: document.title,
url: url.replace(oldCommit.id, newCommit.id),
});
this.refetchDiffData();
this.adjustView();
}
},
2018-11-08 19:23:39 +05:30
diffViewType() {
this.adjustView();
},
shouldShow() {
// When the shouldShow property changed to true, the route is rendered for the first time
// and if we have the isLoading as true this means we didn't fetch the data
if (this.isLoading) {
this.fetchData();
}
this.adjustView();
},
2018-12-05 23:21:45 +05:30
isLoading: 'adjustView',
2021-03-08 18:12:59 +05:30
renderFileTree: 'adjustView',
2018-11-08 19:23:39 +05:30
},
mounted() {
2019-09-04 21:01:54 +05:30
this.setBaseConfig({
endpoint: this.endpoint,
2020-01-01 13:55:28 +05:30
endpointMetadata: this.endpointMetadata,
endpointBatch: this.endpointBatch,
2020-04-08 14:13:33 +05:30
endpointCoverage: this.endpointCoverage,
2021-04-29 21:17:54 +05:30
endpointUpdateUser: this.endpointUpdateUser,
2019-09-04 21:01:54 +05:30
projectPath: this.projectPath,
dismissEndpoint: this.dismissEndpoint,
showSuggestPopover: this.showSuggestPopover,
2021-02-22 17:27:13 +05:30
viewDiffsFileByFile: fileByFile(this.fileByFileUserPreference),
2021-03-08 18:12:59 +05:30
defaultSuggestionCommitMessage: this.defaultSuggestionCommitMessage,
2021-04-17 20:07:23 +05:30
mrReviews: this.rehydratedMrReviews,
2019-09-04 21:01:54 +05:30
});
2018-11-08 19:23:39 +05:30
2021-04-29 21:17:54 +05:30
if (this.endpointCodequality) {
this.setCodequalityEndpoint(this.endpointCodequality);
}
2018-11-08 19:23:39 +05:30
if (this.shouldShow) {
this.fetchData();
}
2019-02-15 15:39:39 +05:30
2020-07-28 23:09:34 +05:30
const id = window?.location?.hash;
2019-02-15 15:39:39 +05:30
2020-07-28 23:09:34 +05:30
if (id && id.indexOf('#note') !== 0) {
2021-03-08 18:12:59 +05:30
this.setHighlightedRow(id.split('diff-content').pop().slice(1));
2019-02-15 15:39:39 +05:30
}
2021-06-08 01:23:25 +05:30
if (window.gon?.features?.diffSettingsUsageData) {
if (this.renderTreeList) {
api.trackRedisHllUserEvent(TRACKING_FILE_BROWSER_TREE);
} else {
api.trackRedisHllUserEvent(TRACKING_FILE_BROWSER_LIST);
}
if (this.diffViewType === INLINE_DIFF_VIEW_TYPE) {
api.trackRedisHllUserEvent(TRACKING_DIFF_VIEW_INLINE);
} else {
api.trackRedisHllUserEvent(TRACKING_DIFF_VIEW_PARALLEL);
}
if (this.showWhitespace) {
api.trackRedisHllUserEvent(TRACKING_WHITESPACE_SHOW);
} else {
api.trackRedisHllUserEvent(TRACKING_WHITESPACE_HIDE);
}
if (this.viewDiffsFileByFile) {
api.trackRedisHllUserEvent(TRACKING_SINGLE_FILE_MODE);
} else {
api.trackRedisHllUserEvent(TRACKING_MULTIPLE_FILES_MODE);
}
}
2018-11-08 19:23:39 +05:30
},
2021-01-29 00:20:46 +05:30
beforeCreate() {
diffsApp.instrument();
},
2018-11-08 19:23:39 +05:30
created() {
this.adjustView();
2021-02-22 17:27:13 +05:30
this.subscribeToEvents();
2021-01-29 00:20:46 +05:30
2019-07-07 11:18:12 +05:30
this.CENTERED_LIMITED_CONTAINER_CLASSES = CENTERED_LIMITED_CONTAINER_CLASSES;
2020-03-13 15:44:24 +05:30
this.unwatchDiscussions = this.$watch(
() => `${this.diffFiles.length}:${this.$store.state.notes.discussions.length}`,
() => this.setDiscussions(),
);
this.unwatchRetrievingBatches = this.$watch(
() => `${this.retrievingBatches}:${this.$store.state.notes.discussions.length}`,
() => {
if (!this.retrievingBatches && this.$store.state.notes.discussions.length) {
this.unwatchDiscussions();
this.unwatchRetrievingBatches();
}
},
);
2019-03-02 22:35:43 +05:30
},
beforeDestroy() {
2021-01-29 00:20:46 +05:30
diffsApp.deinstrument();
2021-02-22 17:27:13 +05:30
this.unsubscribeFromEvents();
2019-07-07 11:18:12 +05:30
this.removeEventListeners();
2018-11-08 19:23:39 +05:30
},
methods: {
2019-02-15 15:39:39 +05:30
...mapActions(['startTaskList']),
2018-11-20 20:47:30 +05:30
...mapActions('diffs', [
2020-05-24 23:13:21 +05:30
'moveToNeighboringCommit',
2018-11-20 20:47:30 +05:30
'setBaseConfig',
2021-04-29 21:17:54 +05:30
'setCodequalityEndpoint',
2020-01-01 13:55:28 +05:30
'fetchDiffFilesMeta',
'fetchDiffFilesBatch',
2020-04-08 14:13:33 +05:30
'fetchCoverageFiles',
2021-04-29 21:17:54 +05:30
'fetchCodequality',
2018-11-20 20:47:30 +05:30
'startRenderDiffsQueue',
'assignDiscussionsToDiff',
2019-02-15 15:39:39 +05:30
'setHighlightedRow',
2019-07-07 11:18:12 +05:30
'cacheTreeListWidth',
'scrollToFile',
2021-02-22 17:27:13 +05:30
'setShowTreeList',
2020-07-28 23:09:34 +05:30
'navigateToDiffFileIndex',
2021-02-22 17:27:13 +05:30
'setFileByFile',
2018-11-20 20:47:30 +05:30
]),
2021-02-22 17:27:13 +05:30
subscribeToEvents() {
notesEventHub.$once('fetchDiffData', this.fetchData);
notesEventHub.$on('refetchDiffData', this.refetchDiffData);
},
unsubscribeFromEvents() {
notesEventHub.$off('refetchDiffData', this.refetchDiffData);
notesEventHub.$off('fetchDiffData', this.fetchData);
},
2020-11-24 15:15:51 +05:30
navigateToDiffFileNumber(number) {
this.navigateToDiffFileIndex(number - 1);
},
2019-09-04 21:01:54 +05:30
refetchDiffData() {
this.fetchData(false);
},
2020-03-13 15:44:24 +05:30
needsReload() {
2020-11-24 15:15:51 +05:30
return this.diffFiles.length && isSingleViewStyle(this.diffFiles[0]);
2020-03-13 15:44:24 +05:30
},
needsFirstLoad() {
2020-11-24 15:15:51 +05:30
return !this.diffFiles.length;
2020-03-13 15:44:24 +05:30
},
2019-09-04 21:01:54 +05:30
fetchData(toggleTree = true) {
2020-11-24 15:15:51 +05:30
this.fetchDiffFilesMeta()
.then(({ real_size }) => {
this.diffFilesLength = parseInt(real_size, 10);
2021-02-22 17:27:13 +05:30
if (toggleTree) this.setTreeDisplay();
2020-11-24 15:15:51 +05:30
})
.catch(() => {
createFlash(__('Something went wrong on our end. Please try again!'));
});
2020-01-01 13:55:28 +05:30
2020-11-24 15:15:51 +05:30
this.fetchDiffFilesBatch()
.then(() => {
2021-02-22 17:27:13 +05:30
if (toggleTree) this.setTreeDisplay();
2020-11-24 15:15:51 +05:30
// Guarantee the discussions are assigned after the batch finishes.
// Just watching the length of the discussions or the diff files
// isn't enough, because with split diff loading, neither will
// change when loading the other half of the diff files.
this.setDiscussions();
})
.catch(() => {
createFlash(__('Something went wrong on our end. Please try again!'));
});
2018-11-08 19:23:39 +05:30
2020-04-08 14:13:33 +05:30
if (this.endpointCoverage) {
this.fetchCoverageFiles();
}
2021-04-29 21:17:54 +05:30
if (this.endpointCodequality) {
this.fetchCodequality();
}
2018-11-08 19:23:39 +05:30
if (!this.isNotesFetched) {
2021-02-22 17:27:13 +05:30
notesEventHub.$emit('fetchNotesData');
2018-11-08 19:23:39 +05:30
}
},
2018-11-20 20:47:30 +05:30
setDiscussions() {
2020-03-13 15:44:24 +05:30
requestIdleCallback(
2021-03-08 18:12:59 +05:30
() => this.assignDiscussionsToDiff().then(this.$nextTick).then(this.startTaskList),
2020-03-13 15:44:24 +05:30
{ timeout: 1000 },
);
2018-11-20 20:47:30 +05:30
},
2018-11-08 19:23:39 +05:30
adjustView() {
2018-12-05 23:21:45 +05:30
if (this.shouldShow) {
this.$nextTick(() => {
2019-07-07 11:18:12 +05:30
this.setEventListeners();
2018-12-05 23:21:45 +05:30
});
2019-07-07 11:18:12 +05:30
} else {
this.removeEventListeners();
}
},
setEventListeners() {
2021-04-29 21:17:54 +05:30
Mousetrap.bind(keysFor(MR_PREVIOUS_FILE_IN_DIFF), () => this.jumpToFile(-1));
Mousetrap.bind(keysFor(MR_NEXT_FILE_IN_DIFF), () => this.jumpToFile(+1));
2020-05-24 23:13:21 +05:30
2021-03-08 18:12:59 +05:30
if (this.commit) {
2021-04-29 21:17:54 +05:30
Mousetrap.bind(keysFor(MR_COMMITS_NEXT_COMMIT), () =>
this.moveToNeighboringCommit({ direction: 'next' }),
);
Mousetrap.bind(keysFor(MR_COMMITS_PREVIOUS_COMMIT), () =>
this.moveToNeighboringCommit({ direction: 'previous' }),
);
2020-05-24 23:13:21 +05:30
}
2019-07-07 11:18:12 +05:30
},
removeEventListeners() {
2021-04-29 21:17:54 +05:30
Mousetrap.unbind(keysFor(MR_PREVIOUS_FILE_IN_DIFF));
Mousetrap.unbind(keysFor(MR_NEXT_FILE_IN_DIFF));
Mousetrap.unbind(keysFor(MR_COMMITS_NEXT_COMMIT));
Mousetrap.unbind(keysFor(MR_COMMITS_PREVIOUS_COMMIT));
2019-07-07 11:18:12 +05:30
},
jumpToFile(step) {
const targetIndex = this.currentDiffIndex + step;
if (targetIndex >= 0 && targetIndex < this.diffFiles.length) {
this.scrollToFile(this.diffFiles[targetIndex].file_path);
}
},
2021-02-22 17:27:13 +05:30
setTreeDisplay() {
2019-07-07 11:18:12 +05:30
const storedTreeShow = localStorage.getItem(MR_TREE_SHOW_KEY);
2021-02-22 17:27:13 +05:30
let showTreeList = true;
2019-07-07 11:18:12 +05:30
2021-02-22 17:27:13 +05:30
if (storedTreeShow !== null) {
showTreeList = parseBoolean(storedTreeShow);
} else if (!bp.isDesktop() || (!this.isBatchLoading && this.diffFiles.length <= 1)) {
showTreeList = false;
2018-11-08 19:23:39 +05:30
}
2021-02-22 17:27:13 +05:30
return this.setShowTreeList({ showTreeList, saving: false });
2018-11-08 19:23:39 +05:30
},
},
2019-07-07 11:18:12 +05:30
minTreeWidth: MIN_TREE_WIDTH,
maxTreeWidth: MAX_TREE_WIDTH,
2018-11-08 19:23:39 +05:30
};
</script>
<template>
<div v-show="shouldShow">
2020-10-24 23:57:45 +05:30
<div v-if="isLoading || !isTreeLoaded" class="loading"><gl-loading-icon size="lg" /></div>
2019-02-15 15:39:39 +05:30
<div v-else id="diffs" :class="{ active: shouldShow }" class="diffs tab-pane">
2018-11-08 19:23:39 +05:30
<compare-versions
2019-07-07 11:18:12 +05:30
:is-limited-container="isLimitedContainer"
2020-10-24 23:57:45 +05:30
:diff-files-count-text="numTotalFiles"
2018-11-08 19:23:39 +05:30
/>
<hidden-files-warning
2020-11-24 15:15:51 +05:30
v-if="visibleWarning == $options.alerts.ALERT_OVERFLOW_HIDDEN"
2018-11-08 19:23:39 +05:30
:visible="numVisibleFiles"
:total="numTotalFiles"
:plain-diff-path="plainDiffPath"
:email-patch-path="emailPatchPath"
/>
2020-11-24 15:15:51 +05:30
<merge-conflict-warning
v-if="visibleWarning == $options.alerts.ALERT_MERGE_CONFLICT"
:limited="isLimitedContainer"
:resolution-path="conflictResolutionPath"
:mergeable="canMerge"
/>
<collapsed-files-warning
v-if="visibleWarning == $options.alerts.ALERT_COLLAPSED_FILES"
:limited="isLimitedContainer"
/>
2020-10-24 23:57:45 +05:30
2018-12-13 13:39:08 +05:30
<div
:data-can-create-note="getNoteableData.current_user.can_create_note"
2020-11-24 15:15:51 +05:30
class="files d-flex gl-mt-2"
2018-12-13 13:39:08 +05:30
>
2019-07-07 11:18:12 +05:30
<div
2021-03-08 18:12:59 +05:30
v-if="renderFileTree"
2019-07-07 11:18:12 +05:30
:style="{ width: `${treeWidth}px` }"
2021-04-29 21:17:54 +05:30
:class="{ 'review-bar-visible': draftsCount > 0 }"
2021-01-03 14:25:43 +05:30
class="diff-tree-list js-diff-tree-list px-3 pr-md-0"
2019-07-07 11:18:12 +05:30
>
<panel-resizer
:size.sync="treeWidth"
:start-size="treeWidth"
:min-size="$options.minTreeWidth"
:max-size="$options.maxTreeWidth"
side="right"
@resize-end="cacheTreeListWidth"
/>
<tree-list :hide-file-stats="hideFileStats" />
</div>
<div
2021-01-03 14:25:43 +05:30
class="col-12 col-md-auto diff-files-holder"
2019-07-07 11:18:12 +05:30
:class="{
[CENTERED_LIMITED_CONTAINER_CLASSES]: isLimitedContainer,
}"
>
2020-10-24 23:57:45 +05:30
<commit-widget v-if="commit" :commit="commit" :collapsible="false" />
2020-04-08 14:13:33 +05:30
<div v-if="isBatchLoading" class="loading"><gl-loading-icon size="lg" /></div>
2020-01-01 13:55:28 +05:30
<template v-else-if="renderDiffFiles">
2021-06-08 01:23:25 +05:30
<dynamic-scroller
v-if="isVirtualScrollingEnabled"
:items="diffs"
:min-item-size="70"
:buffer="1000"
:use-transform="false"
page-mode
>
<template #default="{ item, index, active }">
<dynamic-scroller-item :item="item" :active="active">
<diff-file
:file="item"
:reviewed="fileReviews[item.id]"
:is-first-file="index === 0"
:is-last-file="index === diffFilesLength - 1"
:help-page-path="helpPagePath"
:can-current-user-fork="canCurrentUserFork"
:view-diffs-file-by-file="viewDiffsFileByFile"
/>
</dynamic-scroller-item>
</template>
</dynamic-scroller>
<template v-else>
<diff-file
v-for="(file, index) in diffs"
:key="file.new_path"
:file="file"
:reviewed="fileReviews[file.id]"
:is-first-file="index === 0"
:is-last-file="index === diffFilesLength - 1"
:help-page-path="helpPagePath"
:can-current-user-fork="canCurrentUserFork"
:view-diffs-file-by-file="viewDiffsFileByFile"
/>
</template>
2020-11-24 15:15:51 +05:30
<div
v-if="showFileByFileNavigation"
data-testid="file-by-file-navigation"
class="gl-display-grid gl-text-center"
>
<gl-pagination
class="gl-mx-auto"
:value="currentFileNumber"
:prev-page="previousFileNumber"
:next-page="nextFileNumber"
@input="navigateToDiffFileNumber"
/>
<gl-sprintf :message="__('File %{current} of %{total}')">
<template #current>{{ currentFileNumber }}</template>
<template #total>{{ diffFiles.length }}</template>
</gl-sprintf>
2020-07-28 23:09:34 +05:30
</div>
2021-02-22 17:27:13 +05:30
<gl-loading-icon v-else-if="retrievingBatches" size="lg" />
2019-02-15 15:39:39 +05:30
</template>
<no-changes v-else :changes-empty-state-illustration="changesEmptyStateIllustration" />
2018-12-05 23:21:45 +05:30
</div>
2018-11-08 19:23:39 +05:30
</div>
</div>
</div>
</template>