gitlab-org--gitlab-foss/app/assets/javascripts/registry/components/collapsible_container.vue

130 lines
2.9 KiB
Vue
Raw Normal View History

2017-09-15 09:10:08 -04:00
<script>
/* globals Flash */
2017-09-25 07:29:55 -04:00
import { mapActions } from 'vuex';
import '../../flash';
2017-09-15 12:05:46 -04:00
import clipboardButton from '../../vue_shared/components/clipboard_button.vue';
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
import tooltip from '../../vue_shared/directives/tooltip';
import tableRegistry from './table_registry.vue';
2017-09-25 07:29:55 -04:00
import { errorMessages, errorMessagesTypes } from '../constants';
2017-09-15 12:05:46 -04:00
2017-09-15 09:10:08 -04:00
export default {
name: 'collapsibeContainerRegisty',
props: {
repo: {
2017-09-15 12:05:46 -04:00
type: Object,
required: true,
},
2017-09-15 09:10:08 -04:00
},
components: {
2017-09-15 12:05:46 -04:00
clipboardButton,
loadingIcon,
tableRegistry,
},
directives: {
tooltip,
2017-09-15 09:10:08 -04:00
},
data() {
return {
isOpen: false,
};
},
2017-09-27 07:10:01 -04:00
computed: {
clipboardText() {
return `docker pull ${this.repo.location}`;
},
},
2017-09-15 09:10:08 -04:00
methods: {
2017-09-25 07:29:55 -04:00
...mapActions([
'fetchRepos',
2017-09-25 07:29:55 -04:00
'fetchList',
'deleteRepo',
]),
toggleRepo() {
2017-09-25 07:39:16 -04:00
this.isOpen = !this.isOpen;
2017-09-25 07:39:16 -04:00
if (this.isOpen) {
2017-09-25 07:29:55 -04:00
this.fetchList({ repo: this.repo })
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
}
},
handleDeleteRepository() {
2017-09-25 07:29:55 -04:00
this.deleteRepo(this.repo)
.then(() => this.fetchRepos())
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
},
2017-09-25 07:29:55 -04:00
showError(message) {
Flash((errorMessages[message]));
2017-09-22 06:46:55 -04:00
},
},
};
2017-09-15 09:10:08 -04:00
</script>
<template>
<div class="container-image">
<div
class="container-image-head">
2017-09-25 07:29:55 -04:00
<button
type="button"
@click="toggleRepo"
2017-09-25 07:29:55 -04:00
class="js-toggle-repo btn-link">
<i
class="fa"
:class="{
'fa-chevron-right': !isOpen,
'fa-chevron-up': isOpen,
}"
aria-hidden="true">
</i>
{{repo.name}}
2017-09-25 07:29:55 -04:00
</button>
<clipboard-button
v-if="repo.location"
2017-09-27 07:10:01 -04:00
:text="clipboardText"
:title="repo.location"
/>
<div class="controls hidden-xs pull-right">
<button
v-if="repo.canDelete"
type="button"
2017-09-25 07:29:55 -04:00
class="js-remove-repo btn btn-danger"
:title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
v-tooltip
@click="handleDeleteRepository">
<i
class="fa fa-trash"
aria-hidden="true">
</i>
</button>
</div>
2017-09-15 12:05:46 -04:00
</div>
<loading-icon
v-if="repo.isLoading"
/>
2017-09-15 12:05:46 -04:00
<div
v-else-if="!repo.isLoading && isOpen"
class="container-image-tags">
2017-09-15 12:05:46 -04:00
<table-registry
v-if="repo.list.length"
:repo="repo"
/>
2017-09-22 06:46:55 -04:00
2017-09-15 12:05:46 -04:00
<div
v-else
class="nothing-here-block">
2017-09-25 07:29:55 -04:00
{{s__("ContainerRegistry|No tags in Container Registry for this container image.")}}
2017-09-15 12:05:46 -04:00
</div>
</div>
2017-09-15 09:10:08 -04:00
</div>
</template>