summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repository/components/table/parent_row.vue
blob: 32bdda2e0a8ee764dccaed35996400965884cd2c (plain)
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
<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/${encodeURIComponent(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>