2018-10-15 14:42:47 +05:30
|
|
|
<script>
|
|
|
|
import { mapGetters, mapState, mapActions } from 'vuex';
|
|
|
|
import IdeTreeList from './ide_tree_list.vue';
|
|
|
|
import EditorModeDropdown from './editor_mode_dropdown.vue';
|
|
|
|
import { viewerTypes } from '../constants';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
IdeTreeList,
|
|
|
|
EditorModeDropdown,
|
|
|
|
},
|
|
|
|
computed: {
|
2018-11-18 11:00:15 +05:30
|
|
|
...mapGetters(['currentMergeRequest', 'activeFile']),
|
2018-11-08 19:23:39 +05:30
|
|
|
...mapState(['viewer', 'currentMergeRequestId']),
|
2018-10-15 14:42:47 +05:30
|
|
|
showLatestChangesText() {
|
2018-11-08 19:23:39 +05:30
|
|
|
return !this.currentMergeRequestId || this.viewer === viewerTypes.diff;
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
showMergeRequestText() {
|
2018-11-08 19:23:39 +05:30
|
|
|
return this.currentMergeRequestId && this.viewer === viewerTypes.mr;
|
|
|
|
},
|
|
|
|
mergeRequestId() {
|
|
|
|
return `!${this.currentMergeRequest.iid}`;
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-11-18 11:00:15 +05:30
|
|
|
if (this.activeFile && this.activeFile.pending && !this.activeFile.deleted) {
|
|
|
|
this.$router.push(`/project${this.activeFile.url}`, () => {
|
|
|
|
this.updateViewer('editor');
|
|
|
|
});
|
|
|
|
} else if (this.activeFile && this.activeFile.deleted) {
|
|
|
|
this.resetOpenFiles();
|
|
|
|
}
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
this.$nextTick(() => {
|
2018-11-08 19:23:39 +05:30
|
|
|
this.updateViewer(this.currentMergeRequestId ? viewerTypes.mr : viewerTypes.diff);
|
2018-10-15 14:42:47 +05:30
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
2018-11-18 11:00:15 +05:30
|
|
|
...mapActions(['updateViewer', 'resetOpenFiles']),
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<ide-tree-list
|
|
|
|
:viewer-type="viewer"
|
2018-11-08 19:23:39 +05:30
|
|
|
header-class="ide-review-header"
|
2018-10-15 14:42:47 +05:30
|
|
|
>
|
|
|
|
<template
|
|
|
|
slot="header"
|
|
|
|
>
|
|
|
|
<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">
|
|
|
|
<template v-if="showLatestChangesText">
|
|
|
|
{{ __('Latest changes') }}
|
|
|
|
</template>
|
|
|
|
<template v-else-if="showMergeRequestText">
|
|
|
|
{{ __('Merge request') }}
|
2018-11-08 19:23:39 +05:30
|
|
|
(<a
|
|
|
|
v-if="currentMergeRequest"
|
|
|
|
:href="currentMergeRequest.web_url"
|
|
|
|
v-text="mergeRequestId"
|
|
|
|
></a>)
|
2018-10-15 14:42:47 +05:30
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ide-tree-list>
|
|
|
|
</template>
|