2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
|
|
|
import { mapActions } from 'vuex';
|
|
|
|
import { n__ } from '../../locale';
|
|
|
|
import Flash from '../../flash';
|
|
|
|
import clipboardButton from '../../vue_shared/components/clipboard_button.vue';
|
|
|
|
import tablePagination from '../../vue_shared/components/table_pagination.vue';
|
|
|
|
import tooltip from '../../vue_shared/directives/tooltip';
|
|
|
|
import timeagoMixin from '../../vue_shared/mixins/timeago';
|
|
|
|
import { errorMessages, errorMessagesTypes } from '../constants';
|
|
|
|
import { numberToHumanSize } from '../../lib/utils/number_utils';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
clipboardButton,
|
|
|
|
tablePagination,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
mixins: [
|
|
|
|
timeagoMixin,
|
|
|
|
],
|
|
|
|
props: {
|
|
|
|
repo: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
shouldRenderPagination() {
|
|
|
|
return this.repo.pagination.total > this.repo.pagination.perPage;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions([
|
|
|
|
'fetchList',
|
|
|
|
'deleteRegistry',
|
|
|
|
]),
|
|
|
|
|
|
|
|
layers(item) {
|
|
|
|
return item.layers ? n__('%d layer', '%d layers', item.layers) : '';
|
|
|
|
},
|
|
|
|
|
|
|
|
formatSize(size) {
|
|
|
|
return numberToHumanSize(size);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleDeleteRegistry(registry) {
|
|
|
|
this.deleteRegistry(registry)
|
|
|
|
.then(() => this.fetchList({ repo: this.repo }))
|
|
|
|
.catch(() => this.showError(errorMessagesTypes.DELETE_REGISTRY));
|
|
|
|
},
|
|
|
|
|
|
|
|
onPageChange(pageNumber) {
|
|
|
|
this.fetchList({ repo: this.repo, page: pageNumber })
|
|
|
|
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
|
|
|
|
},
|
|
|
|
|
|
|
|
showError(message) {
|
|
|
|
Flash(errorMessages[message]);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<table class="table tags">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{ s__('ContainerRegistry|Tag') }}</th>
|
|
|
|
<th>{{ s__('ContainerRegistry|Tag ID') }}</th>
|
|
|
|
<th>{{ s__("ContainerRegistry|Size") }}</th>
|
|
|
|
<th>{{ s__("ContainerRegistry|Created") }}</th>
|
|
|
|
<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"
|
2018-11-08 19:23:39 +05:30
|
|
|
:text="item.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
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span
|
|
|
|
v-tooltip
|
|
|
|
:title="item.revision"
|
|
|
|
data-placement="bottom"
|
|
|
|
>
|
|
|
|
{{ item.shortRevision }}
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ formatSize(item.size) }}
|
|
|
|
<template v-if="item.size && item.layers">
|
|
|
|
·
|
|
|
|
</template>
|
|
|
|
{{ layers(item) }}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2018-11-08 19:23:39 +05:30
|
|
|
<span
|
|
|
|
v-tooltip
|
|
|
|
:title="tooltipTitle(item.createdAt)"
|
|
|
|
data-placement="bottom"
|
|
|
|
>
|
|
|
|
{{ timeFormated(item.createdAt) }}
|
|
|
|
</span>
|
2018-03-17 18:26:18 +05:30
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="content">
|
|
|
|
<button
|
|
|
|
v-if="item.canDelete"
|
2018-12-05 23:21:45 +05:30
|
|
|
v-tooltip
|
2018-03-17 18:26:18 +05:30
|
|
|
:title="s__('ContainerRegistry|Remove tag')"
|
|
|
|
:aria-label="s__('ContainerRegistry|Remove tag')"
|
2018-11-08 19:23:39 +05:30
|
|
|
type="button"
|
|
|
|
class="js-delete-registry btn btn-danger d-none d-sm-block float-right"
|
2018-03-17 18:26:18 +05:30
|
|
|
data-container="body"
|
|
|
|
@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"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|