2018-06-21 08:22:40 -04:00
|
|
|
<script>
|
2018-10-03 05:05:43 -04:00
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2018-11-20 07:37:57 -05:00
|
|
|
import { GlTooltipDirective, GlLink, GlButton } from '@gitlab/ui';
|
2018-10-03 05:05:43 -04:00
|
|
|
import { __ } from '~/locale';
|
2019-01-22 03:29:41 -05:00
|
|
|
import { polyfillSticky } from '~/lib/utils/sticky';
|
2018-10-03 05:05:43 -04:00
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2018-06-21 08:22:40 -04:00
|
|
|
import CompareVersionsDropdown from './compare_versions_dropdown.vue';
|
2019-01-24 09:48:03 -05:00
|
|
|
import SettingsDropdown from './settings_dropdown.vue';
|
2019-01-29 22:21:26 -05:00
|
|
|
import DiffStats from './diff_stats.vue';
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
CompareVersionsDropdown,
|
2018-10-03 05:05:43 -04:00
|
|
|
Icon,
|
2018-11-20 07:37:57 -05:00
|
|
|
GlLink,
|
|
|
|
GlButton,
|
2019-01-24 09:48:03 -05:00
|
|
|
SettingsDropdown,
|
2019-01-29 22:21:26 -05:00
|
|
|
DiffStats,
|
2018-10-03 05:05:43 -04:00
|
|
|
},
|
|
|
|
directives: {
|
2018-11-05 08:12:40 -05:00
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
mergeRequestDiffs: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
mergeRequestDiff: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
2018-11-20 07:37:57 -05:00
|
|
|
default: () => ({}),
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
targetBranch: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2019-01-29 22:21:26 -05:00
|
|
|
...mapGetters('diffs', ['hasCollapsedFile', 'diffFilesLength']),
|
|
|
|
...mapState('diffs', [
|
|
|
|
'commit',
|
|
|
|
'showTreeList',
|
|
|
|
'startVersion',
|
|
|
|
'latestVersionPath',
|
|
|
|
'addedLines',
|
|
|
|
'removedLines',
|
|
|
|
]),
|
2018-06-21 08:22:40 -04:00
|
|
|
comparableDiffs() {
|
|
|
|
return this.mergeRequestDiffs.slice(1);
|
|
|
|
},
|
2018-10-03 05:05:43 -04:00
|
|
|
showDropdowns() {
|
|
|
|
return !this.commit && this.mergeRequestDiffs.length;
|
|
|
|
},
|
2019-01-22 03:29:41 -05:00
|
|
|
fileTreeIcon() {
|
|
|
|
return this.showTreeList ? 'collapse-left' : 'expand-left';
|
|
|
|
},
|
|
|
|
toggleFileBrowserTitle() {
|
|
|
|
return this.showTreeList ? __('Hide file browser') : __('Show file browser');
|
|
|
|
},
|
2019-01-16 08:18:10 -05:00
|
|
|
baseVersionPath() {
|
|
|
|
return this.mergeRequestDiff.base_version_path;
|
|
|
|
},
|
2018-10-03 05:05:43 -04:00
|
|
|
},
|
2019-01-22 03:29:41 -05:00
|
|
|
mounted() {
|
|
|
|
polyfillSticky(this.$el);
|
|
|
|
},
|
2018-10-03 05:05:43 -04:00
|
|
|
methods: {
|
|
|
|
...mapActions('diffs', [
|
|
|
|
'setInlineDiffViewType',
|
|
|
|
'setParallelDiffViewType',
|
|
|
|
'expandAllFiles',
|
|
|
|
'toggleShowTreeList',
|
|
|
|
]),
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-01-22 03:29:41 -05:00
|
|
|
<div class="mr-version-controls" :class="{ 'is-fileTreeOpen': showTreeList }">
|
2018-11-16 15:07:38 -05:00
|
|
|
<div class="mr-version-menus-container content-block">
|
2018-10-03 05:05:43 -04:00
|
|
|
<button
|
2018-11-15 03:31:07 -05:00
|
|
|
v-gl-tooltip.hover
|
2018-10-03 05:05:43 -04:00
|
|
|
type="button"
|
|
|
|
class="btn btn-default append-right-8 js-toggle-tree-list"
|
|
|
|
:class="{
|
2018-11-16 15:07:38 -05:00
|
|
|
active: showTreeList,
|
2018-10-03 05:05:43 -04:00
|
|
|
}"
|
2019-01-22 03:29:41 -05:00
|
|
|
:title="toggleFileBrowserTitle"
|
2018-10-03 05:05:43 -04:00
|
|
|
@click="toggleShowTreeList"
|
|
|
|
>
|
2019-01-22 03:29:41 -05:00
|
|
|
<icon :name="fileTreeIcon" />
|
2018-10-03 05:05:43 -04:00
|
|
|
</button>
|
2018-11-16 15:07:38 -05:00
|
|
|
<div v-if="showDropdowns" class="d-flex align-items-center compare-versions-container">
|
2018-10-03 05:05:43 -04:00
|
|
|
Changes between
|
|
|
|
<compare-versions-dropdown
|
|
|
|
:other-versions="mergeRequestDiffs"
|
|
|
|
:merge-request-version="mergeRequestDiff"
|
|
|
|
:show-commit-count="true"
|
|
|
|
class="mr-version-dropdown"
|
|
|
|
/>
|
|
|
|
and
|
|
|
|
<compare-versions-dropdown
|
|
|
|
:other-versions="comparableDiffs"
|
2019-01-16 08:18:10 -05:00
|
|
|
:base-version-path="baseVersionPath"
|
2018-10-03 05:05:43 -04:00
|
|
|
:start-version="startVersion"
|
|
|
|
:target-branch="targetBranch"
|
|
|
|
class="mr-version-compare-dropdown"
|
|
|
|
/>
|
|
|
|
</div>
|
2018-11-20 07:37:57 -05: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 09:48:03 -05:00
|
|
|
<div class="inline-parallel-buttons d-none d-md-flex ml-auto">
|
2019-01-29 22:21:26 -05:00
|
|
|
<diff-stats
|
|
|
|
:diff-files-length="diffFilesLength"
|
|
|
|
:added-lines="addedLines"
|
|
|
|
:removed-lines="removedLines"
|
|
|
|
/>
|
2018-11-20 07:37:57 -05:00
|
|
|
<gl-button
|
|
|
|
v-if="commit || startVersion"
|
|
|
|
:href="latestVersionPath"
|
|
|
|
class="append-right-8 js-latest-version"
|
|
|
|
>
|
|
|
|
{{ __('Show latest version') }}
|
|
|
|
</gl-button>
|
2019-03-11 09:09:36 -04:00
|
|
|
<gl-button v-show="hasCollapsedFile" class="append-right-8" @click="expandAllFiles">
|
2018-10-03 05:05:43 -04:00
|
|
|
{{ __('Expand all') }}
|
2019-03-11 09:09:36 -04:00
|
|
|
</gl-button>
|
2019-01-24 09:48:03 -05:00
|
|
|
<settings-dropdown />
|
2018-10-03 05:05:43 -04:00
|
|
|
</div>
|
2018-06-21 08:22:40 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|