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

103 lines
2.7 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2018-12-13 13:39:08 +05:30
import { mapActions } from 'vuex';
2019-02-15 15:39:39 +05:30
import { GlLoadingIcon, GlButton, GlTooltipDirective } from '@gitlab/ui';
import createFlash from '../../flash';
import ClipboardButton from '../../vue_shared/components/clipboard_button.vue';
import Icon from '../../vue_shared/components/icon.vue';
import TableRegistry from './table_registry.vue';
2018-12-13 13:39:08 +05:30
import { errorMessages, errorMessagesTypes } from '../constants';
import { __ } from '../../locale';
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
export default {
name: 'CollapsibeContainerRegisty',
components: {
2019-02-15 15:39:39 +05:30
ClipboardButton,
TableRegistry,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2019-02-15 15:39:39 +05:30
GlButton,
Icon,
2018-12-13 13:39:08 +05:30
},
directives: {
2019-02-15 15:39:39 +05:30
GlTooltip: GlTooltipDirective,
2018-12-13 13:39:08 +05:30
},
props: {
repo: {
type: Object,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
},
data() {
return {
isOpen: false,
};
},
2019-02-15 15:39:39 +05:30
computed: {
iconName() {
return this.isOpen ? 'angle-up' : 'angle-right';
},
},
2018-12-13 13:39:08 +05:30
methods: {
...mapActions(['fetchRepos', 'fetchList', 'deleteRepo']),
toggleRepo() {
this.isOpen = !this.isOpen;
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
if (this.isOpen) {
2019-02-15 15:39:39 +05:30
this.fetchList({ repo: this.repo });
2018-12-13 13:39:08 +05:30
}
},
handleDeleteRepository() {
this.deleteRepo(this.repo)
.then(() => {
2019-02-15 15:39:39 +05:30
createFlash(__('This container registry has been scheduled for deletion.'), 'notice');
2018-12-13 13:39:08 +05:30
this.fetchRepos();
})
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
},
showError(message) {
2019-02-15 15:39:39 +05:30
createFlash(errorMessages[message]);
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<div class="container-image">
<div class="container-image-head">
2019-02-15 15:39:39 +05:30
<gl-button class="js-toggle-repo btn-link align-baseline" @click="toggleRepo">
<icon :name="iconName" /> {{ repo.name }}
</gl-button>
2018-03-17 18:26:18 +05:30
<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">
2019-02-15 15:39:39 +05:30
<gl-button
2018-03-17 18:26:18 +05:30
v-if="repo.canDelete"
2019-02-15 15:39:39 +05:30
v-gl-tooltip
2018-03-17 18:26:18 +05:30
:title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
2019-02-15 15:39:39 +05:30
class="js-remove-repo"
variant="danger"
2018-03-17 18:26:18 +05:30
@click="handleDeleteRepository"
>
2019-02-15 15:39:39 +05:30
<icon name="remove" />
</gl-button>
2018-03-17 18:26:18 +05:30
</div>
</div>
2019-02-15 15:39:39 +05:30
<gl-loading-icon v-if="repo.isLoading" :size="2" class="append-bottom-20" />
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
<div v-else-if="!repo.isLoading && isOpen" class="container-image-tags">
<table-registry v-if="repo.list.length" :repo="repo" />
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
<div v-else class="nothing-here-block">
{{ s__('ContainerRegistry|No tags in Container Registry for this container image.') }}
2018-03-17 18:26:18 +05:30
</div>
</div>
</div>
</template>