2018-06-21 08:22:40 -04:00
|
|
|
<script>
|
2020-09-07 08:08:27 -04:00
|
|
|
import {
|
|
|
|
GlTooltipDirective,
|
|
|
|
GlSafeHtmlDirective,
|
|
|
|
GlIcon,
|
|
|
|
GlButton,
|
2020-09-24 08:09:37 -04:00
|
|
|
GlButtonGroup,
|
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
|
|
|
GlDropdownDivider,
|
2021-01-25 04:09:10 -05:00
|
|
|
GlFormCheckbox,
|
2020-11-11 10:08:46 -05:00
|
|
|
GlLoadingIcon,
|
2020-09-07 08:08:27 -04:00
|
|
|
} from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { escape } from 'lodash';
|
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
|
|
|
import { diffViewerModes } from '~/ide/constants';
|
|
|
|
import { scrollToElement } from '~/lib/utils/common_utils';
|
2018-06-21 08:22:40 -04:00
|
|
|
import { truncateSha } from '~/lib/utils/text_utility';
|
|
|
|
import { __, s__, sprintf } from '~/locale';
|
2021-02-14 13:09:20 -05:00
|
|
|
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
|
|
|
import FileIcon from '~/vue_shared/components/file_icon.vue';
|
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
2021-01-25 04:09:10 -05:00
|
|
|
|
2021-02-14 13:09:20 -05:00
|
|
|
import { DIFF_FILE_AUTOMATIC_COLLAPSE } from '../constants';
|
|
|
|
import { DIFF_FILE_HEADER } from '../i18n';
|
2021-01-25 04:09:10 -05:00
|
|
|
import { collapsedType, isCollapsed } from '../utils/diff_file';
|
|
|
|
import { reviewable } from '../utils/file_reviews';
|
|
|
|
|
2021-02-01 10:08:56 -05:00
|
|
|
import DiffStats from './diff_stats.vue';
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ClipboardButton,
|
2020-08-24 11:10:11 -04:00
|
|
|
GlIcon,
|
2018-07-05 08:02:56 -04:00
|
|
|
FileIcon,
|
2019-01-29 22:21:26 -05:00
|
|
|
DiffStats,
|
2020-09-07 08:08:27 -04:00
|
|
|
GlButton,
|
2020-09-24 08:09:37 -04:00
|
|
|
GlButtonGroup,
|
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
|
|
|
GlDropdownDivider,
|
2021-01-25 04:09:10 -05:00
|
|
|
GlFormCheckbox,
|
2020-11-11 10:08:46 -05:00
|
|
|
GlLoadingIcon,
|
2021-04-02 20:09:02 -04:00
|
|
|
CodeQualityBadge: () => import('ee_component/diffs/components/code_quality_badge.vue'),
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
directives: {
|
2018-11-05 08:12:40 -05:00
|
|
|
GlTooltip: GlTooltipDirective,
|
2020-09-07 08:08:27 -04:00
|
|
|
SafeHtml: GlSafeHtmlDirective,
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2021-01-25 04:09:10 -05:00
|
|
|
mixins: [glFeatureFlagsMixin()],
|
2020-10-13 14:08:58 -04:00
|
|
|
i18n: {
|
|
|
|
...DIFF_FILE_HEADER,
|
2021-04-01 02:09:29 -04:00
|
|
|
compareButtonLabel: s__('Compare submodule commit revisions'),
|
2020-10-13 14:08:58 -04:00
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
props: {
|
2018-10-11 18:32:28 -04:00
|
|
|
discussionPath: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
diffFile: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
collapsible: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
addMergeRequestButtons: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
expanded: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2018-07-17 11:47:02 -04:00
|
|
|
canCurrentUserFork: {
|
|
|
|
type: Boolean,
|
2018-06-21 08:22:40 -04:00
|
|
|
required: true,
|
|
|
|
},
|
2020-07-15 02:09:35 -04:00
|
|
|
viewDiffsFileByFile: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-25 04:09:10 -05:00
|
|
|
showLocalFileReviews: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
reviewed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-05-06 20:10:27 -04:00
|
|
|
codequalityDiff: {
|
|
|
|
type: Array,
|
2021-04-02 20:09:02 -04:00
|
|
|
required: false,
|
2021-05-06 20:10:27 -04:00
|
|
|
default: () => [],
|
2021-04-02 20:09:02 -04:00
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2020-09-18 17:10:11 -04:00
|
|
|
data() {
|
|
|
|
return {
|
2020-09-24 08:09:37 -04:00
|
|
|
moreActionsShown: false,
|
2020-09-18 17:10:11 -04:00
|
|
|
};
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
computed: {
|
2021-01-25 04:09:10 -05:00
|
|
|
...mapState('diffs', ['latestDiff']),
|
2018-07-17 07:54:33 -04:00
|
|
|
...mapGetters('diffs', ['diffHasExpandedDiscussions', 'diffHasDiscussions']),
|
2019-03-25 11:13:22 -04:00
|
|
|
diffContentIDSelector() {
|
|
|
|
return `#diff-content-${this.diffFile.file_hash}`;
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
titleLink() {
|
|
|
|
if (this.diffFile.submodule) {
|
2018-11-09 14:48:41 -05:00
|
|
|
return this.diffFile.submodule_tree_url || this.diffFile.submodule_link;
|
2018-06-21 08:22:40 -04:00
|
|
|
}
|
2019-03-25 11:13:22 -04:00
|
|
|
|
|
|
|
if (!this.discussionPath) {
|
|
|
|
return this.diffContentIDSelector;
|
|
|
|
}
|
|
|
|
|
2018-10-11 18:32:28 -04:00
|
|
|
return this.discussionPath;
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2020-09-07 08:08:27 -04:00
|
|
|
submoduleDiffCompareLinkText() {
|
|
|
|
if (this.diffFile.submodule_compare) {
|
|
|
|
const truncatedOldSha = escape(truncateSha(this.diffFile.submodule_compare.old_sha));
|
|
|
|
const truncatedNewSha = escape(truncateSha(this.diffFile.submodule_compare.new_sha));
|
|
|
|
return sprintf(
|
|
|
|
s__('Compare %{oldCommitId}...%{newCommitId}'),
|
|
|
|
{
|
|
|
|
oldCommitId: `<span class="commit-sha">${truncatedOldSha}</span>`,
|
|
|
|
newCommitId: `<span class="commit-sha">${truncatedNewSha}</span>`,
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
filePath() {
|
|
|
|
if (this.diffFile.submodule) {
|
2018-11-09 14:48:41 -05:00
|
|
|
return `${this.diffFile.file_path} @ ${truncateSha(this.diffFile.blob.id)}`;
|
2018-06-21 08:22:40 -04:00
|
|
|
}
|
|
|
|
|
2018-11-09 14:48:41 -05:00
|
|
|
if (this.diffFile.deleted_file) {
|
|
|
|
return sprintf(__('%{filePath} deleted'), { filePath: this.diffFile.file_path }, false);
|
2018-06-21 08:22:40 -04:00
|
|
|
}
|
|
|
|
|
2018-11-09 14:48:41 -05:00
|
|
|
return this.diffFile.file_path;
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
isUsingLfs() {
|
2018-11-09 14:48:41 -05:00
|
|
|
return this.diffFile.stored_externally && this.diffFile.external_storage === 'lfs';
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2020-10-26 08:08:44 -04:00
|
|
|
isCollapsed() {
|
|
|
|
return isCollapsed(this.diffFile, { fileByFile: this.viewDiffsFileByFile });
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
collapseIcon() {
|
|
|
|
return this.expanded ? 'chevron-down' : 'chevron-right';
|
|
|
|
},
|
|
|
|
viewFileButtonText() {
|
2020-04-21 14:09:31 -04:00
|
|
|
const truncatedContentSha = escape(truncateSha(this.diffFile.content_sha));
|
2018-06-21 08:22:40 -04:00
|
|
|
return sprintf(
|
|
|
|
s__('MergeRequests|View file @ %{commitId}'),
|
2019-04-15 18:28:20 -04:00
|
|
|
{ commitId: truncatedContentSha },
|
2018-06-21 08:22:40 -04:00
|
|
|
false,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
viewReplacedFileButtonText() {
|
2020-04-21 14:09:31 -04:00
|
|
|
const truncatedBaseSha = escape(truncateSha(this.diffFile.diff_refs.base_sha));
|
2020-10-05 11:08:56 -04:00
|
|
|
return sprintf(s__('MergeRequests|View replaced file @ %{commitId}'), {
|
|
|
|
commitId: truncatedBaseSha,
|
|
|
|
});
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2018-07-30 09:37:28 -04:00
|
|
|
gfmCopyText() {
|
2018-11-09 14:48:41 -05:00
|
|
|
return `\`${this.diffFile.file_path}\``;
|
2018-07-30 09:37:28 -04:00
|
|
|
},
|
2019-02-15 12:56:50 -05:00
|
|
|
isFileRenamed() {
|
2019-08-21 04:23:22 -04:00
|
|
|
return this.diffFile.renamed_file;
|
2019-02-15 12:56:50 -05:00
|
|
|
},
|
|
|
|
isModeChanged() {
|
|
|
|
return this.diffFile.viewer.name === diffViewerModes.mode_changed;
|
|
|
|
},
|
2019-03-28 17:37:06 -04:00
|
|
|
expandDiffToFullFileTitle() {
|
|
|
|
if (this.diffFile.isShowingFullFile) {
|
|
|
|
return s__('MRDiff|Show changes only');
|
|
|
|
}
|
|
|
|
return s__('MRDiff|Show full file');
|
|
|
|
},
|
2020-09-24 08:09:37 -04:00
|
|
|
showEditButton() {
|
|
|
|
return (
|
|
|
|
this.diffFile.blob?.readable_text &&
|
|
|
|
!this.diffFile.deleted_file &&
|
|
|
|
(this.diffFile.edit_path || this.diffFile.ide_edit_path)
|
|
|
|
);
|
|
|
|
},
|
2021-01-25 04:09:10 -05:00
|
|
|
isReviewable() {
|
|
|
|
return reviewable(this.diffFile);
|
|
|
|
},
|
2021-04-01 02:09:29 -04:00
|
|
|
externalUrlLabel() {
|
|
|
|
return sprintf(__('View on %{url}'), { url: this.diffFile.formatted_external_url });
|
|
|
|
},
|
2021-05-20 14:10:33 -04:00
|
|
|
showCodequalityBadge() {
|
|
|
|
return this.codequalityDiff?.length > 0 && !this.glFeatures.codequalityMrDiffAnnotations;
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2019-07-03 04:26:57 -04:00
|
|
|
...mapActions('diffs', [
|
|
|
|
'toggleFileDiscussions',
|
|
|
|
'toggleFileDiscussionWrappers',
|
|
|
|
'toggleFullDiff',
|
2020-09-01 05:10:28 -04:00
|
|
|
'toggleActiveFileByHash',
|
2021-01-25 04:09:10 -05:00
|
|
|
'reviewFile',
|
|
|
|
'setFileCollapsedByUser',
|
2019-07-03 04:26:57 -04:00
|
|
|
]),
|
2019-09-12 01:04:22 -04:00
|
|
|
handleToggleFile() {
|
|
|
|
this.$emit('toggleFile');
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2020-09-24 08:09:37 -04:00
|
|
|
showForkMessage(e) {
|
|
|
|
if (this.canCurrentUserFork && !this.diffFile.can_modify_blob) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.$emit('showForkMessage');
|
|
|
|
}
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2019-03-25 11:13:22 -04:00
|
|
|
handleFileNameClick(e) {
|
|
|
|
const isLinkToOtherPage =
|
|
|
|
this.diffFile.submodule_tree_url || this.diffFile.submodule_link || this.discussionPath;
|
|
|
|
|
|
|
|
if (!isLinkToOtherPage) {
|
|
|
|
e.preventDefault();
|
|
|
|
const selector = this.diffContentIDSelector;
|
|
|
|
scrollToElement(document.querySelector(selector));
|
|
|
|
window.location.hash = selector;
|
2020-09-01 05:10:28 -04:00
|
|
|
if (!this.viewDiffsFileByFile) {
|
|
|
|
this.toggleActiveFileByHash(this.diffFile.file_hash);
|
|
|
|
}
|
2019-03-25 11:13:22 -04:00
|
|
|
}
|
|
|
|
},
|
2020-09-24 08:09:37 -04:00
|
|
|
setMoreActionsShown(val) {
|
|
|
|
this.moreActionsShown = val;
|
2020-09-18 17:10:11 -04:00
|
|
|
},
|
2021-01-25 04:09:10 -05:00
|
|
|
toggleReview(newReviewedStatus) {
|
|
|
|
const autoCollapsed =
|
|
|
|
this.isCollapsed && collapsedType(this.diffFile) === DIFF_FILE_AUTOMATIC_COLLAPSE;
|
|
|
|
const open = this.expanded;
|
|
|
|
const closed = !open;
|
|
|
|
const reviewed = newReviewedStatus;
|
|
|
|
|
|
|
|
this.reviewFile({ file: this.diffFile, reviewed });
|
|
|
|
|
|
|
|
if (reviewed && autoCollapsed) {
|
|
|
|
this.setFileCollapsedByUser({
|
|
|
|
filePath: this.diffFile.file_path,
|
|
|
|
collapsed: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((open && reviewed) || (closed && !reviewed)) {
|
|
|
|
this.$emit('toggleFile');
|
|
|
|
}
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
ref="header"
|
2020-09-24 08:09:37 -04:00
|
|
|
:class="{ 'gl-z-dropdown-menu!': moreActionsShown }"
|
2018-06-21 08:22:40 -04:00
|
|
|
class="js-file-title file-title file-title-flex-parent"
|
2021-01-21 01:09:03 -05:00
|
|
|
data-qa-selector="file_title_container"
|
|
|
|
:data-qa-file-name="filePath"
|
2019-09-12 01:04:22 -04:00
|
|
|
@click.self="handleToggleFile"
|
2018-06-21 08:22:40 -04:00
|
|
|
>
|
2020-11-06 19:08:58 -05:00
|
|
|
<div class="file-header-content">
|
2020-08-24 11:10:11 -04:00
|
|
|
<gl-icon
|
2018-06-21 08:22:40 -04:00
|
|
|
v-if="collapsible"
|
2019-09-12 01:04:22 -04:00
|
|
|
ref="collapseIcon"
|
2018-06-21 08:22:40 -04:00
|
|
|
:name="collapseIcon"
|
|
|
|
:size="16"
|
2020-07-08 17:09:09 -04:00
|
|
|
class="diff-toggle-caret gl-mr-2"
|
2019-09-12 01:04:22 -04:00
|
|
|
@click.stop="handleToggleFile"
|
2018-06-21 08:22:40 -04:00
|
|
|
/>
|
2020-07-15 02:09:35 -04:00
|
|
|
<a
|
|
|
|
ref="titleWrapper"
|
|
|
|
:v-once="!viewDiffsFileByFile"
|
2020-11-06 19:08:58 -05:00
|
|
|
class="gl-mr-2 gl-text-decoration-none! gl-word-break-all"
|
2020-07-15 02:09:35 -04:00
|
|
|
:href="titleLink"
|
|
|
|
@click="handleFileNameClick"
|
|
|
|
>
|
2020-11-05 10:09:04 -05:00
|
|
|
<file-icon
|
|
|
|
:file-name="filePath"
|
|
|
|
:size="18"
|
|
|
|
aria-hidden="true"
|
|
|
|
css-classes="gl-mr-2"
|
|
|
|
:submodule="diffFile.submodule"
|
|
|
|
/>
|
2019-02-15 12:56:50 -05:00
|
|
|
<span v-if="isFileRenamed">
|
2018-06-21 08:22:40 -04:00
|
|
|
<strong
|
2018-11-05 08:12:40 -05:00
|
|
|
v-gl-tooltip
|
2020-09-21 17:09:27 -04:00
|
|
|
v-safe-html="diffFile.old_path_html"
|
2018-11-09 14:48:41 -05:00
|
|
|
:title="diffFile.old_path"
|
2018-06-21 08:22:40 -04:00
|
|
|
class="file-title-name"
|
2018-10-03 14:14:39 -04:00
|
|
|
></strong>
|
2018-06-21 08:22:40 -04:00
|
|
|
→
|
|
|
|
<strong
|
2018-11-05 08:12:40 -05:00
|
|
|
v-gl-tooltip
|
2020-09-21 17:09:27 -04:00
|
|
|
v-safe-html="diffFile.new_path_html"
|
2018-11-09 14:48:41 -05:00
|
|
|
:title="diffFile.new_path"
|
2018-06-21 08:22:40 -04:00
|
|
|
class="file-title-name"
|
2018-10-03 14:14:39 -04:00
|
|
|
></strong>
|
2018-06-21 08:22:40 -04:00
|
|
|
</span>
|
|
|
|
|
2020-10-01 08:10:14 -04:00
|
|
|
<strong
|
|
|
|
v-else
|
|
|
|
v-gl-tooltip
|
|
|
|
:title="filePath"
|
|
|
|
class="file-title-name"
|
|
|
|
data-container="body"
|
|
|
|
data-qa-selector="file_name_content"
|
|
|
|
>
|
2018-06-21 08:22:40 -04:00
|
|
|
{{ filePath }}
|
|
|
|
</strong>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<clipboard-button
|
2019-10-09 08:06:13 -04:00
|
|
|
:title="__('Copy file path')"
|
2018-11-09 14:48:41 -05:00
|
|
|
:text="diffFile.file_path"
|
2018-07-30 09:37:28 -04:00
|
|
|
:gfm="gfmCopyText"
|
2020-10-02 20:08:46 -04:00
|
|
|
data-testid="diff-file-copy-clipboard"
|
|
|
|
category="tertiary"
|
2020-01-23 04:09:07 -05:00
|
|
|
data-track-event="click_copy_file_button"
|
|
|
|
data-track-label="diff_copy_file_path_button"
|
|
|
|
data-track-property="diff_copy_file"
|
2018-06-21 08:22:40 -04:00
|
|
|
/>
|
|
|
|
|
2021-05-06 20:10:27 -04:00
|
|
|
<code-quality-badge
|
2021-05-20 14:10:33 -04:00
|
|
|
v-if="showCodequalityBadge"
|
2021-05-06 20:10:27 -04:00
|
|
|
:file-name="filePath"
|
|
|
|
:codequality-diff="codequalityDiff"
|
|
|
|
class="gl-mr-2"
|
|
|
|
/>
|
2021-04-02 20:09:02 -04:00
|
|
|
|
2019-05-30 08:54:12 -04:00
|
|
|
<small v-if="isModeChanged" ref="fileMode" class="mr-1">
|
2018-11-09 14:48:41 -05:00
|
|
|
{{ diffFile.a_mode }} → {{ diffFile.b_mode }}
|
2018-06-21 08:22:40 -04:00
|
|
|
</small>
|
|
|
|
|
2020-11-06 19:08:58 -05:00
|
|
|
<span v-if="isUsingLfs" class="badge label label-lfs gl-mr-2"> {{ __('LFS') }} </span>
|
2018-06-21 08:22:40 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-if="!diffFile.submodule && addMergeRequestButtons"
|
2020-11-06 19:08:58 -05:00
|
|
|
class="file-actions d-flex align-items-center gl-ml-auto gl-align-self-start"
|
2018-06-21 08:22:40 -04:00
|
|
|
>
|
2019-01-29 22:21:26 -05:00
|
|
|
<diff-stats :added-lines="diffFile.added_lines" :removed-lines="diffFile.removed_lines" />
|
2021-01-25 04:09:10 -05:00
|
|
|
<gl-form-checkbox
|
|
|
|
v-if="isReviewable && showLocalFileReviews"
|
|
|
|
v-gl-tooltip.hover
|
|
|
|
data-testid="fileReviewCheckbox"
|
2021-03-02 13:11:20 -05:00
|
|
|
class="gl-mr-5 gl-display-flex gl-align-items-center"
|
2021-01-25 04:09:10 -05:00
|
|
|
:title="$options.i18n.fileReviewTooltip"
|
|
|
|
:checked="reviewed"
|
|
|
|
@change="toggleReview"
|
|
|
|
>
|
2021-03-02 13:11:20 -05:00
|
|
|
{{ $options.i18n.fileReviewLabel }}
|
2021-01-25 04:09:10 -05:00
|
|
|
</gl-form-checkbox>
|
2020-09-24 08:09:37 -04:00
|
|
|
<gl-button-group class="gl-pt-0!">
|
|
|
|
<gl-button
|
2019-03-28 17:37:06 -04:00
|
|
|
v-if="diffFile.external_url"
|
2019-09-12 01:04:22 -04:00
|
|
|
ref="externalLink"
|
2019-03-28 17:37:06 -04:00
|
|
|
v-gl-tooltip.hover
|
|
|
|
:href="diffFile.external_url"
|
2021-04-01 02:09:29 -04:00
|
|
|
:title="externalUrlLabel"
|
|
|
|
:aria-label="externalUrlLabel"
|
2019-03-28 17:37:06 -04:00
|
|
|
target="_blank"
|
2020-01-23 04:09:07 -05:00
|
|
|
data-track-event="click_toggle_external_button"
|
|
|
|
data-track-label="diff_toggle_external_button"
|
|
|
|
data-track-property="diff_toggle_external"
|
2020-09-24 08:09:37 -04:00
|
|
|
icon="external-link"
|
|
|
|
/>
|
|
|
|
<gl-dropdown
|
2020-10-13 14:08:58 -04:00
|
|
|
v-gl-tooltip.hover.focus="$options.i18n.optionsDropdownTitle"
|
2020-09-24 08:09:37 -04:00
|
|
|
right
|
|
|
|
toggle-class="btn-icon js-diff-more-actions"
|
|
|
|
class="gl-pt-0!"
|
2021-01-21 01:09:03 -05:00
|
|
|
data-qa-selector="dropdown_button"
|
2020-09-24 08:09:37 -04:00
|
|
|
@show="setMoreActionsShown(true)"
|
|
|
|
@hidden="setMoreActionsShown(false)"
|
2019-03-28 17:37:06 -04:00
|
|
|
>
|
2020-09-24 08:09:37 -04:00
|
|
|
<template #button-content>
|
|
|
|
<gl-icon name="ellipsis_v" class="mr-0" />
|
2020-10-13 14:08:58 -04:00
|
|
|
<span class="sr-only">{{ $options.i18n.optionsDropdownTitle }}</span>
|
2020-09-24 08:09:37 -04:00
|
|
|
</template>
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="diffFile.replaced_view_path"
|
|
|
|
ref="replacedFileButton"
|
|
|
|
:href="diffFile.replaced_view_path"
|
|
|
|
target="_blank"
|
2020-10-05 11:08:56 -04:00
|
|
|
>
|
|
|
|
{{ viewReplacedFileButtonText }}
|
|
|
|
</gl-dropdown-item>
|
2020-09-24 08:09:37 -04:00
|
|
|
<gl-dropdown-item ref="viewButton" :href="diffFile.view_path" target="_blank">
|
|
|
|
{{ viewFileButtonText }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
<template v-if="showEditButton">
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="diffFile.edit_path"
|
|
|
|
ref="editButton"
|
|
|
|
:href="diffFile.edit_path"
|
|
|
|
class="js-edit-blob"
|
|
|
|
@click="showForkMessage"
|
|
|
|
>
|
|
|
|
{{ __('Edit in single-file editor') }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="diffFile.edit_path"
|
|
|
|
ref="ideEditButton"
|
|
|
|
:href="diffFile.ide_edit_path"
|
|
|
|
class="js-ide-edit-blob"
|
2021-01-21 01:09:03 -05:00
|
|
|
data-qa-selector="edit_in_ide_button"
|
2020-09-24 08:09:37 -04:00
|
|
|
>
|
|
|
|
{{ __('Edit in Web IDE') }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
</template>
|
|
|
|
|
2020-10-26 08:08:44 -04:00
|
|
|
<template v-if="!isCollapsed">
|
2020-09-24 08:09:37 -04:00
|
|
|
<gl-dropdown-divider
|
|
|
|
v-if="!diffFile.is_fully_expanded || diffHasDiscussions(diffFile)"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="diffHasDiscussions(diffFile)"
|
|
|
|
ref="toggleDiscussionsButton"
|
|
|
|
data-qa-selector="toggle_comments_button"
|
|
|
|
@click="toggleFileDiscussionWrappers(diffFile)"
|
|
|
|
>
|
|
|
|
<template v-if="diffHasExpandedDiscussions(diffFile)">
|
|
|
|
{{ __('Hide comments on this file') }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ __('Show comments on this file') }}
|
|
|
|
</template>
|
|
|
|
</gl-dropdown-item>
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="!diffFile.is_fully_expanded"
|
|
|
|
ref="expandDiffToFullFileButton"
|
2020-11-11 10:08:46 -05:00
|
|
|
:disabled="diffFile.isLoadingFullFile"
|
2020-09-24 08:09:37 -04:00
|
|
|
@click="toggleFullDiff(diffFile.file_path)"
|
|
|
|
>
|
2020-11-11 10:08:46 -05:00
|
|
|
<gl-loading-icon v-if="diffFile.isLoadingFullFile" inline />
|
2020-09-24 08:09:37 -04:00
|
|
|
{{ expandDiffToFullFileTitle }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
</template>
|
|
|
|
</gl-dropdown>
|
|
|
|
</gl-button-group>
|
2018-06-21 08:22:40 -04:00
|
|
|
</div>
|
2020-09-07 08:08:27 -04:00
|
|
|
|
|
|
|
<div
|
|
|
|
v-if="diffFile.submodule_compare"
|
|
|
|
class="file-actions d-none d-sm-flex align-items-center flex-wrap"
|
|
|
|
>
|
|
|
|
<gl-button
|
|
|
|
v-gl-tooltip.hover
|
|
|
|
v-safe-html="submoduleDiffCompareLinkText"
|
|
|
|
class="submodule-compare"
|
2021-04-01 02:09:29 -04:00
|
|
|
:title="$options.i18n.compareButtonLabel"
|
|
|
|
:aria-label="$options.i18n.compareButtonLabel"
|
2020-09-07 08:08:27 -04:00
|
|
|
:href="diffFile.submodule_compare.url"
|
|
|
|
/>
|
|
|
|
</div>
|
2018-06-21 08:22:40 -04:00
|
|
|
</div>
|
|
|
|
</template>
|