debian-mirror-gitlab/app/assets/javascripts/ide/components/ide_review.vue

78 lines
2.2 KiB
Vue
Raw Normal View History

2018-10-15 14:42:47 +05:30
<script>
import { mapGetters, mapState, mapActions } from 'vuex';
import { viewerTypes } from '../constants';
2021-03-11 19:13:27 +05:30
import EditorModeDropdown from './editor_mode_dropdown.vue';
import IdeTreeList from './ide_tree_list.vue';
2018-10-15 14:42:47 +05:30
export default {
components: {
IdeTreeList,
EditorModeDropdown,
},
computed: {
2020-11-24 15:15:51 +05:30
...mapGetters(['currentMergeRequest', 'activeFile', 'getUrlForPath']),
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() {
2021-01-03 14:25:43 +05:30
this.initialize();
},
activated() {
this.initialize();
2018-10-15 14:42:47 +05:30
},
methods: {
2018-11-18 11:00:15 +05:30
...mapActions(['updateViewer', 'resetOpenFiles']),
2021-01-03 14:25:43 +05:30
initialize() {
if (this.activeFile && this.activeFile.pending && !this.activeFile.deleted) {
this.$router.push(this.getUrlForPath(this.activeFile.path), () => {
this.updateViewer(viewerTypes.edit);
});
} else if (this.activeFile && this.activeFile.deleted) {
this.resetOpenFiles();
}
this.$nextTick(() => {
this.updateViewer(this.currentMergeRequestId ? viewerTypes.mr : viewerTypes.diff);
});
},
2018-10-15 14:42:47 +05:30
},
};
</script>
<template>
2021-01-03 14:25:43 +05:30
<ide-tree-list header-class="ide-review-header">
2020-05-24 23:13:21 +05:30
<template #header>
2018-10-15 14:42:47 +05:30
<div class="ide-review-button-holder">
{{ __('Review') }}
<editor-mode-dropdown
v-if="currentMergeRequest"
:viewer="viewer"
:merge-request-id="currentMergeRequest.iid"
@click="updateViewer"
/>
</div>
2020-07-28 23:09:34 +05:30
<div class="gl-mt-2 ide-review-sub-header">
2018-10-15 14:42:47 +05:30
<template v-if="showLatestChangesText">
{{ __('Latest changes') }}
</template>
<template v-else-if="showMergeRequestText">
2019-02-15 15:39:39 +05:30
{{ __('Merge request') }} (<a
2018-11-08 19:23:39 +05:30
v-if="currentMergeRequest"
:href="currentMergeRequest.web_url"
v-text="mergeRequestId"
2019-02-15 15:39:39 +05:30
></a
>)
2018-10-15 14:42:47 +05:30
</template>
</div>
</template>
</ide-tree-list>
</template>