All files / app/assets/javascripts/repository/components/table parent_row.vue

100% Statements 7/7
100% Branches 2/2
100% Functions 5/5
100% Lines 7/7

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  7x                                             7x 7x   16x     6x         1x           46x                          
<script>
import { GlLoadingIcon } from '@gitlab/ui';
 
export default {
  components: {
    GlLoadingIcon,
  },
  props: {
    commitRef: {
      type: String,
      required: true,
    },
    path: {
      type: String,
      required: true,
    },
    loadingPath: {
      type: String,
      required: false,
      default: null,
    },
  },
  computed: {
    parentPath() {
      const splitArray = this.path.split('/');
      splitArray.pop();
 
      return splitArray.map((p) => encodeURIComponent(p)).join('/');
    },
    parentRoute() {
      return { path: `/-/tree/${this.commitRef}/${this.parentPath}` };
    },
  },
  methods: {
    clickRow() {
      this.$router.push(this.parentRoute);
    },
  },
};
</script>
 
<template>
  <tr class="tree-item">
    <td colspan="3" class="tree-item-file-name" @click.self="clickRow">
      <gl-loading-icon
        v-if="parentPath === loadingPath"
        size="sm"
        inline
        class="d-inline-block align-text-bottom"
      />
      <router-link v-else :to="parentRoute" :aria-label="__('Go to parent')"> .. </router-link>
    </td>
  </tr>
</template>