Welcome to mirror list, hosted at ThFree Co, Russian Federation.

app_index.vue « components « releases « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 32183e454c8814743573e33c66eb1cae1fdb5260 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<script>
import { GlEmptyState, GlLink, GlButton } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex';
import { getParameterByName } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import ReleaseBlock from './release_block.vue';
import ReleaseSkeletonLoader from './release_skeleton_loader.vue';
import ReleasesPagination from './releases_pagination.vue';
import ReleasesSort from './releases_sort.vue';

export default {
  name: 'ReleasesApp',
  components: {
    GlEmptyState,
    GlLink,
    GlButton,
    ReleaseBlock,
    ReleasesPagination,
    ReleaseSkeletonLoader,
    ReleasesSort,
  },
  computed: {
    ...mapState('list', [
      'documentationPath',
      'illustrationPath',
      'newReleasePath',
      'isLoading',
      'releases',
      'hasError',
    ]),
    shouldRenderEmptyState() {
      return !this.releases.length && !this.hasError && !this.isLoading;
    },
    shouldRenderSuccessState() {
      return this.releases.length && !this.isLoading && !this.hasError;
    },
    emptyStateText() {
      return __(
        "Releases are based on Git tags and mark specific points in a project's development history. They can contain information about the type of changes and can also deliver binaries, like compiled versions of your software.",
      );
    },
  },
  created() {
    this.fetchReleases();

    window.addEventListener('popstate', this.fetchReleases);
  },
  methods: {
    ...mapActions('list', {
      fetchReleasesStoreAction: 'fetchReleases',
    }),
    fetchReleases() {
      this.fetchReleasesStoreAction({
        // these two parameters are only used in "GraphQL mode"
        before: getParameterByName('before'),
        after: getParameterByName('after'),

        // this parameter is only used when in "REST mode"
        page: getParameterByName('page'),
      });
    },
  },
};
</script>
<template>
  <div class="flex flex-column mt-2">
    <div class="gl-align-self-end gl-mb-3">
      <releases-sort class="gl-mr-2" @sort:changed="fetchReleases" />

      <gl-button
        v-if="newReleasePath"
        :href="newReleasePath"
        :aria-describedby="shouldRenderEmptyState && 'releases-description'"
        category="primary"
        variant="success"
        class="js-new-release-btn"
      >
        {{ __('New release') }}
      </gl-button>
    </div>

    <release-skeleton-loader v-if="isLoading" class="js-loading" />

    <gl-empty-state
      v-else-if="shouldRenderEmptyState"
      class="js-empty-state"
      :title="__('Getting started with releases')"
      :svg-path="illustrationPath"
    >
      <template #description>
        <span id="releases-description">
          {{ emptyStateText }}
          <gl-link
            :href="documentationPath"
            :aria-label="__('Releases documentation')"
            target="_blank"
          >
            {{ __('More information') }}
          </gl-link>
        </span>
      </template>
    </gl-empty-state>

    <div v-else-if="shouldRenderSuccessState" class="js-success-state">
      <release-block
        v-for="(release, index) in releases"
        :key="index"
        :release="release"
        :class="{ 'linked-card': releases.length > 1 && index !== releases.length - 1 }"
      />
    </div>

    <releases-pagination v-if="!isLoading" />
  </div>
</template>
<style>
.linked-card::after {
  width: 1px;
  content: ' ';
  border: 1px solid #e5e5e5;
  height: 17px;
  top: 100%;
  position: absolute;
  left: 32px;
}
</style>