2018-03-20 14:12:48 +00:00
|
|
|
<script>
|
2018-03-23 10:45:43 +00:00
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2018-03-27 14:56:22 +00:00
|
|
|
import { __, sprintf } from '~/locale';
|
2018-03-20 14:12:48 +00:00
|
|
|
|
2018-03-23 10:45:43 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
hasChanges: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2018-03-27 14:56:22 +00:00
|
|
|
mergeRequestId: {
|
|
|
|
type: String,
|
2018-03-23 10:45:43 +00:00
|
|
|
required: false,
|
2018-03-27 14:56:22 +00:00
|
|
|
default: '',
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2018-03-23 10:45:43 +00:00
|
|
|
viewer: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2018-03-23 10:45:43 +00:00
|
|
|
showShadow: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2018-03-27 15:02:39 +00:00
|
|
|
computed: {
|
|
|
|
mergeReviewLine() {
|
|
|
|
return sprintf(__('Reviewing (merge request !%{mergeRequestId})'), {
|
|
|
|
mergeRequestId: this.mergeRequestId,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
2018-03-23 10:45:43 +00:00
|
|
|
methods: {
|
|
|
|
changeMode(mode) {
|
|
|
|
this.$emit('click', mode);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-03-20 14:12:48 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="dropdown"
|
|
|
|
:class="{
|
|
|
|
shadow: showShadow,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-primary btn-sm"
|
|
|
|
:class="{
|
|
|
|
'btn-inverted': hasChanges,
|
|
|
|
}"
|
|
|
|
data-toggle="dropdown"
|
|
|
|
>
|
2018-03-27 14:56:22 +00:00
|
|
|
<template v-if="viewer === 'mrdiff' && mergeRequestId">
|
2018-03-27 15:02:39 +00:00
|
|
|
{{ mergeReviewLine }}
|
2018-03-23 10:45:43 +00:00
|
|
|
</template>
|
|
|
|
<template v-else-if="viewer === 'editor'">
|
2018-03-20 14:12:48 +00:00
|
|
|
{{ __('Editing') }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ __('Reviewing') }}
|
|
|
|
</template>
|
|
|
|
<icon
|
|
|
|
name="angle-down"
|
|
|
|
:size="12"
|
|
|
|
css-classes="caret-down"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
<div class="dropdown-menu dropdown-menu-selectable dropdown-open-left">
|
|
|
|
<ul>
|
2018-03-27 14:56:22 +00:00
|
|
|
<template v-if="mergeRequestId">
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
@click.prevent="changeMode('mrdiff')"
|
|
|
|
:class="{
|
|
|
|
'is-active': viewer === 'mrdiff',
|
|
|
|
}"
|
|
|
|
>
|
2018-03-27 15:02:39 +00:00
|
|
|
<strong class="dropdown-menu-inner-title">
|
|
|
|
{{ mergeReviewLine }}
|
|
|
|
</strong>
|
2018-03-27 14:56:22 +00:00
|
|
|
<span class="dropdown-menu-inner-content">
|
|
|
|
{{ __('Compare changes with the merge request target branch') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li
|
|
|
|
role="separator"
|
|
|
|
class="divider"
|
2018-03-23 10:45:43 +00:00
|
|
|
>
|
2018-03-27 14:56:22 +00:00
|
|
|
</li>
|
|
|
|
</template>
|
2018-03-20 14:12:48 +00:00
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
@click.prevent="changeMode('editor')"
|
|
|
|
:class="{
|
|
|
|
'is-active': viewer === 'editor',
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<strong class="dropdown-menu-inner-title">{{ __('Editing') }}</strong>
|
|
|
|
<span class="dropdown-menu-inner-content">
|
|
|
|
{{ __('View and edit lines') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
@click.prevent="changeMode('diff')"
|
|
|
|
:class="{
|
|
|
|
'is-active': viewer === 'diff',
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<strong class="dropdown-menu-inner-title">{{ __('Reviewing') }}</strong>
|
|
|
|
<span class="dropdown-menu-inner-content">
|
|
|
|
{{ __('Compare changes with the last commit') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|