Commit 44cb5673 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Hide unsupported sorting for project VSA stage table

For project VSA we have migrated to the shared stage
table, but we currently do not support sorting.

Adding the sortable prop to the stage table component will allow
us to hide the sorting behaviour for project VSA until it is
supported.
parent 37bba1df
...@@ -173,6 +173,7 @@ export default { ...@@ -173,6 +173,7 @@ export default {
:empty-state-message="emptyStageText" :empty-state-message="emptyStageText"
:no-data-svg-path="noDataSvgPath" :no-data-svg-path="noDataSvgPath"
:pagination="null" :pagination="null"
:sortable="false"
/> />
</div> </div>
</template> </template>
...@@ -23,8 +23,8 @@ import TotalTime from './total_time_component.vue'; ...@@ -23,8 +23,8 @@ import TotalTime from './total_time_component.vue';
const DEFAULT_WORKFLOW_TITLE_PROPERTIES = { const DEFAULT_WORKFLOW_TITLE_PROPERTIES = {
thClass: 'gl-w-half', thClass: 'gl-w-half',
key: PAGINATION_SORT_FIELD_END_EVENT, key: PAGINATION_SORT_FIELD_END_EVENT,
sortable: true,
}; };
const WORKFLOW_COLUMN_TITLES = { const WORKFLOW_COLUMN_TITLES = {
issues: { ...DEFAULT_WORKFLOW_TITLE_PROPERTIES, label: __('Issues') }, issues: { ...DEFAULT_WORKFLOW_TITLE_PROPERTIES, label: __('Issues') },
jobs: { ...DEFAULT_WORKFLOW_TITLE_PROPERTIES, label: __('Jobs') }, jobs: { ...DEFAULT_WORKFLOW_TITLE_PROPERTIES, label: __('Jobs') },
...@@ -84,6 +84,11 @@ export default { ...@@ -84,6 +84,11 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
sortable: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
if (this.pagination) { if (this.pagination) {
...@@ -122,9 +127,11 @@ export default { ...@@ -122,9 +127,11 @@ export default {
key: PAGINATION_SORT_FIELD_DURATION, key: PAGINATION_SORT_FIELD_DURATION,
label: __('Time'), label: __('Time'),
thClass: 'gl-w-half', thClass: 'gl-w-half',
sortable: true,
}, },
]; ].map((field) => ({
...field,
sortable: this.sortable,
}));
}, },
prevPage() { prevPage() {
return Math.max(this.pagination.page - 1, 0); return Math.max(this.pagination.page - 1, 0);
......
...@@ -22,6 +22,7 @@ const findStageEvents = () => wrapper.findAllByTestId('vsa-stage-event'); ...@@ -22,6 +22,7 @@ const findStageEvents = () => wrapper.findAllByTestId('vsa-stage-event');
const findPagination = () => wrapper.findByTestId('vsa-stage-pagination'); const findPagination = () => wrapper.findByTestId('vsa-stage-pagination');
const findTable = () => wrapper.findComponent(GlTable); const findTable = () => wrapper.findComponent(GlTable);
const findTableHead = () => wrapper.find('thead'); const findTableHead = () => wrapper.find('thead');
const findTableHeadColumns = () => findTableHead().findAll('th');
const findStageEventTitle = (ev) => extendedWrapper(ev).findByTestId('vsa-stage-event-title'); const findStageEventTitle = (ev) => extendedWrapper(ev).findByTestId('vsa-stage-event-title');
const findStageTime = () => wrapper.findByTestId('vsa-stage-event-time'); const findStageTime = () => wrapper.findByTestId('vsa-stage-event-time');
const findIcon = (name) => wrapper.findByTestId(`${name}-icon`); const findIcon = (name) => wrapper.findByTestId(`${name}-icon`);
...@@ -244,6 +245,12 @@ describe('StageTable', () => { ...@@ -244,6 +245,12 @@ describe('StageTable', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it('can sort the table by each column', () => {
findTableHeadColumns().wrappers.forEach((w) => {
expect(w.attributes('aria-sort')).toBe('none');
});
});
it('clicking a table column will send tracking information', () => { it('clicking a table column will send tracking information', () => {
triggerTableSort(); triggerTableSort();
...@@ -275,5 +282,17 @@ describe('StageTable', () => { ...@@ -275,5 +282,17 @@ describe('StageTable', () => {
}, },
]); ]);
}); });
describe('with sortable=false', () => {
beforeEach(() => {
wrapper = createComponent({ sortable: false });
});
it('cannot sort the table', () => {
findTableHeadColumns().wrappers.forEach((w) => {
expect(w.attributes('aria-sort')).toBeUndefined();
});
});
});
}); });
}); });
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