summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/registry/components/app.vue
blob: 2d8ca443ea7170bed1433c5a31202e38b231fd34 (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
<script>
  /* globals Flash */
  import { mapGetters, mapActions } from 'vuex';
  import '../../flash';
  import loadingIcon from '../../vue_shared/components/loading_icon.vue';
  import store from '../stores';
  import collapsibleContainer from './collapsible_container.vue';
  import { errorMessages, errorMessagesTypes } from '../constants';

  export default {
    name: 'registryListApp',
    props: {
      endpoint: {
        type: String,
        required: true,
      },
    },
    store,
    components: {
      collapsibleContainer,
      loadingIcon,
    },
    computed: {
      ...mapGetters([
        'isLoading',
        'repos',
      ]),
    },
    methods: {
      ...mapActions([
        'setMainEndpoint',
        'fetchRepos',
      ]),
    },
    created() {
      this.setMainEndpoint(this.endpoint);
    },
    mounted() {
      this.fetchRepos()
        .catch(() => Flash(errorMessages[errorMessagesTypes.FETCH_REPOS]));
    },
  };
</script>
<template>
  <div>
    <loading-icon
      v-if="isLoading"
      size="3"
      />

    <collapsible-container
      v-else-if="!isLoading && repos.length"
      v-for="(item, index) in repos"
      :key="index"
      :repo="item"
      />

    <p v-else-if="!isLoading && !repos.length">
      {{__("No container images stored for this project. Add one by following the instructions above.")}}
    </p>
  </div>
</template>