2018-11-08 19:23:39 +05:30
|
|
|
<script>
|
2018-12-05 23:21:45 +05:30
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2020-03-13 15:44:24 +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';
|
2018-12-05 23:21:45 +05:30
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2018-11-08 19:23:39 +05:30
|
|
|
import CompareVersionsDropdown from './compare_versions_dropdown.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: {
|
|
|
|
CompareVersionsDropdown,
|
2018-12-05 23:21:45 +05:30
|
|
|
Icon,
|
2019-02-15 15:39:39 +05:30
|
|
|
GlLink,
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
mergeRequestDiff: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
2019-02-15 15:39:39 +05:30
|
|
|
default: () => ({}),
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
targetBranch: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
isLimitedContainer: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
diffFilesLength: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2020-03-13 15:44:24 +05:30
|
|
|
...mapGetters('diffs', ['hasCollapsedFile']),
|
2019-03-02 22:35:43 +05:30
|
|
|
...mapState('diffs', [
|
|
|
|
'commit',
|
|
|
|
'showTreeList',
|
|
|
|
'startVersion',
|
|
|
|
'latestVersionPath',
|
|
|
|
'addedLines',
|
|
|
|
'removedLines',
|
|
|
|
]),
|
2018-11-08 19:23:39 +05:30
|
|
|
comparableDiffs() {
|
|
|
|
return this.mergeRequestDiffs.slice(1);
|
|
|
|
},
|
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');
|
|
|
|
},
|
|
|
|
baseVersionPath() {
|
|
|
|
return this.mergeRequestDiff.base_version_path;
|
|
|
|
},
|
|
|
|
},
|
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,
|
|
|
|
}"
|
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
<button
|
2019-02-15 15:39:39 +05:30
|
|
|
v-gl-tooltip.hover
|
2018-12-05 23:21:45 +05:30
|
|
|
type="button"
|
|
|
|
class="btn btn-default append-right-8 js-toggle-tree-list"
|
|
|
|
:class="{
|
2019-02-15 15:39:39 +05:30
|
|
|
active: showTreeList,
|
2018-12-05 23:21:45 +05:30
|
|
|
}"
|
2019-03-02 22:35:43 +05:30
|
|
|
:title="toggleFileBrowserTitle"
|
2018-12-05 23:21:45 +05:30
|
|
|
@click="toggleShowTreeList"
|
|
|
|
>
|
2020-03-13 15:44:24 +05:30
|
|
|
<icon name="file-tree" />
|
2018-12-05 23:21:45 +05:30
|
|
|
</button>
|
2020-03-13 15:44:24 +05:30
|
|
|
<gl-sprintf
|
|
|
|
v-if="showDropdowns"
|
|
|
|
class="d-flex align-items-center compare-versions-container"
|
|
|
|
:message="s__('MergeRequest|Compare %{source} and %{target}')"
|
|
|
|
>
|
|
|
|
<template #source>
|
|
|
|
<compare-versions-dropdown
|
|
|
|
:other-versions="mergeRequestDiffs"
|
|
|
|
:merge-request-version="mergeRequestDiff"
|
|
|
|
:show-commit-count="true"
|
|
|
|
class="mr-version-dropdown"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template #target>
|
|
|
|
<compare-versions-dropdown
|
|
|
|
:other-versions="comparableDiffs"
|
|
|
|
:base-version-path="baseVersionPath"
|
|
|
|
:start-version="startVersion"
|
|
|
|
:target-branch="targetBranch"
|
|
|
|
class="mr-version-compare-dropdown"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</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
|
|
|
|
:diff-files-length="diffFilesLength"
|
|
|
|
:added-lines="addedLines"
|
|
|
|
:removed-lines="removedLines"
|
|
|
|
/>
|
2019-02-15 15:39:39 +05:30
|
|
|
<gl-button
|
|
|
|
v-if="commit || startVersion"
|
|
|
|
:href="latestVersionPath"
|
|
|
|
class="append-right-8 js-latest-version"
|
2018-12-05 23:21:45 +05:30
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
{{ __('Show latest version') }}
|
|
|
|
</gl-button>
|
2019-07-07 11:18:12 +05:30
|
|
|
<gl-button v-show="hasCollapsedFile" class="append-right-8" @click="expandAllFiles">
|
2018-12-05 23:21:45 +05:30
|
|
|
{{ __('Expand all') }}
|
2019-07-07 11:18:12 +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>
|