2018-11-08 19:23:39 +05:30
|
|
|
<script>
|
2018-12-05 23:21:45 +05:30
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2019-01-03 12:48:30 +05:30
|
|
|
import Tooltip from '@gitlab-org/gitlab-ui/dist/directives/tooltip';
|
2018-12-05 23:21:45 +05:30
|
|
|
import { __ } from '~/locale';
|
|
|
|
import { getParameterValues, mergeUrlParams } from '~/lib/utils/url_utility';
|
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2018-11-08 19:23:39 +05:30
|
|
|
import CompareVersionsDropdown from './compare_versions_dropdown.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
CompareVersionsDropdown,
|
2018-12-05 23:21:45 +05:30
|
|
|
Icon,
|
|
|
|
},
|
|
|
|
directives: {
|
2019-01-03 12:48:30 +05:30
|
|
|
Tooltip,
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
mergeRequestDiffs: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
mergeRequestDiff: {
|
2019-01-03 12:48:30 +05:30
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
startVersion: {
|
2018-11-08 19:23:39 +05:30
|
|
|
type: Object,
|
|
|
|
required: false,
|
2019-01-03 12:48:30 +05:30
|
|
|
default: null,
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
targetBranch: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2019-01-03 12:48:30 +05:30
|
|
|
...mapState('diffs', ['commit', 'showTreeList']),
|
2018-12-13 13:39:08 +05:30
|
|
|
...mapGetters('diffs', ['isInlineView', 'isParallelView', 'hasCollapsedFile']),
|
2018-11-08 19:23:39 +05:30
|
|
|
comparableDiffs() {
|
|
|
|
return this.mergeRequestDiffs.slice(1);
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
toggleWhitespaceText() {
|
2018-12-13 13:39:08 +05:30
|
|
|
if (this.isWhitespaceVisible()) {
|
2018-12-05 23:21:45 +05:30
|
|
|
return __('Hide whitespace changes');
|
|
|
|
}
|
|
|
|
return __('Show whitespace changes');
|
|
|
|
},
|
|
|
|
toggleWhitespacePath() {
|
2018-12-13 13:39:08 +05:30
|
|
|
if (this.isWhitespaceVisible()) {
|
2018-12-05 23:21:45 +05:30
|
|
|
return mergeUrlParams({ w: 1 }, window.location.href);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mergeUrlParams({ w: 0 }, window.location.href);
|
|
|
|
},
|
|
|
|
showDropdowns() {
|
|
|
|
return !this.commit && this.mergeRequestDiffs.length;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions('diffs', [
|
|
|
|
'setInlineDiffViewType',
|
|
|
|
'setParallelDiffViewType',
|
|
|
|
'expandAllFiles',
|
|
|
|
'toggleShowTreeList',
|
|
|
|
]),
|
2018-12-13 13:39:08 +05:30
|
|
|
isWhitespaceVisible() {
|
|
|
|
return getParameterValues('w')[0] !== '1';
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="mr-version-controls">
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
class="mr-version-menus-container content-block"
|
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
<button
|
2019-01-03 12:48:30 +05:30
|
|
|
v-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-01-03 12:48:30 +05:30
|
|
|
active: showTreeList
|
2018-12-05 23:21:45 +05:30
|
|
|
}"
|
|
|
|
:title="__('Toggle file browser')"
|
|
|
|
@click="toggleShowTreeList"
|
|
|
|
>
|
2019-01-03 12:48:30 +05:30
|
|
|
<icon
|
|
|
|
name="hamburger"
|
|
|
|
/>
|
2018-12-05 23:21:45 +05:30
|
|
|
</button>
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
v-if="showDropdowns"
|
|
|
|
class="d-flex align-items-center compare-versions-container"
|
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
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"
|
|
|
|
:start-version="startVersion"
|
|
|
|
:target-branch="targetBranch"
|
|
|
|
class="mr-version-compare-dropdown"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
class="inline-parallel-buttons d-none d-md-flex ml-auto"
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
v-show="hasCollapsedFile"
|
|
|
|
class="btn btn-default append-right-8"
|
|
|
|
@click="expandAllFiles"
|
2018-12-05 23:21:45 +05:30
|
|
|
>
|
|
|
|
{{ __('Expand all') }}
|
|
|
|
</a>
|
2019-01-03 12:48:30 +05:30
|
|
|
<a
|
|
|
|
:href="toggleWhitespacePath"
|
|
|
|
class="btn btn-default qa-toggle-whitespace"
|
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
{{ toggleWhitespaceText }}
|
|
|
|
</a>
|
|
|
|
<div class="btn-group prepend-left-8">
|
|
|
|
<button
|
|
|
|
id="inline-diff-btn"
|
|
|
|
:class="{ active: isInlineView }"
|
|
|
|
type="button"
|
|
|
|
class="btn js-inline-diff-button"
|
|
|
|
data-view-type="inline"
|
|
|
|
@click="setInlineDiffViewType"
|
|
|
|
>
|
|
|
|
{{ __('Inline') }}
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
id="parallel-diff-btn"
|
|
|
|
:class="{ active: isParallelView }"
|
|
|
|
type="button"
|
|
|
|
class="btn js-parallel-diff-button"
|
|
|
|
data-view-type="parallel"
|
|
|
|
@click="setParallelDiffViewType"
|
|
|
|
>
|
|
|
|
{{ __('Side-by-side') }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-08 19:23:39 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|