summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/components/diff_file_header.vue
blob: fc7b52be241759dbb52fb80b082cea81225b3d3f (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<script>
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import Icon from '~/vue_shared/components/icon.vue';

export default {
  components: {
    ClipboardButton,
    Icon,
  },
  props: {
    diffFile: {
      type: Object,
      required: true,
    },
  },
  computed: {
    titleTag() {
      return this.diffFile.discussionPath ? 'a' : 'span';
    },
  },
};
</script>

<template>
  <div class="file-header-content">
    <div
      v-if="diffFile.submodule"
    >
      <span>
        <icon name="archive" />
        <strong
          class="file-title-name"
          v-html="diffFile.submoduleLink"
        ></strong>
        <clipboard-button
          :text="diffFile.submoduleLink"
          title="Copy file path to clipboard"
          css-class="btn-default btn-transparent btn-clipboard"
        />
      </span>
    </div>
    <template v-else>
      <component
        ref="titleWrapper"
        :is="titleTag"
        :href="diffFile.discussionPath"
      >
        <span v-html="diffFile.blobIcon"></span>
        <span v-if="diffFile.renamedFile">
          <strong
            :title="diffFile.oldPath"
            class="file-title-name has-tooltip"
            data-container="body"
          >
            {{ diffFile.oldPath }}
          </strong>
          &rarr;
          <strong
            :title="diffFile.newPath"
            class="file-title-name has-tooltip"
            data-container="body"
          >
            {{ diffFile.newPath }}
          </strong>
        </span>

        <strong
          v-else
          :title="diffFile.oldPath"
          class="file-title-name has-tooltip"
          data-container="body"
        >
          {{ diffFile.filePath }}
          <span v-if="diffFile.deletedFile">
            deleted
          </span>
        </strong>
      </component>

      <clipboard-button
        :text="diffFile.filePath"
        title="Copy file path to clipboard"
        css-class="btn-default btn-transparent btn-clipboard"
      />

      <small
        v-if="diffFile.modeChanged"
        ref="fileMode"
      >
        {{ diffFile.aMode }} → {{ diffFile.bMode }}
      </small>
    </template>
  </div>
</template>