Commit a172b543 authored by Nick Kipling's avatar Nick Kipling

Applying maintainer feedback

Tidied header field generation
Created shared util for determining header fields
Updated snapshot test
parent 7f06b11a
...@@ -12,12 +12,8 @@ import { ...@@ -12,12 +12,8 @@ import {
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { import { LIST_KEY_ACTIONS, LIST_LABEL_ACTIONS } from '../constants';
LIST_KEY_PROJECT, import getTableHeaders from '../utils';
LIST_KEY_ACTIONS,
LIST_LABEL_ACTIONS,
TABLE_HEADER_FIELDS,
} from '../constants';
import { TrackingActions } from '../../shared/constants'; import { TrackingActions } from '../../shared/constants';
import { packageTypeToTrackCategory } from '../../shared/utils'; import { packageTypeToTrackCategory } from '../../shared/utils';
import PackageTags from '../../shared/components/package_tags.vue'; import PackageTags from '../../shared/components/package_tags.vue';
...@@ -66,18 +62,13 @@ export default { ...@@ -66,18 +62,13 @@ export default {
return !this.isGroupPage; return !this.isGroupPage;
}, },
headerFields() { headerFields() {
const fields = TABLE_HEADER_FIELDS.filter( const fields = getTableHeaders(this.isGroupPage);
f => f.key !== LIST_KEY_PROJECT || this.isGroupPage,
);
if (this.showActions) { if (this.showActions) {
const actions = { fields.push({
key: LIST_KEY_ACTIONS, key: LIST_KEY_ACTIONS,
label: LIST_LABEL_ACTIONS, label: LIST_LABEL_ACTIONS,
tdClass: ['text-right'], });
};
return [...fields, actions];
} }
fields[fields.length - 1].class = ['text-right']; fields[fields.length - 1].class = ['text-right'];
......
...@@ -68,7 +68,7 @@ export default { ...@@ -68,7 +68,7 @@ export default {
</script> </script>
<template> <template>
<gl-tabs active-tab-class="js-package-active-tab" @input="tabChanged"> <gl-tabs @input="tabChanged">
<template #tabs-end> <template #tabs-end>
<div class="align-self-center ml-auto"> <div class="align-self-center ml-auto">
<package-sort @sort:changed="requestPackagesList" /> <package-sort @sort:changed="requestPackagesList" />
......
<script> <script>
import { GlSorting, GlSortingItem } from '@gitlab/ui'; import { GlSorting, GlSortingItem } from '@gitlab/ui';
import { import { ASCENDING_ODER, DESCENDING_ORDER } from '../constants';
LIST_KEY_PROJECT, import getTableHeaders from '../utils';
ASCENDING_ODER,
DESCENDING_ORDER,
TABLE_HEADER_FIELDS,
} from '../constants';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
export default { export default {
...@@ -25,8 +21,7 @@ export default { ...@@ -25,8 +21,7 @@ export default {
return field ? field.label : ''; return field ? field.label : '';
}, },
sortableFields() { sortableFields() {
// This list is filtered in the case of the project page, and the project column is removed return getTableHeaders(this.isGroupPage);
return TABLE_HEADER_FIELDS.filter(f => f.key !== LIST_KEY_PROJECT || this.isGroupPage);
}, },
isSortAscending() { isSortAscending() {
return this.sort === ASCENDING_ODER; return this.sort === ASCENDING_ODER;
......
import { LIST_KEY_PROJECT, TABLE_HEADER_FIELDS } from './constants';
export default isGroupPage =>
TABLE_HEADER_FIELDS.filter(f => f.key !== LIST_KEY_PROJECT || isGroupPage);
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
exports[`packages_list_app renders 1`] = ` exports[`packages_list_app renders 1`] = `
<b-tabs-stub <b-tabs-stub
activenavitemclass="gl-tab-nav-item-active gl-tab-nav-item-active-indigo" activenavitemclass="gl-tab-nav-item-active gl-tab-nav-item-active-indigo"
activetabclass="js-package-active-tab"
class="gl-tabs" class="gl-tabs"
contentclass=",gl-tab-content" contentclass=",gl-tab-content"
navclass="gl-tabs-nav" navclass="gl-tabs-nav"
......
...@@ -41,7 +41,7 @@ describe('packages_list_app', () => { ...@@ -41,7 +41,7 @@ describe('packages_list_app', () => {
config: { config: {
resourceId: 'project_id', resourceId: 'project_id',
emptyListIllustration: 'helpSvg', emptyListIllustration: 'helpSvg',
emptyListHelpUrl: 'helpUrl', emptyListHelpUrl,
}, },
}, },
}); });
...@@ -62,9 +62,14 @@ describe('packages_list_app', () => { ...@@ -62,9 +62,14 @@ describe('packages_list_app', () => {
it('generate the correct empty list link', () => { it('generate the correct empty list link', () => {
const link = findListComponent().find('a'); const link = findListComponent().find('a');
expect(link.html()).toMatchInlineSnapshot( expect(link.element).toMatchInlineSnapshot(`
`"<a href=\\"${emptyListHelpUrl}\\" target=\\"_blank\\">publish and share your packages</a>"`, <a
); href="${emptyListHelpUrl}"
target="_blank"
>
publish and share your packages
</a>
`);
}); });
it('includes the right content on the default tab', () => { it('includes the right content on the default tab', () => {
......
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