Commit 129dd185 authored by Phil Hughes's avatar Phil Hughes

Added merge request to IDE sidebar

#44846
parent 9b8332d3
<script> <script>
import Icon from '~/vue_shared/components/icon.vue';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
export default { export default {
components: {
Icon,
},
props: { props: {
hasChanges: {
type: Boolean,
required: false,
default: false,
},
mergeRequestId: {
type: String,
required: false,
default: '',
},
viewer: { viewer: {
type: String, type: String,
required: true, required: true,
}, },
showShadow: { mergeRequestId: {
type: Boolean, type: Number,
required: true, required: true,
}, },
}, },
...@@ -44,69 +30,30 @@ export default { ...@@ -44,69 +30,30 @@ export default {
<template> <template>
<div <div
class="dropdown" class="dropdown"
:class="{ style="margin-left:auto;"
shadow: showShadow,
}"
> >
<button <button
type="button" type="button"
class="btn btn-primary btn-sm" class="btn btn-link"
:class="{
'btn-inverted': hasChanges,
}"
data-toggle="dropdown" data-toggle="dropdown"
> >
<template v-if="viewer === 'mrdiff' && mergeRequestId"> Edit
{{ mergeReviewLine }}
</template>
<template v-else-if="viewer === 'editor'">
{{ __('Editing') }}
</template>
<template v-else>
{{ __('Reviewing') }}
</template>
<icon
name="angle-down"
:size="12"
css-classes="caret-down"
/>
</button> </button>
<div class="dropdown-menu dropdown-menu-selectable dropdown-open-left"> <div class="dropdown-menu dropdown-menu-selectable dropdown-open-left">
<ul> <ul>
<template v-if="mergeRequestId">
<li>
<a
href="#"
@click.prevent="changeMode('mrdiff')"
:class="{
'is-active': viewer === 'mrdiff',
}"
>
<strong class="dropdown-menu-inner-title">
{{ mergeReviewLine }}
</strong>
<span class="dropdown-menu-inner-content">
{{ __('Compare changes with the merge request target branch') }}
</span>
</a>
</li>
<li
role="separator"
class="divider"
>
</li>
</template>
<li> <li>
<a <a
href="#" href="#"
@click.prevent="changeMode('editor')" @click.prevent="changeMode('mrdiff')"
:class="{ :class="{
'is-active': viewer === 'editor', 'is-active': viewer === 'mrdiff',
}" }"
> >
<strong class="dropdown-menu-inner-title">{{ __('Editing') }}</strong> <strong class="dropdown-menu-inner-title">
{{ mergeReviewLine }}
</strong>
<span class="dropdown-menu-inner-content"> <span class="dropdown-menu-inner-content">
{{ __('View and edit lines') }} {{ __('Compare changes with the merge request target branch') }}
</span> </span>
</a> </a>
</li> </li>
......
<script> <script>
import { mapGetters, mapState, mapActions } from 'vuex';
import IdeTreeList from './ide_tree_list.vue'; import IdeTreeList from './ide_tree_list.vue';
import EditorModeDropdown from './editor_mode_dropdown.vue';
export default { export default {
components: { components: {
IdeTreeList, IdeTreeList,
EditorModeDropdown,
},
computed: {
...mapGetters(['currentMergeRequest']),
...mapState(['viewer']),
},
mounted() {
this.updateViewer(this.currentMergeRequest ? 'mrdiff' : 'diff');
},
methods: {
...mapActions(['updateViewer']),
}, },
}; };
</script> </script>
<template> <template>
<ide-tree-list <ide-tree-list
viewer-type="diff" :viewer-type="viewer"
header-class="ide-review-header" header-class="ide-review-header"
:disable-action-dropdown="true" :disable-action-dropdown="true"
> >
<template <template
slot="header" slot="header"
> >
{{ __('Review') }} <div class="ide-review-button-holder">
{{ __('Review') }}
<editor-mode-dropdown
v-if="currentMergeRequest"
:viewer="viewer"
:merge-request-id="currentMergeRequest.iid"
@click="updateViewer"
/>
</div>
<div class="prepend-top-5 ide-review-sub-header"> <div class="prepend-top-5 ide-review-sub-header">
{{ __('Lastest changes') }} <template v-if="!currentMergeRequest || viewer === 'diff'">
{{ __('Lastest changes') }}
</template>
<template v-else-if="currentMergeRequest && viewer === 'mrdiff'">
Merge request
(<a :href="currentMergeRequest.web_url">!{{ currentMergeRequest.iid }}</a>)
</template>
</div> </div>
</template> </template>
</ide-tree-list> </ide-tree-list>
</template> </template>
<style>
.ide-review-button-holder {
display: flex;
width: 100%;
align-items: center;
}
</style>
...@@ -2,6 +2,7 @@ import Vue from 'vue'; ...@@ -2,6 +2,7 @@ import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import flash from '~/flash'; import flash from '~/flash';
import store from './stores'; import store from './stores';
import { activityBarViews } from './constants';
Vue.use(VueRouter); Vue.use(VueRouter);
...@@ -101,7 +102,7 @@ router.beforeEach((to, from, next) => { ...@@ -101,7 +102,7 @@ router.beforeEach((to, from, next) => {
throw e; throw e;
}); });
} else if (to.params.mrid) { } else if (to.params.mrid) {
store.dispatch('updateViewer', 'mrdiff'); store.dispatch('updateActivityBarView', activityBarViews.review);
store store
.dispatch('getMergeRequestData', { .dispatch('getMergeRequestData', {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment