Commit bb917cd7 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch...

Merge branch '14697-convert-package-registry-file-table-and-rows-into-dedicated-components' into 'master'

Replace html table with gl-table on package details page

Closes #14697

See merge request gitlab-org/gitlab!16375
parents fcbe187d 17e57175
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
GlTooltipDirective, GlTooltipDirective,
GlLink, GlLink,
GlEmptyState, GlEmptyState,
GlTable,
} from '@gitlab/ui'; } from '@gitlab/ui';
import _ from 'underscore'; import _ from 'underscore';
import PackageInformation from './information.vue'; import PackageInformation from './information.vue';
...@@ -13,7 +14,7 @@ import Icon from '~/vue_shared/components/icon.vue'; ...@@ -13,7 +14,7 @@ import Icon from '~/vue_shared/components/icon.vue';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
import PackageType from '../constants'; import PackageType from '../constants';
export default { export default {
...@@ -23,6 +24,7 @@ export default { ...@@ -23,6 +24,7 @@ export default {
GlEmptyState, GlEmptyState,
GlLink, GlLink,
GlModal, GlModal,
GlTable,
Icon, Icon,
PackageInformation, PackageInformation,
}, },
...@@ -126,6 +128,14 @@ export default { ...@@ -126,6 +128,14 @@ export default {
return null; return null;
} }
}, },
filesTableRows() {
return this.files.map(x => ({
name: x.file_name,
downloadPath: x.download_path,
size: this.formatSize(x.size),
created: x.created_at,
}));
},
}, },
methods: { methods: {
formatSize(size) { formatSize(size) {
...@@ -138,6 +148,22 @@ export default { ...@@ -138,6 +148,22 @@ export default {
i18n: { i18n: {
deleteModalTitle: s__(`PackageRegistry|Delete Package Version`), deleteModalTitle: s__(`PackageRegistry|Delete Package Version`),
}, },
filesTableHeaderFields: [
{
key: 'name',
label: __('Name'),
tdClass: 'd-flex align-items-center',
},
{
key: 'size',
label: __('Size'),
},
{
key: 'created',
label: __('Created'),
class: 'text-right',
},
],
}; };
</script> </script>
...@@ -171,38 +197,27 @@ export default { ...@@ -171,38 +197,27 @@ export default {
/> />
</div> </div>
<table class="table"> <gl-table
<thead> :fields="$options.filesTableHeaderFields"
<tr> :items="filesTableRows"
<th>{{ __('Name') }}</th> tbody-tr-class="js-file-row"
<th>{{ __('Size') }}</th> >
<th> <template #name="items">
<span class="pull-right">{{ __('Created') }}</span> <icon name="doc-code" class="space-right" />
</th> <gl-link :href="items.item.downloadPath" class="js-file-download">{{
</tr> items.item.name
</thead> }}</gl-link>
</template>
<tbody> <template #created="items">
<tr v-for="file in files" :key="file.id" class="js-file-row"> <span v-gl-tooltip :title="tooltipTitle(items.item.created)">{{
<td class="d-flex align-items-center"> timeFormated(items.item.created)
<icon name="doc-code" class="space-right" /><gl-link }}</span>
:href="file.download_path" </template>
class="js-file-download" </gl-table>
>{{ file.file_name }}</gl-link
>
</td>
<td>{{ formatSize(file.size) }}</td>
<td>
<span v-gl-tooltip class="pull-right" :title="tooltipTitle(file.created_at)">{{
timeFormated(file.created_at)
}}</span>
</td>
</tr>
</tbody>
</table>
<gl-modal ref="deleteModal" class="js-delete-modal" modal-id="delete-modal"> <gl-modal ref="deleteModal" class="js-delete-modal" modal-id="delete-modal">
<template v-slot:modal-title>{{ $options.i18n.deleteModalTitle }}</template> <template #modal-title>{{ $options.i18n.deleteModalTitle }}</template>
<p v-html="deleteModalDescription"></p> <p v-html="deleteModalDescription"></p>
<div slot="modal-footer" class="w-100"> <div slot="modal-footer" class="w-100">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment