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,
|
2018-11-07 05:06:15 -05:00
|
|
|
GlLoadingIcon,
|
2018-10-10 02:49:24 -04:00
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
repo: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2017-09-19 11:38:55 -04:00
|
|
|
},
|
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;
|
2017-09-26 07:02:03 -04:00
|
|
|
|
2018-10-10 02:49:24 -04:00
|
|
|
if (this.isOpen) {
|
|
|
|
this.fetchList({ repo: this.repo }).catch(() =>
|
|
|
|
this.showError(errorMessagesTypes.FETCH_REGISTRY),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2017-09-20 14:03:53 -04:00
|
|
|
|
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));
|
|
|
|
},
|
2017-09-20 14:03:53 -04:00
|
|
|
|
2018-10-10 02:49:24 -04:00
|
|
|
showError(message) {
|
|
|
|
Flash(errorMessages[message]);
|
2017-09-19 11:38:55 -04:00
|
|
|
},
|
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">
|
2017-09-19 11:38:55 -04: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"
|
|
|
|
>
|
2017-09-19 11:38:55 -04:00
|
|
|
</i>
|
2018-01-04 19:18:35 -05:00
|
|
|
{{ repo.name }}
|
2017-09-25 07:29:55 -04:00
|
|
|
</button>
|
2017-09-19 11:38:55 -04:00
|
|
|
|
2017-09-20 14:03:53 -04:00
|
|
|
<clipboard-button
|
|
|
|
v-if="repo.location"
|
2018-05-16 06:19:41 -04:00
|
|
|
:text="repo.location"
|
2017-09-20 14:03:53 -04:00
|
|
|
: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
|
|
|
/>
|
2017-09-19 11:38:55 -04:00
|
|
|
|
2018-04-09 17:50:40 -04:00
|
|
|
<div class="controls d-none d-sm-block float-right">
|
2017-09-19 11:38:55 -04:00
|
|
|
<button
|
|
|
|
v-if="repo.canDelete"
|
2018-09-20 02:13:50 -04:00
|
|
|
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>
|
2017-09-19 11:38:55 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
2017-09-15 12:05:46 -04:00
|
|
|
</div>
|
2017-09-19 11:38:55 -04:00
|
|
|
|
2018-11-16 15:07:38 -05:00
|
|
|
<gl-loading-icon v-if="repo.isLoading" :size="2" class="append-bottom-20" />
|
2017-09-19 11:38:55 -04:00
|
|
|
|
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>
|