Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RHINENG-1423): Enable sorting by last modified #2106

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/GroupsTable/GroupsTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import GroupsTable from './GroupsTable';

const DEFAULT_ROW_COUNT = 50;
const TABLE_HEADERS = ['Name', 'Total systems', 'Last modified'];
const SORTABLE_HEADERS = ['Name', 'Total systems'];
const SORTABLE_HEADERS = ['Name', 'Total systems', 'Last modified'];
const ROOT = 'div[id="groups-table"]';

const mountTable = (initialEntry = '/') =>
Expand Down Expand Up @@ -192,11 +192,17 @@ describe('url search parameters', () => {
.should('have.value', '123');
});

it('applies sorting', () => {
it('applies sorting, hosts count', () => {
mountTable('/?order_by=host_count&order_how=desc');

checkSorting('Total systems', 'descending', 'host_count');
});

it('applies sorting, last modified', () => {
mountTable('/?order_by=host_count&order_how=desc');

checkSorting('Last modified', 'descending', 'updated');
});
});

describe('sorting', () => {
Expand All @@ -207,7 +213,7 @@ describe('sorting', () => {
cy.wait('@getGroups'); // first initial request
});

_.zip(['name', 'host_count'], SORTABLE_HEADERS).forEach(
_.zip(['name', 'host_count', 'updated'], SORTABLE_HEADERS).forEach(
([category, label]) => {
SORTING_ORDERS.forEach((order) => {
it(`${order} by ${label}`, () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/GroupsTable/GroupsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ const GROUPS_TABLE_COLUMNS = [
},
{
title: 'Last modified',
transforms: [cellWidth(20)],
transforms: [sortable, cellWidth(20)],
},
];

const GROUPS_TABLE_COLUMNS_TO_URL = {
0: '', // reserved for selection boxes
1: 'name',
2: 'host_count',
3: 'updated_at',
3: 'updated',
};

const REQUEST_DEBOUNCE_TIMEOUT = 500;
Expand Down