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

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

    <collapsible-container
      v-for="(item, index) in repos"
      v-else-if="!isLoading && repos.length"
      :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>