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

133 lines
3 KiB
Vue
Raw Normal View History

2017-09-15 09:10:08 -04:00
<script>
2017-09-25 07:29:55 -04:00
import { mapActions } from 'vuex';
2018-01-04 19:18:35 -05:00
import Flash from '../../flash';
2017-09-15 12:05:46 -04:00
import clipboardButton from '../../vue_shared/components/clipboard_button.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';
import { __ } from '../../locale';
2017-09-15 12:05:46 -04:00
2017-09-15 09:10:08 -04:00
export default {
2018-01-04 19:18:35 -05:00
name: 'CollapsibeContainerRegisty',
2017-09-15 09:10:08 -04:00
components: {
2017-09-15 12:05:46 -04:00
clipboardButton,
tableRegistry,
},
directives: {
tooltip,
2017-09-15 09:10:08 -04:00
},
2018-01-04 19:18:35 -05:00
props: {
repo: {
type: Object,
required: true,
},
},
2017-09-15 09:10:08 -04:00
data() {
return {
isOpen: false,
};
},
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(() => {
Flash(__('This container registry has been scheduled for deletion.'), 'notice');
this.fetchRepos();
})
2017-09-25 07:29:55 -04:00
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
},
2017-09-25 07:29:55 -04:00
showError(message) {
2017-10-19 00:02:19 -04:00
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">
2018-01-04 19:18:35 -05:00
<div class="container-image-head">
2017-09-25 07:29:55 -04:00
<button
type="button"
2018-01-04 19:18:35 -05:00
class="js-toggle-repo btn-link"
2018-06-11 05:49:47 -04:00
@click="toggleRepo"
2018-01-04 19:18:35 -05:00
>
<i
:class="{
'fa-chevron-right': !isOpen,
'fa-chevron-up': isOpen,
}"
2018-06-11 05:49:47 -04:00
class="fa"
2018-01-04 19:18:35 -05:00
aria-hidden="true"
>
</i>
2018-01-04 19:18:35 -05:00
{{ repo.name }}
2017-09-25 07:29:55 -04:00
</button>
<clipboard-button
v-if="repo.location"
:text="repo.location"
:title="repo.location"
2018-05-10 15:22:56 -04:00
css-class="btn-default btn-transparent btn-clipboard"
2018-01-04 19:18:35 -05:00
/>
2018-04-09 17:50:40 -04:00
<div class="controls d-none d-sm-block float-right">
<button
v-if="repo.canDelete"
v-tooltip
2017-09-25 07:29:55 -04:00
:title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
2018-06-11 05:49:47 -04:00
type="button"
class="js-remove-repo btn btn-danger"
2018-01-04 19:18:35 -05:00
@click="handleDeleteRepository"
>
<i
class="fa fa-trash"
2018-01-04 19:18:35 -05:00
aria-hidden="true"
>
</i>
</button>
</div>
2017-09-15 12:05:46 -04:00
</div>
2018-09-11 18:19:21 -04:00
<gl-loading-icon
v-if="repo.isLoading"
2018-09-11 18:19:21 -04:00
:size="2"
2017-09-28 06:47:24 -04:00
class="append-bottom-20"
2018-01-04 19:18:35 -05:00
/>
2017-09-15 12:05:46 -04:00
<div
v-else-if="!repo.isLoading && isOpen"
2018-01-04 19:18:35 -05:00
class="container-image-tags"
>
2017-09-15 12:05:46 -04:00
<table-registry
v-if="repo.list.length"
:repo="repo"
2018-01-04 19:18:35 -05:00
/>
2017-09-22 06:46:55 -04:00
2017-09-15 12:05:46 -04:00
<div
v-else
2018-01-04 19:18:35 -05:00
class="nothing-here-block"
>
{{ 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>