All files / app/assets/javascripts/ide/components ide_review.vue

83.33% Statements 15/18
70.59% Branches 12/17
88.89% Functions 8/9
83.33% Lines 15/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78  2x 2x 2x 2x                     13x     2x     2x       9x     13x       22x 22x       22x       22x 22x             46x                                                        
<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']),
    showLatestChangesText() {
      return !this.currentMergeRequestId || this.viewer === viewerTypes.diff;
    },
    showMergeRequestText() {
      return this.currentMergeRequestId && this.viewer === viewerTypes.mr;
    },
    mergeRequestId() {
      return `!${this.currentMergeRequest.iid}`;
    },
  },
  mounted() {
    this.initialize();
  },
  activated() {
    this.initialize();
  },
  methods: {
    ...mapActions(['updateViewer', 'resetOpenFiles']),
    initialize() {
I      if (this.activeFile && this.activeFile.pending && !this.activeFile.deleted) {
        this.$router.push(this.getUrlForPath(this.activeFile.path), () => {
          this.updateViewer(viewerTypes.edit);
        });
I      } 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">
        <template v-if="showLatestChangesText">
          {{ __('Latest changes') }}
        </template>
        <template v-else-if="showMergeRequestText">
          {{ __('Merge request') }} (<a
            v-if="currentMergeRequest"
            :href="currentMergeRequest.web_url"
            v-text="mergeRequestId"
          ></a
          >)
        </template>
      </div>
    </template>
  </ide-tree-list>
</template>