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

110 lines
2.8 KiB
Vue
Raw Normal View History

2017-09-15 09:10:08 -04:00
<script>
2018-10-10 02:49:24 -04:00
import { mapActions } from 'vuex';
2018-11-16 14:29:11 -05:00
import { GlLoadingIcon } from '@gitlab/ui';
2018-10-10 02:49:24 -04:00
import Flash from '../../flash';
import clipboardButton from '../../vue_shared/components/clipboard_button.vue';
import tooltip from '../../vue_shared/directives/tooltip';
import tableRegistry from './table_registry.vue';
import { errorMessages, errorMessagesTypes } from '../constants';
import { __ } from '../../locale';
2017-09-15 12:05:46 -04:00
2018-10-10 02:49:24 -04:00
export default {
name: 'CollapsibeContainerRegisty',
components: {
clipboardButton,
tableRegistry,
GlLoadingIcon,
2018-10-10 02:49:24 -04:00
},
directives: {
tooltip,
},
props: {
repo: {
type: Object,
required: true,
},
2018-10-10 02:49:24 -04:00
},
data() {
return {
isOpen: false,
};
},
methods: {
...mapActions(['fetchRepos', 'fetchList', 'deleteRepo']),
2017-09-25 07:29:55 -04:00
2018-10-10 02:49:24 -04:00
toggleRepo() {
this.isOpen = !this.isOpen;
2018-10-10 02:49:24 -04:00
if (this.isOpen) {
this.fetchList({ repo: this.repo }).catch(() =>
this.showError(errorMessagesTypes.FETCH_REGISTRY),
);
}
},
2018-10-10 02:49:24 -04:00
handleDeleteRepository() {
this.deleteRepo(this.repo)
.then(() => {
Flash(__('This container registry has been scheduled for deletion.'), 'notice');
this.fetchRepos();
})
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
},
2018-10-10 02:49:24 -04:00
showError(message) {
Flash(errorMessages[message]);
},
2018-10-10 02:49:24 -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">
2018-11-16 15:07:38 -05:00
<button type="button" class="js-toggle-repo btn-link" @click="toggleRepo">
<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"
>
2018-11-16 15:07:38 -05:00
<i class="fa fa-trash" aria-hidden="true"> </i>
</button>
</div>
2017-09-15 12:05:46 -04:00
</div>
2018-11-16 15:07:38 -05:00
<gl-loading-icon v-if="repo.isLoading" :size="2" class="append-bottom-20" />
2018-11-16 15:07:38 -05:00
<div v-else-if="!repo.isLoading && isOpen" class="container-image-tags">
<table-registry v-if="repo.list.length" :repo="repo" />
2017-09-15 12:05:46 -04:00
2018-11-16 15:07:38 -05:00
<div v-else 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>