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 { GlButton, GlTooltipDirective } from '@gitlab/ui';
|
2018-12-13 13:39:08 +05:30
|
|
|
import { n__ } from '../../locale';
|
2019-02-15 15:39:39 +05:30
|
|
|
import createFlash from '../../flash';
|
|
|
|
import ClipboardButton from '../../vue_shared/components/clipboard_button.vue';
|
|
|
|
import TablePagination from '../../vue_shared/components/table_pagination.vue';
|
|
|
|
import Icon from '../../vue_shared/components/icon.vue';
|
2018-12-13 13:39:08 +05:30
|
|
|
import timeagoMixin from '../../vue_shared/mixins/timeago';
|
|
|
|
import { errorMessages, errorMessagesTypes } from '../constants';
|
|
|
|
import { numberToHumanSize } from '../../lib/utils/number_utils';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
2019-02-15 15:39:39 +05:30
|
|
|
ClipboardButton,
|
|
|
|
TablePagination,
|
|
|
|
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
|
|
|
},
|
|
|
|
mixins: [timeagoMixin],
|
|
|
|
props: {
|
|
|
|
repo: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
shouldRenderPagination() {
|
|
|
|
return this.repo.pagination.total > this.repo.pagination.perPage;
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
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) {
|
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>
|
|
|
|
<table class="table tags">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{ s__('ContainerRegistry|Tag') }}</th>
|
|
|
|
<th>{{ s__('ContainerRegistry|Tag ID') }}</th>
|
2019-02-15 15:39:39 +05:30
|
|
|
<th>{{ s__('ContainerRegistry|Size') }}</th>
|
|
|
|
<th>{{ s__('ContainerRegistry|Created') }}</th>
|
2018-03-17 18:26:18 +05:30
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2019-02-15 15:39:39 +05:30
|
|
|
<tr v-for="item in repo.list" :key="item.tag">
|
2018-03-17 18:26:18 +05:30
|
|
|
<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>
|
2019-02-15 15:39:39 +05:30
|
|
|
<span v-gl-tooltip.bottom :title="item.revision">{{ item.shortRevision }}</span>
|
2018-03-17 18:26:18 +05:30
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ formatSize(item.size) }}
|
2019-02-15 15:39:39 +05:30
|
|
|
<template v-if="item.size && item.layers"
|
|
|
|
>·</template
|
|
|
|
>
|
2018-03-17 18:26:18 +05:30
|
|
|
{{ layers(item) }}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2019-02-15 15:39:39 +05:30
|
|
|
<span v-gl-tooltip.bottom :title="tooltipTitle(item.createdAt)">{{
|
|
|
|
timeFormated(item.createdAt)
|
|
|
|
}}</span>
|
2018-03-17 18:26:18 +05:30
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="content">
|
2019-02-15 15:39:39 +05:30
|
|
|
<gl-button
|
2018-03-17 18:26:18 +05:30
|
|
|
v-if="item.canDelete"
|
2019-02-15 15:39:39 +05:30
|
|
|
v-gl-tooltip
|
2018-03-17 18:26:18 +05:30
|
|
|
:title="s__('ContainerRegistry|Remove tag')"
|
|
|
|
:aria-label="s__('ContainerRegistry|Remove tag')"
|
2019-02-15 15:39:39 +05:30
|
|
|
variant="danger"
|
|
|
|
class="js-delete-registry d-none d-sm-block float-right"
|
|
|
|
@click="handleDeleteRegistry(item);"
|
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
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<table-pagination
|
|
|
|
v-if="shouldRenderPagination"
|
|
|
|
:change="onPageChange"
|
|
|
|
:page-info="repo.pagination"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|