Commit eff40efc authored by Miguel Rincon's avatar Miguel Rincon

GlTableLite in favor of GlTable for runners list

This is performance improvement to reduce the bundle size of the
runner UI.

Changelog: performance
parent 0bb0b3b6
<script> <script>
import { GlTable, GlTooltipDirective, GlSkeletonLoader } from '@gitlab/ui'; import { GlTableLite, GlTooltipDirective, GlSkeletonLoader } from '@gitlab/ui';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue'; import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
...@@ -12,7 +12,7 @@ import RunnerTags from './runner_tags.vue'; ...@@ -12,7 +12,7 @@ import RunnerTags from './runner_tags.vue';
export default { export default {
components: { components: {
GlTable, GlTableLite,
GlSkeletonLoader, GlSkeletonLoader,
TooltipOnTruncate, TooltipOnTruncate,
TimeAgo, TimeAgo,
...@@ -35,6 +35,16 @@ export default { ...@@ -35,6 +35,16 @@ export default {
required: true, required: true,
}, },
}, },
computed: {
tableClass() {
// <gl-table-lite> does not provide a busy state, add
// simple support for it.
// See http://bootstrap-vue.org/docs/components/table#table-busy-state
return {
'gl-opacity-6': this.loading,
};
},
},
methods: { methods: {
formatJobCount(jobCount) { formatJobCount(jobCount) {
return formatJobCount(jobCount); return formatJobCount(jobCount);
...@@ -62,8 +72,9 @@ export default { ...@@ -62,8 +72,9 @@ export default {
</script> </script>
<template> <template>
<div> <div>
<gl-table <gl-table-lite
:busy="loading" :aria-busy="loading"
:class="tableClass"
:items="runners" :items="runners"
:fields="$options.fields" :fields="$options.fields"
:tbody-tr-attr="runnerTrAttr" :tbody-tr-attr="runnerTrAttr"
...@@ -72,10 +83,6 @@ export default { ...@@ -72,10 +83,6 @@ export default {
primary-key="id" primary-key="id"
fixed fixed
> >
<template v-if="!runners.length" #table-busy>
<gl-skeleton-loader v-for="i in 4" :key="i" />
</template>
<template #cell(status)="{ item }"> <template #cell(status)="{ item }">
<runner-status-cell :runner="item" /> <runner-status-cell :runner="item" />
</template> </template>
...@@ -116,6 +123,10 @@ export default { ...@@ -116,6 +123,10 @@ export default {
<template #cell(actions)="{ item }"> <template #cell(actions)="{ item }">
<runner-actions-cell :runner="item" /> <runner-actions-cell :runner="item" />
</template> </template>
</gl-table> </gl-table-lite>
<template v-if="!runners.length && loading">
<gl-skeleton-loader v-for="i in 4" :key="i" />
</template>
</div> </div>
</template> </template>
import { GlTable, GlSkeletonLoader } from '@gitlab/ui'; import { GlTableLite, GlSkeletonLoader } from '@gitlab/ui';
import { import {
extendedWrapper, extendedWrapper,
shallowMountExtended, shallowMountExtended,
...@@ -17,7 +17,7 @@ describe('RunnerList', () => { ...@@ -17,7 +17,7 @@ describe('RunnerList', () => {
let wrapper; let wrapper;
const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader);
const findTable = () => wrapper.findComponent(GlTable); const findTable = () => wrapper.findComponent(GlTableLite);
const findHeaders = () => wrapper.findAll('th'); const findHeaders = () => wrapper.findAll('th');
const findRows = () => wrapper.findAll('[data-testid^="runner-row-"]'); const findRows = () => wrapper.findAll('[data-testid^="runner-row-"]');
const findCell = ({ row = 0, fieldKey }) => const findCell = ({ row = 0, fieldKey }) =>
...@@ -143,7 +143,8 @@ describe('RunnerList', () => { ...@@ -143,7 +143,8 @@ describe('RunnerList', () => {
describe('When data is loading', () => { describe('When data is loading', () => {
it('shows a busy state', () => { it('shows a busy state', () => {
createComponent({ props: { runners: [], loading: true } }); createComponent({ props: { runners: [], loading: true } });
expect(findTable().attributes('busy')).toBeTruthy();
expect(findTable().classes('gl-opacity-6')).toBe(true);
}); });
it('when there are no runners, shows an skeleton loader', () => { it('when there are no runners, shows an skeleton loader', () => {
......
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