summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/commit_sidebar/list_collapsed.vue
blob: 4821b8389ff248bc99056265d5041f83605e4549 (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
95
96
97
98
99
100
101
102
103
<script>
import { GlIcon } from '@gitlab/ui';
import tooltip from '~/vue_shared/directives/tooltip';
import { sprintf, n__, __ } from '~/locale';

export default {
  components: {
    GlIcon,
  },
  directives: {
    tooltip,
  },
  props: {
    files: {
      type: Array,
      required: true,
    },
    iconName: {
      type: String,
      required: true,
    },
    title: {
      type: String,
      required: true,
    },
  },
  computed: {
    addedFilesLength() {
      return this.files.filter(f => f.tempFile).length;
    },
    modifiedFilesLength() {
      return this.files.filter(f => !f.tempFile).length;
    },
    addedFilesIconClass() {
      return this.addedFilesLength ? 'multi-file-addition' : '';
    },
    modifiedFilesClass() {
      return this.modifiedFilesLength ? 'multi-file-modified' : '';
    },
    additionsTooltip() {
      return sprintf(
        n__('1 %{type} addition', '%{count} %{type} additions', this.addedFilesLength),
        {
          type: this.title.toLowerCase(),
          count: this.addedFilesLength,
        },
      );
    },
    modifiedTooltip() {
      return sprintf(
        n__('1 %{type} modification', '%{count} %{type} modifications', this.modifiedFilesLength),
        {
          type: this.title.toLowerCase(),
          count: this.modifiedFilesLength,
        },
      );
    },
    titleTooltip() {
      return sprintf(__('%{title} changes'), { title: this.title });
    },
    additionIconName() {
      return this.title.toLowerCase() === 'staged' ? 'file-addition-solid' : 'file-addition';
    },
    modifiedIconName() {
      return this.title.toLowerCase() === 'staged' ? 'file-modified-solid' : 'file-modified';
    },
  },
};
</script>

<template>
  <div class="multi-file-commit-list-collapsed text-center">
    <div
      v-tooltip
      :title="titleTooltip"
      data-container="body"
      data-placement="left"
      class="gl-mb-5"
    >
      <gl-icon v-once :name="iconName" :size="18" />
    </div>
    <div
      v-tooltip
      :title="additionsTooltip"
      data-container="body"
      data-placement="left"
      class="gl-mb-3"
    >
      <gl-icon :name="additionIconName" :size="18" :class="addedFilesIconClass" />
    </div>
    {{ addedFilesLength }}
    <div
      v-tooltip
      :title="modifiedTooltip"
      data-container="body"
      data-placement="left"
      class="gl-mt-3 gl-mb-3"
    >
      <gl-icon :name="modifiedIconName" :size="18" :class="modifiedFilesClass" />
    </div>
    {{ modifiedFilesLength }}
  </div>
</template>