From b7bf7f78df6361e8be3effa2f6170e512944a73b Mon Sep 17 00:00:00 2001 From: Artem Baskal Date: Tue, 8 Dec 2020 15:31:20 +0300 Subject: [PATCH] client: 2353 sort ip in dns rewrites Close #2353 Squashed commit of the following: commit 1072b124c68ff09c6d718acb3aea625fd7b38c4f Merge: 77e9a6f10 6aacb2105 Author: Artem Baskal Date: Tue Dec 8 14:27:06 2020 +0300 Merge branch 'master' into 2353-fix-sort-ip commit 77e9a6f1013e200346b0dc332fd6b7e9e88c8ade Author: Artem Baskal Date: Mon Dec 7 17:38:24 2020 +0300 client: 2353 sort ip in dns rewrites --- client/src/__tests__/helpers.test.js | 8 ++++---- client/src/components/Filters/Rewrites/Table.js | 2 ++ client/src/helpers/helpers.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/src/__tests__/helpers.test.js b/client/src/__tests__/helpers.test.js index 309b40e6..a5ed121b 100644 --- a/client/src/__tests__/helpers.test.js +++ b/client/src/__tests__/helpers.test.js @@ -273,15 +273,15 @@ describe('sortIp', () => { }); }); describe('invalid input', () => { - const originalError = console.error; + const originalWarn = console.warn; beforeEach(() => { - console.error = jest.fn(); + console.warn = jest.fn(); }); afterEach(() => { - expect(console.error).toHaveBeenCalled(); - console.error = originalError; + expect(console.warn).toHaveBeenCalled(); + console.warn = originalWarn; }); test('invalid strings', () => { diff --git a/client/src/components/Filters/Rewrites/Table.js b/client/src/components/Filters/Rewrites/Table.js index 5bc1f678..45638ec0 100644 --- a/client/src/components/Filters/Rewrites/Table.js +++ b/client/src/components/Filters/Rewrites/Table.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import ReactTable from 'react-table'; import { withTranslation } from 'react-i18next'; +import { sortIp } from '../../../helpers/helpers'; class Table extends Component { cellWrap = ({ value }) => ( @@ -21,6 +22,7 @@ class Table extends Component { { Header: this.props.t('answer'), accessor: 'answer', + sortMethod: sortIp, Cell: this.cellWrap, }, { diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 0ace3f08..0cefcfdf 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -687,7 +687,7 @@ export const sortIp = (a, b) => { return 0; } catch (e) { - console.error(e); + console.warn(e); return 0; } };