debian-mirror-gitlab/app/assets/javascripts/registry/components/collapsible_container.vue

135 lines
3.1 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
import { mapActions } from 'vuex';
import Flash from '../../flash';
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';
import { errorMessages, errorMessagesTypes } from '../constants';
2018-11-20 20:47:30 +05:30
import { __ } from '../../locale';
2018-03-17 18:26:18 +05:30
export default {
name: 'CollapsibeContainerRegisty',
components: {
clipboardButton,
loadingIcon,
tableRegistry,
},
directives: {
tooltip,
},
props: {
repo: {
type: Object,
required: true,
},
},
data() {
return {
isOpen: false,
};
},
methods: {
...mapActions([
'fetchRepos',
'fetchList',
'deleteRepo',
]),
toggleRepo() {
this.isOpen = !this.isOpen;
if (this.isOpen) {
this.fetchList({ repo: this.repo })
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
}
},
handleDeleteRepository() {
this.deleteRepo(this.repo)
2018-11-20 20:47:30 +05:30
.then(() => {
Flash(__('This container registry has been scheduled for deletion.'), 'notice');
this.fetchRepos();
})
2018-03-17 18:26:18 +05:30
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
},
showError(message) {
Flash(errorMessages[message]);
},
},
};
</script>
<template>
<div class="container-image">
<div class="container-image-head">
<button
type="button"
class="js-toggle-repo btn-link"
2018-11-08 19:23:39 +05:30
@click="toggleRepo"
2018-03-17 18:26:18 +05:30
>
<i
:class="{
'fa-chevron-right': !isOpen,
'fa-chevron-up': isOpen,
}"
2018-11-08 19:23:39 +05:30
class="fa"
2018-03-17 18:26:18 +05:30
aria-hidden="true"
>
</i>
{{ repo.name }}
</button>
<clipboard-button
v-if="repo.location"
2018-11-08 19:23:39 +05:30
:text="repo.location"
2018-03-17 18:26:18 +05:30
:title="repo.location"
2018-03-27 19:54:05 +05:30
css-class="btn-default btn-transparent btn-clipboard"
2018-03-17 18:26:18 +05:30
/>
2018-11-08 19:23:39 +05:30
<div class="controls d-none d-sm-block float-right">
2018-03-17 18:26:18 +05:30
<button
2018-11-08 19:23:39 +05:30
v-tooltip
2018-03-17 18:26:18 +05:30
v-if="repo.canDelete"
:title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
2018-11-08 19:23:39 +05:30
type="button"
class="js-remove-repo btn btn-danger"
2018-03-17 18:26:18 +05:30
@click="handleDeleteRepository"
>
<i
class="fa fa-trash"
aria-hidden="true"
>
</i>
</button>
</div>
</div>
<loading-icon
v-if="repo.isLoading"
class="append-bottom-20"
size="2"
/>
<div
v-else-if="!repo.isLoading && isOpen"
class="container-image-tags"
>
<table-registry
v-if="repo.list.length"
:repo="repo"
/>
<div
v-else
class="nothing-here-block"
>
{{ s__("ContainerRegistry|No tags in Container Registry for this container image.") }}
</div>
</div>
</div>
</template>