2018-11-08 19:23:39 +05:30
|
|
|
<script>
|
2018-12-05 23:21:45 +05:30
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { GlTooltipDirective, GlLink, GlButton, GlSprintf } from '@gitlab/ui';
|
2018-12-05 23:21:45 +05:30
|
|
|
import { __ } from '~/locale';
|
2019-03-02 22:35:43 +05:30
|
|
|
import { polyfillSticky } from '~/lib/utils/sticky';
|
2020-04-22 19:07:51 +05:30
|
|
|
import CompareDropdownLayout from './compare_dropdown_layout.vue';
|
2019-03-02 22:35:43 +05:30
|
|
|
import SettingsDropdown from './settings_dropdown.vue';
|
|
|
|
import DiffStats from './diff_stats.vue';
|
2019-07-07 11:18:12 +05:30
|
|
|
import { CENTERED_LIMITED_CONTAINER_CLASSES } from '../constants';
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-04-22 19:07:51 +05:30
|
|
|
CompareDropdownLayout,
|
2019-02-15 15:39:39 +05:30
|
|
|
GlLink,
|
2020-11-24 15:15:51 +05:30
|
|
|
GlButton,
|
2020-03-13 15:44:24 +05:30
|
|
|
GlSprintf,
|
2019-03-02 22:35:43 +05:30
|
|
|
SettingsDropdown,
|
|
|
|
DiffStats,
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
directives: {
|
2019-02-15 15:39:39 +05:30
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
mergeRequestDiffs: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
isLimitedContainer: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
diffFilesCountText: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2020-04-22 19:07:51 +05:30
|
|
|
...mapGetters('diffs', [
|
|
|
|
'hasCollapsedFile',
|
|
|
|
'diffCompareDropdownTargetVersions',
|
|
|
|
'diffCompareDropdownSourceVersions',
|
|
|
|
]),
|
2019-03-02 22:35:43 +05:30
|
|
|
...mapState('diffs', [
|
|
|
|
'commit',
|
|
|
|
'showTreeList',
|
|
|
|
'startVersion',
|
|
|
|
'latestVersionPath',
|
|
|
|
'addedLines',
|
|
|
|
'removedLines',
|
|
|
|
]),
|
2018-12-05 23:21:45 +05:30
|
|
|
showDropdowns() {
|
|
|
|
return !this.commit && this.mergeRequestDiffs.length;
|
|
|
|
},
|
2019-03-02 22:35:43 +05:30
|
|
|
toggleFileBrowserTitle() {
|
|
|
|
return this.showTreeList ? __('Hide file browser') : __('Show file browser');
|
|
|
|
},
|
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
created() {
|
|
|
|
this.CENTERED_LIMITED_CONTAINER_CLASSES = CENTERED_LIMITED_CONTAINER_CLASSES;
|
|
|
|
},
|
2019-03-02 22:35:43 +05:30
|
|
|
mounted() {
|
|
|
|
polyfillSticky(this.$el);
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions('diffs', [
|
|
|
|
'setInlineDiffViewType',
|
|
|
|
'setParallelDiffViewType',
|
|
|
|
'expandAllFiles',
|
|
|
|
'toggleShowTreeList',
|
|
|
|
]),
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2020-03-13 15:44:24 +05:30
|
|
|
<div class="mr-version-controls border-top">
|
2019-07-07 11:18:12 +05:30
|
|
|
<div
|
|
|
|
class="mr-version-menus-container content-block"
|
|
|
|
:class="{
|
|
|
|
[CENTERED_LIMITED_CONTAINER_CLASSES]: isLimitedContainer,
|
|
|
|
}"
|
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-button
|
2019-02-15 15:39:39 +05:30
|
|
|
v-gl-tooltip.hover
|
2020-11-24 15:15:51 +05:30
|
|
|
variant="default"
|
|
|
|
icon="file-tree"
|
|
|
|
class="gl-mr-3 js-toggle-tree-list"
|
2019-03-02 22:35:43 +05:30
|
|
|
:title="toggleFileBrowserTitle"
|
2020-11-24 15:15:51 +05:30
|
|
|
:selected="showTreeList"
|
2018-12-05 23:21:45 +05:30
|
|
|
@click="toggleShowTreeList"
|
2020-11-24 15:15:51 +05:30
|
|
|
/>
|
2020-03-13 15:44:24 +05:30
|
|
|
<gl-sprintf
|
|
|
|
v-if="showDropdowns"
|
|
|
|
class="d-flex align-items-center compare-versions-container"
|
2020-06-23 00:09:42 +05:30
|
|
|
:message="s__('MergeRequest|Compare %{target} and %{source}')"
|
2020-03-13 15:44:24 +05:30
|
|
|
>
|
|
|
|
<template #target>
|
2020-04-22 19:07:51 +05:30
|
|
|
<compare-dropdown-layout
|
|
|
|
:versions="diffCompareDropdownTargetVersions"
|
2020-03-13 15:44:24 +05:30
|
|
|
class="mr-version-compare-dropdown"
|
2021-01-03 14:25:43 +05:30
|
|
|
data-qa-selector="target_version_dropdown"
|
2020-03-13 15:44:24 +05:30
|
|
|
/>
|
|
|
|
</template>
|
2020-06-23 00:09:42 +05:30
|
|
|
<template #source>
|
|
|
|
<compare-dropdown-layout
|
|
|
|
:versions="diffCompareDropdownSourceVersions"
|
|
|
|
class="mr-version-dropdown"
|
|
|
|
/>
|
|
|
|
</template>
|
2020-03-13 15:44:24 +05:30
|
|
|
</gl-sprintf>
|
2019-02-15 15:39:39 +05:30
|
|
|
<div v-else-if="commit">
|
|
|
|
{{ __('Viewing commit') }}
|
|
|
|
<gl-link :href="commit.commit_url" class="monospace">{{ commit.short_id }}</gl-link>
|
|
|
|
</div>
|
|
|
|
<div class="inline-parallel-buttons d-none d-md-flex ml-auto">
|
2019-03-02 22:35:43 +05:30
|
|
|
<diff-stats
|
2020-10-24 23:57:45 +05:30
|
|
|
:diff-files-count-text="diffFilesCountText"
|
2019-03-02 22:35:43 +05:30
|
|
|
:added-lines="addedLines"
|
|
|
|
:removed-lines="removedLines"
|
|
|
|
/>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-button
|
2019-02-15 15:39:39 +05:30
|
|
|
v-if="commit || startVersion"
|
|
|
|
:href="latestVersionPath"
|
2020-11-24 15:15:51 +05:30
|
|
|
variant="default"
|
2020-06-23 00:09:42 +05:30
|
|
|
class="gl-mr-3 js-latest-version"
|
2018-12-05 23:21:45 +05:30
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
{{ __('Show latest version') }}
|
2020-11-24 15:15:51 +05:30
|
|
|
</gl-button>
|
|
|
|
<gl-button
|
|
|
|
v-show="hasCollapsedFile"
|
|
|
|
variant="default"
|
|
|
|
class="gl-mr-3"
|
|
|
|
@click="expandAllFiles"
|
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
{{ __('Expand all') }}
|
2020-11-24 15:15:51 +05:30
|
|
|
</gl-button>
|
2019-03-02 22:35:43 +05:30
|
|
|
<settings-dropdown />
|
2018-12-05 23:21:45 +05:30
|
|
|
</div>
|
2018-11-08 19:23:39 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|