gitlab-org--gitlab-foss/app/assets/javascripts/ide/components/ide_review.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.2 KiB
Vue
Raw Permalink Normal View History

<script>
import { mapGetters, mapState, mapActions } from 'vuex';
import { viewerTypes } from '../constants';
import EditorModeDropdown from './editor_mode_dropdown.vue';
import IdeTreeList from './ide_tree_list.vue';
export default {
components: {
IdeTreeList,
EditorModeDropdown,
},
computed: {
...mapGetters(['currentMergeRequest', 'activeFile', 'getUrlForPath']),
...mapState(['viewer', 'currentMergeRequestId']),
2018-05-04 12:03:35 +00:00
showLatestChangesText() {
return !this.currentMergeRequestId || this.viewer === viewerTypes.diff;
2018-05-04 12:03:35 +00:00
},
showMergeRequestText() {
return this.currentMergeRequestId && this.viewer === viewerTypes.mr;
2018-05-04 12:03:35 +00:00
},
2018-06-06 15:10:11 +00:00
mergeRequestId() {
return `!${this.currentMergeRequest.iid}`;
},
},
mounted() {
this.initialize();
},
activated() {
this.initialize();
},
methods: {
2018-07-26 14:56:56 +00:00
...mapActions(['updateViewer', 'resetOpenFiles']),
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);
});
},
},
};
</script>
<template>
<ide-tree-list header-class="ide-review-header">
<template #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="gl-mt-2 ide-review-sub-header">
2018-05-04 12:03:35 +00:00
<template v-if="showLatestChangesText">
{{ __('Latest changes') }}
</template>
2018-05-04 12:03:35 +00:00
<template v-else-if="showMergeRequestText">
2018-11-16 20:07:38 +00:00
{{ __('Merge request') }} (<a
v-if="currentMergeRequest"
:href="currentMergeRequest.web_url"
2018-06-06 15:10:11 +00:00
v-text="mergeRequestId"
2018-11-16 20:07:38 +00:00
></a
>)
</template>
</div>
</template>
</ide-tree-list>
</template>