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 sorting by string values #1936

Merged
merged 4 commits into from
Jan 22, 2020
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
31 changes: 16 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Lower memory usage when getting a report [#1858](https://github.com/greenbone/gvmd/pull/1858)

### Fixed
- Fix broken entity links for reportformat, scanconfig and portlist [#1934](https://github.com/greenbone/gsa/pull/1934)
- Fixed sorting columns with empty string values [#1936](https://github.com/greenbone/gsa/pull/1936)
- Fixed broken entity links for reportformat, scanconfig and portlist [#1934](https://github.com/greenbone/gsa/pull/1934)
- Fixed removing levels filter keyword if all severity levels are unchecked [#1869](https://github.com/greenbone/gsa/pull/1869)
- Fixed sorting of hosts in report details [#1860](https://github.com/greenbone/gsa/pull/1860)
- Fixed displaying update indication at all report details tabs [#1849](https://github.com/greenbone/gsa/pull/1849)
Expand All @@ -73,37 +74,37 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Use correct link for ManualIcon [#1835](https://github.com/greenbone/gsa/pull/1835)
- Fixed getting InvalidStateError with IE 11 on XHR creation [#1769](https://github.com/greenbone/gsa/pull/1769)
- Fixed filtering general command permissions in roles [#1734](https://github.com/greenbone/gsa/pull/1734)
- Fix getting details in delta report [#1732](https://github.com/greenbone/gsa/pull/1732)
- Fixed getting details in delta report [#1732](https://github.com/greenbone/gsa/pull/1732)
- Include results (details=1) in report download [#1731](https://github.com/greenbone/gsa/pull/1731)
- Fixed High column in hosts table for reports [#1730](https://github.com/greenbone/gsa/pull/1730)
- Fix setting the user default filter in report results [#1699](https://github.com/greenbone/gsa/pull/1699)
- Fixed setting the user default filter in report results [#1699](https://github.com/greenbone/gsa/pull/1699)
- Use new model construction in some commands [#1665](https://github.com/greenbone/gsa/pull/1665)
- Fixed auth_method preselection for user dialog [#1661](https://github.com/greenbone/gsa/pull/1661)
- Fixed userId, roleId and groupId not rendering in create entity permissions dialog [#1658](https://github.com/greenbone/gsa/pull/1658)
- Don't crash Schedule details and list pages if invalid ical data is loaded [#1656](https://github.com/greenbone/gsa/pull/1656)
- Fix showing loading indicator in content composers [#1613](https://github.com/greenbone/gsa/pull/1613)
- Fixed showing loading indicator in content composers [#1613](https://github.com/greenbone/gsa/pull/1613)
- Enable downloading csv in table dashboard [#1611](https://github.com/greenbone/gsa/pull/1611)
- Fixed 404 URL handling in gsad which caused a XSS vulnerability [#1603](https://github.com/greenbone/gsa/pull/1603)
- Fixed status of Tickets for task.isInTrash() and isOrphan [#1592](https://github.com/greenbone/gsa/pull/1592)
- Fix and improve editing of roles [#1587](https://github.com/greenbone/gsa/pull/1587)
- Fix showing ScanConfig trends [#1582](https://github.com/greenbone/gsa/pull/1582) [#1554](https://github.com/greenbone/gsa/pull/1554)
- Fixed and improve editing of roles [#1587](https://github.com/greenbone/gsa/pull/1587)
- Fixed showing ScanConfig trends [#1582](https://github.com/greenbone/gsa/pull/1582) [#1554](https://github.com/greenbone/gsa/pull/1554)
- Show HostsCount at SectionTitle [#1576](https://github.com/greenbone/gsa/pull/1576)
- Fixed creating target from hosts [#1575](https://github.com/greenbone/gsa/pull/1575)
- Fixed CVSSBaseCalculatorv2 [#1572](https://github.com/greenbone/gsa/pull/1572)
- Fix title in Operating Systems table of Reports [#1567](https://github.com/greenbone/gsa/pull/1567)
- Fix displaying only usable report formats at report download [#1565](https://github.com/greenbone/gsa/pull/1565)
- Fix handling schedule_periods ("once" option) in TaskDialog [#1563](https://github.com/greenbone/gsa/pull/1563)
- Fix showing inactive VerifyIcon at ReportFormats detailspage [#1554](https://github.com/greenbone/gsa/pull/1554)
- Fix showing SensorIcon for tasks [#1548](https://github.com/greenbone/gsa/pull/1548)
- Fixed title in Operating Systems table of Reports [#1567](https://github.com/greenbone/gsa/pull/1567)
- Fixed displaying only usable report formats at report download [#1565](https://github.com/greenbone/gsa/pull/1565)
- Fixed handling schedule_periods ("once" option) in TaskDialog [#1563](https://github.com/greenbone/gsa/pull/1563)
- Fixed showing inactive VerifyIcon at ReportFormats detailspage [#1554](https://github.com/greenbone/gsa/pull/1554)
- Fixed showing SensorIcon for tasks [#1548](https://github.com/greenbone/gsa/pull/1548)
- Always show an identifier for results [#1543](https://github.com/greenbone/gsa/pull/1543)
- Don't crash Alerts listpage and trashcan when Alert data is missing [#1541](https://github.com/greenbone/gsa/pull/1541)
- Fix calculating the next date of schedules [#1539](https://github.com/greenbone/gsa/pull/1539)
- Fix linking to best OS in host details [#1528](https://github.com/greenbone/gsa/pull/1528)
- Fixed calculating the next date of schedules [#1539](https://github.com/greenbone/gsa/pull/1539)
- Fixed linking to best OS in host details [#1528](https://github.com/greenbone/gsa/pull/1528)
- Redirect to root URL by default [#1517](https://github.com/greenbone/gsa/pull/1517)
- Fix showing details for tasks [#1515](https://github.com/greenbone/gsa/pull/1515)
- Fixed showing details for tasks [#1515](https://github.com/greenbone/gsa/pull/1515)
- Allow to use additional options for starting gsad via systemd
[#1514](https://github.com/greenbone/gsa/pull/1514)
- Fix using filename templates from usersettings [#1512](https://github.com/greenbone/gsa/pull/1512)
- Fixed using filename templates from usersettings [#1512](https://github.com/greenbone/gsa/pull/1512)
- Update manpage [#1616](https://github.com/greenbone/gsa/pull/1616)

[8.0.2]: https://github.com/greenbone/gsa/compare/v8.0.1...gsa-8.0
Expand Down
20 changes: 20 additions & 0 deletions gsa/src/web/utils/__tests__/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,22 @@ describe('makeCompareString tests', () => {
const objD = {
value: 1, // will be converted to string
};
const objE = {
value: undefined,
};
const objF = {
value: 'z',
};

const compareValues = makeCompareString('value')();
expect(compareValues(objA, objB)).toEqual(-1);
expect(compareValues(objB, objA)).toEqual(1);
expect(compareValues(objA, objC)).toEqual(0);
expect(compareValues(objA, objD)).toEqual(1);
expect(compareValues(objE, objA)).toEqual(-1);
expect(compareValues(objA, objE)).toEqual(1);
expect(compareValues(objE, objF)).toEqual(-1);
expect(compareValues(objF, objE)).toEqual(1);
});

test('should compare strings desc', () => {
Expand All @@ -133,12 +143,22 @@ describe('makeCompareString tests', () => {
const objD = {
value: 1, // will be converted to string
};
const objE = {
value: undefined,
};
const objF = {
value: 'z',
};

const compareValues = makeCompareString('value')(true);
expect(compareValues(objA, objB)).toEqual(1);
expect(compareValues(objB, objA)).toEqual(-1);
expect(compareValues(objA, objC)).toEqual(0);
expect(compareValues(objA, objD)).toEqual(-1);
expect(compareValues(objE, objA)).toEqual(1);
expect(compareValues(objA, objE)).toEqual(-1);
expect(compareValues(objE, objF)).toEqual(1);
expect(compareValues(objF, objE)).toEqual(-1);
});
});

Expand Down
2 changes: 1 addition & 1 deletion gsa/src/web/utils/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const makeCompare = convertFunc => (property, undefinedVal) => (
);
};

export const makeCompareString = makeCompare(value => '' + value);
export const makeCompareString = makeCompare((value = '') => '' + value);

export const makeCompareNumber = makeCompare(parseFloat);

Expand Down