2017-09-15 09:10:08 -04:00
|
|
|
<script>
|
2017-09-25 07:29:55 -04:00
|
|
|
import { mapActions } from 'vuex';
|
|
|
|
import { n__, s__ } from '../../locale';
|
2017-09-15 12:05:46 -04:00
|
|
|
import clipboardButton from '../../vue_shared/components/clipboard_button.vue';
|
2017-09-19 11:38:55 -04:00
|
|
|
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
|
2017-09-22 06:46:55 -04:00
|
|
|
import tablePagination from '../../vue_shared/components/table_pagination.vue';
|
2017-09-19 11:38:55 -04:00
|
|
|
import tooltip from '../../vue_shared/directives/tooltip';
|
2017-09-20 14:03:53 -04:00
|
|
|
import timeagoMixin from '../../vue_shared/mixins/timeago';
|
2017-09-25 07:29:55 -04:00
|
|
|
import { errorMessages, errorMessagesTypes } from '../constants';
|
2017-09-15 12:05:46 -04:00
|
|
|
|
2017-09-15 09:10:08 -04:00
|
|
|
export default {
|
|
|
|
name: 'collapsibeContainerRegisty',
|
|
|
|
props: {
|
2017-09-19 11:38:55 -04:00
|
|
|
repo: {
|
2017-09-15 12:05:46 -04:00
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2017-09-15 09:10:08 -04:00
|
|
|
},
|
|
|
|
components: {
|
2017-09-15 12:05:46 -04:00
|
|
|
clipboardButton,
|
2017-09-19 11:38:55 -04:00
|
|
|
loadingIcon,
|
2017-09-22 06:46:55 -04:00
|
|
|
tablePagination,
|
2017-09-19 11:38:55 -04:00
|
|
|
},
|
2017-09-20 14:03:53 -04:00
|
|
|
mixins: [
|
|
|
|
timeagoMixin,
|
|
|
|
],
|
2017-09-19 11:38:55 -04:00
|
|
|
directives: {
|
|
|
|
tooltip,
|
2017-09-15 09:10:08 -04:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isOpen: false,
|
|
|
|
};
|
|
|
|
},
|
2017-09-22 06:46:55 -04:00
|
|
|
computed: {
|
|
|
|
shouldRenderPagination() {
|
|
|
|
return this.repo.pagination.total > this.repo.pagination.perPage;
|
|
|
|
},
|
|
|
|
},
|
2017-09-15 09:10:08 -04:00
|
|
|
methods: {
|
2017-09-25 07:29:55 -04:00
|
|
|
...mapActions([
|
|
|
|
'fetchList',
|
|
|
|
'deleteRepo',
|
|
|
|
'deleteRegistry',
|
|
|
|
'toggleLoading',
|
|
|
|
]),
|
|
|
|
|
2017-09-19 11:38:55 -04:00
|
|
|
layers(item) {
|
2017-09-25 07:29:55 -04:00
|
|
|
const pluralize = n__('layer', 'layers', item.layers);
|
2017-09-19 11:38:55 -04:00
|
|
|
return `${item.layers} ${pluralize}`;
|
|
|
|
},
|
2017-09-20 14:03:53 -04:00
|
|
|
|
2017-09-19 11:38:55 -04:00
|
|
|
toggleRepo() {
|
|
|
|
if (this.isOpen === false) {
|
2017-09-25 07:29:55 -04:00
|
|
|
this.fetchList({ repo: this.repo })
|
|
|
|
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
|
2017-09-19 11:38:55 -04:00
|
|
|
}
|
|
|
|
this.isOpen = !this.isOpen;
|
|
|
|
},
|
2017-09-20 14:03:53 -04:00
|
|
|
|
2017-09-19 11:38:55 -04:00
|
|
|
handleDeleteRepository() {
|
2017-09-25 07:29:55 -04:00
|
|
|
this.deleteRepo(this.repo)
|
|
|
|
.then(() => this.fetchRepos())
|
|
|
|
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
|
2017-09-19 11:38:55 -04:00
|
|
|
},
|
2017-09-20 14:03:53 -04:00
|
|
|
|
2017-09-19 11:38:55 -04:00
|
|
|
handleDeleteRegistry(registry) {
|
2017-09-25 07:29:55 -04:00
|
|
|
this.deleteRegistry(registry)
|
|
|
|
.then(() => this.fetchRegistry(this.repo))
|
|
|
|
.catch(() => this.showError(errorMessagesTypes.DELETE_REGISTRY));
|
2017-09-19 11:38:55 -04:00
|
|
|
},
|
2017-09-22 06:46:55 -04:00
|
|
|
|
|
|
|
onPageChange(pageNumber) {
|
2017-09-25 07:29:55 -04:00
|
|
|
this.fetchList({ repo: this.repo, page })
|
|
|
|
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
|
|
|
|
},
|
|
|
|
|
|
|
|
clipboardText(text) {
|
|
|
|
return `docker pull ${text}`;
|
|
|
|
},
|
|
|
|
|
|
|
|
showError(message) {
|
|
|
|
Flash((errorMessages[message]));
|
2017-09-22 06:46:55 -04:00
|
|
|
},
|
2017-09-19 11:38:55 -04:00
|
|
|
},
|
|
|
|
};
|
2017-09-15 09:10:08 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="container-image">
|
2017-09-19 11:38:55 -04:00
|
|
|
<div
|
|
|
|
class="container-image-head">
|
2017-09-25 07:29:55 -04:00
|
|
|
<button
|
|
|
|
type="button"
|
2017-09-20 14:03:53 -04:00
|
|
|
@click="toggleRepo"
|
2017-09-25 07:29:55 -04:00
|
|
|
class="js-toggle-repo btn-link">
|
2017-09-19 11:38:55 -04:00
|
|
|
<i
|
|
|
|
class="fa"
|
|
|
|
:class="{
|
|
|
|
'fa-chevron-right': !isOpen,
|
|
|
|
'fa-chevron-up': isOpen,
|
|
|
|
}"
|
|
|
|
aria-hidden="true">
|
|
|
|
</i>
|
|
|
|
{{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"
|
2017-09-25 07:29:55 -04:00
|
|
|
:text="clipboardText(repo.location)"
|
2017-09-20 14:03:53 -04:00
|
|
|
:title="repo.location"
|
|
|
|
/>
|
2017-09-19 11:38:55 -04:00
|
|
|
|
|
|
|
<div class="controls hidden-xs pull-right">
|
|
|
|
<button
|
|
|
|
v-if="repo.canDelete"
|
|
|
|
type="button"
|
2017-09-25 07:29:55 -04:00
|
|
|
class="js-remove-repo btn btn-danger"
|
|
|
|
:title="s__('ContainerRegistry|Remove repository')"
|
|
|
|
:aria-label="s__('ContainerRegistry|Remove repository')"
|
2017-09-19 11:38:55 -04:00
|
|
|
v-tooltip
|
|
|
|
@click="handleDeleteRepository">
|
|
|
|
<i
|
|
|
|
class="fa fa-trash"
|
|
|
|
aria-hidden="true">
|
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
</div>
|
2017-09-15 12:05:46 -04:00
|
|
|
|
|
|
|
</div>
|
2017-09-19 11:38:55 -04:00
|
|
|
|
|
|
|
<loading-icon
|
|
|
|
v-if="repo.isLoading"
|
|
|
|
/>
|
|
|
|
|
2017-09-15 12:05:46 -04:00
|
|
|
<div
|
2017-09-19 11:38:55 -04:00
|
|
|
v-else-if="!repo.isLoading && isOpen"
|
|
|
|
class="container-image-tags">
|
2017-09-15 12:05:46 -04:00
|
|
|
|
2017-09-22 06:46:55 -04:00
|
|
|
<template v-if="repo.list.length">
|
|
|
|
<table class="table tags">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2017-09-25 07:29:55 -04:00
|
|
|
<th>{{s__('ContainerRegistry|Tag')}}</th>
|
|
|
|
<th>{{s__('ContainerRegistry|Tag ID')}}</th>
|
|
|
|
<th>{{s__("ContainerRegistry|Size")}}</th>
|
|
|
|
<th>{{s__("ContainerRegistry|Created")}}</th>
|
2017-09-22 06:46:55 -04:00
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr
|
|
|
|
v-for="(item, i) in repo.list"
|
|
|
|
:key="i">
|
|
|
|
<td>
|
|
|
|
|
|
|
|
{{item.tag}}
|
|
|
|
|
|
|
|
<clipboard-button
|
|
|
|
v-if="item.location"
|
|
|
|
:title="item.location"
|
2017-09-25 07:29:55 -04:00
|
|
|
:text="clipboardText(item.location)"
|
2017-09-22 06:46:55 -04:00
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span
|
|
|
|
v-tooltip
|
|
|
|
:title="item.revision"
|
|
|
|
data-placement="bottom">
|
|
|
|
{{item.shortRevision}}
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<template v-if="item.size">
|
|
|
|
{{item.size}}
|
|
|
|
·
|
|
|
|
{{layers(item)}}
|
|
|
|
</template>
|
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="light">
|
|
|
|
\-
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<template v-if="item.createdAt">
|
|
|
|
{{timeFormated(item.createdAt)}}
|
|
|
|
</template>
|
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="light">
|
|
|
|
\-
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="content">
|
|
|
|
<button
|
|
|
|
v-if="item.canDelete"
|
|
|
|
type="button"
|
2017-09-25 07:29:55 -04:00
|
|
|
class="js-delete-registry btn btn-danger hidden-xs pull-right"
|
|
|
|
:title="s__('ContainerRegistry|Remove tag')"
|
|
|
|
:aria-label="s__('ContainerRegistry|Remove tag')"
|
2017-09-22 06:46:55 -04:00
|
|
|
data-container="body"
|
|
|
|
v-tooltip
|
|
|
|
@click="handleDeleteRegistry(item)">
|
|
|
|
<i
|
|
|
|
class="fa fa-trash"
|
|
|
|
aria-hidden="true">
|
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<table-pagination
|
|
|
|
v-if="shouldRenderPagination"
|
|
|
|
:change="onPageChange"
|
|
|
|
:page-info="repo.pagination"
|
|
|
|
/>
|
|
|
|
</template>
|
2017-09-15 12:05:46 -04:00
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="nothing-here-block">
|
2017-09-25 07:29:55 -04:00
|
|
|
{{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>
|