summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/components/no_changes.vue
blob: 42af2ab7880588a3571489eac75344ac3bea2570 (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
<script>
import { GlButton, GlSprintf } from '@gitlab/ui';
import { mapGetters } from 'vuex';

export default {
  components: {
    GlButton,
    GlSprintf,
  },
  props: {
    changesEmptyStateIllustration: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapGetters('diffs', [
      'diffCompareDropdownTargetVersions',
      'diffCompareDropdownSourceVersions',
    ]),
    ...mapGetters(['getNoteableData']),
    selectedSourceVersion() {
      return this.diffCompareDropdownSourceVersions.find((x) => x.selected);
    },
    sourceName() {
      if (!this.selectedSourceVersion || this.selectedSourceVersion.isLatestVersion) {
        return this.getNoteableData.source_branch;
      }

      return this.selectedSourceVersion.versionName;
    },
    selectedTargetVersion() {
      return this.diffCompareDropdownTargetVersions.find((x) => x.selected);
    },
    targetName() {
      if (!this.selectedTargetVersion || this.selectedTargetVersion.version_index < 0) {
        return this.getNoteableData.target_branch;
      }

      return this.selectedTargetVersion.versionName || '';
    },
  },
};
</script>

<template>
  <div class="row empty-state">
    <div class="col-12">
      <div class="svg-content svg-250"><img :src="changesEmptyStateIllustration" /></div>
    </div>
    <div class="col-12">
      <div class="text-content text-center">
        <div data-testid="no-changes-message">
          <gl-sprintf :message="__('No changes between %{source} and %{target}')">
            <template #source>
              <span class="ref-name">{{ sourceName }}</span>
            </template>
            <template #target>
              <span class="ref-name">{{ targetName }}</span>
            </template>
          </gl-sprintf>
        </div>
        <div class="text-center">
          <gl-button :href="getNoteableData.new_blob_path" variant="confirm" category="primary">{{
            __('Create commit')
          }}</gl-button>
        </div>
      </div>
    </div>
  </div>
</template>