2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2018-12-13 13:39:08 +05:30
|
|
|
import { mapActions } from 'vuex';
|
2019-09-30 21:07:59 +05:30
|
|
|
import { GlLoadingIcon, GlButton, GlTooltipDirective, GlModal, GlModalDirective } from '@gitlab/ui';
|
2019-02-15 15:39:39 +05:30
|
|
|
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,
|
2019-09-30 21:07:59 +05:30
|
|
|
GlModal,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
directives: {
|
2019-02-15 15:39:39 +05:30
|
|
|
GlTooltip: GlTooltipDirective,
|
2019-09-30 21:07:59 +05:30
|
|
|
GlModal: GlModalDirective,
|
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-09-30 21:07:59 +05:30
|
|
|
modalId: `confirm-repo-deletion-modal-${this.repo.id}`,
|
2018-12-13 13:39:08 +05:30
|
|
|
};
|
|
|
|
},
|
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: {
|
2019-09-30 21:07:59 +05:30
|
|
|
...mapActions(['fetchRepos', 'fetchList', 'deleteItem']),
|
2018-12-13 13:39:08 +05:30
|
|
|
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() {
|
2019-09-30 21:07:59 +05:30
|
|
|
this.deleteItem(this.repo)
|
2018-12-13 13:39:08 +05:30
|
|
|
.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
|
2019-09-30 21:07:59 +05:30
|
|
|
v-gl-modal="modalId"
|
2018-03-17 18:26:18 +05:30
|
|
|
:title="s__('ContainerRegistry|Remove repository')"
|
|
|
|
:aria-label="s__('ContainerRegistry|Remove repository')"
|
2019-10-12 21:52:04 +05:30
|
|
|
class="js-remove-repo btn-inverted"
|
2019-02-15 15:39:39 +05:30
|
|
|
variant="danger"
|
2018-03-17 18:26:18 +05:30
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
<icon name="remove" />
|
|
|
|
</gl-button>
|
2018-03-17 18:26:18 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
<gl-loading-icon v-if="repo.isLoading" size="md" 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>
|
2019-09-30 21:07:59 +05:30
|
|
|
<gl-modal :modal-id="modalId" ok-variant="danger" @ok="handleDeleteRepository">
|
|
|
|
<template v-slot:modal-title>{{ s__('ContainerRegistry|Remove repository') }}</template>
|
|
|
|
<p
|
|
|
|
v-html="
|
|
|
|
sprintf(
|
|
|
|
s__(
|
|
|
|
'ContainerRegistry|You are about to remove repository <b>%{title}</b>. Once you confirm, this repository will be permanently deleted.',
|
|
|
|
),
|
|
|
|
{ title: repo.name },
|
|
|
|
)
|
|
|
|
"
|
|
|
|
></p>
|
|
|
|
<template v-slot:modal-ok>{{ __('Remove') }}</template>
|
|
|
|
</gl-modal>
|
2018-03-17 18:26:18 +05:30
|
|
|
</div>
|
|
|
|
</template>
|