summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/releases/components/app.vue
blob: 0ad5ee2915c711aa851d800972be172bb3cc9f35 (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
<script>
import { mapState, mapActions } from 'vuex';
import { GlLoadingIcon, GlEmptyState } from '@gitlab/ui';
import ReleaseBlock from './release_block.vue';

export default {
  name: 'ReleasesApp',
  components: {
    GlLoadingIcon,
    GlEmptyState,
    ReleaseBlock,
  },
  props: {
    projectId: {
      type: String,
      required: true,
    },
    documentationLink: {
      type: String,
      required: true,
    },
    illustrationPath: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapState(['isLoading', 'releases', 'hasError']),
    shouldRenderEmptyState() {
      return !this.releases.length && !this.hasError && !this.isLoading;
    },
    shouldRenderSuccessState() {
      return this.releases.length && !this.isLoading && !this.hasError;
    },
  },
  created() {
    this.fetchReleases(this.projectId);
  },
  methods: {
    ...mapActions(['fetchReleases']),
  },
};
</script>
<template>
  <div class="prepend-top-default">
    <gl-loading-icon v-if="isLoading" :size="2" class="js-loading prepend-top-20" />

    <gl-empty-state
      v-else-if="shouldRenderEmptyState"
      class="js-empty-state"
      :title="__('Getting started with releases')"
      :svg-path="illustrationPath"
      :description="
        __(
          'Releases mark specific points in a project\'s development history, communicate information about the type of change, and deliver on prepared, often compiled, versions of the software to be reused elsewhere. Currently, releases can only be created through the API.',
        )
      "
      :primary-button-link="documentationLink"
      :primary-button-text="__('Open Documentation')"
    />

    <div v-else-if="shouldRenderSuccessState" class="js-success-state">
      <release-block
        v-for="(release, index) in releases"
        :key="release.tag_name"
        :release="release"
        :class="{ 'linked-card': releases.length > 1 && index !== releases.length - 1 }"
      />
    </div>
  </div>
</template>
<style>
.linked-card::after {
  width: 1px;
  content: ' ';
  border: 1px solid #e5e5e5;
  height: 17px;
  top: 100%;
  position: absolute;
  left: 32px;
}
</style>