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