Commit deb894a1 authored by Nick Kipling's avatar Nick Kipling

Changed package details to use gl-table

Updated the package details vue app to use gl-table
Applied styles to match appearance
Added locale method to support translation
parent a4eabca0
...@@ -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,35 +197,24 @@ export default { ...@@ -171,35 +197,24 @@ 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 slot="name" slot-scope="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 slot="created" slot-scope="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 v-slot:modal-title>{{ $options.i18n.deleteModalTitle }}</template>
......
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