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

Table-mode: sort ips numerically #2007

Merged
merged 10 commits into from
Nov 22, 2016
Merged

Table-mode: sort ips numerically #2007

merged 10 commits into from
Nov 22, 2016

Conversation

fbarl
Copy link
Contributor

@fbarl fbarl commented Nov 11, 2016

No description provided.

@fbarl fbarl self-assigned this Nov 11, 2016
@@ -50,6 +51,16 @@ const COLUMN_WIDTHS = {
};


// TODO: Consider introducing the 'ip' dataType for
// the fields instead of maintaining a list here.
const IP_FIELDS = ['kubernetes_ip'];

This comment was marked as abuse.

This comment was marked as abuse.

@fbarl fbarl force-pushed the 1746-sort-ips-numerically branch from a5c682f to bceee78 Compare November 14, 2016 14:48
@fbarl fbarl changed the title [WIP] Table-mode: sort ips numerically Table-mode: sort ips numerically Nov 14, 2016
@fbarl fbarl assigned foot and davkal Nov 14, 2016
Copy link
Contributor

@davkal davkal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good first stab! Have a couple of requests.

@@ -74,13 +80,22 @@ function maybeToLower(value) {
}


function toArrayOfThreeDigitStrings(value) {

This comment was marked as abuse.

This comment was marked as abuse.

@@ -74,13 +80,22 @@ function maybeToLower(value) {
}


function toArrayOfThreeDigitStrings(value) {
const padToThreeDigits = (n) => `000${n}`.slice(-3);

This comment was marked as abuse.

This comment was marked as abuse.

function matchColumnValues(columnLabel, expectedValues) {
const columnIndex = columns.findIndex(column => column.id === columnLabel);
const values = TestUtils.scryRenderedDOMComponentsWithClass(component, 'node-details-table-node-value').map(d => d.title);
const filteredValues = values.filter((element, index) => index % columns.length === columnIndex);

This comment was marked as abuse.

This comment was marked as abuse.

describe('kubernetes_ip', () => {
it('sorts ascendingly', () => {
component = TestUtils.renderIntoDocument(
<Provider store={configureStore()}>

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

{
id: 'node-1',
metadata: [
{ id: 'kubernetes_ip', label: 'IP', value: '10.244.253.24' },

This comment was marked as abuse.

This comment was marked as abuse.

@davkal davkal unassigned foot and davkal Nov 14, 2016
@fbarl fbarl force-pushed the 1746-sort-ips-numerically branch from da8c70f to d9e46c5 Compare November 15, 2016 09:14
Copy link
Contributor Author

@fbarl fbarl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davkal PTAL

@@ -74,13 +80,22 @@ function maybeToLower(value) {
}


function toArrayOfThreeDigitStrings(value) {
const padToThreeDigits = (n) => `000${n}`.slice(-3);

This comment was marked as abuse.

@@ -20,4 +20,13 @@ describe('StringUtils', () => {
expect(fun(['prefix', 'suffix'])).toBe('');
});
});

describe('iPtoPaddedString', () => {
const fun = StringUtils.iPtoPaddedString;

This comment was marked as abuse.

This comment was marked as abuse.

@@ -75,6 +80,11 @@ export function longestCommonPrefix(strArr) {
return (new LCP(strArr)).lcp();
}

// Converts IPs from '10.244.253.4' to '010.244.253.004' format.
export function iPtoPaddedString(value) {

This comment was marked as abuse.

This comment was marked as abuse.

@foot
Copy link
Contributor

foot commented Nov 15, 2016

Nicely done! Keeping the ip as a padded string rather than converting it into a number works really well and still allows for comparisons w/ domains etc too. 👍

I'm not sure if we really need to render the components to test the sorting though.. you could export function getSortedNodes in node-details-table and test that instead (i think?).

@fbarl fbarl force-pushed the 1746-sort-ips-numerically branch from d9e46c5 to 3128bc7 Compare November 15, 2016 09:59
@foot
Copy link
Contributor

foot commented Nov 15, 2016

Ooops! The rebase looks like its gone a bit funny (commits from master now in this branch),

You wanna do something like:

git fetch
git rebase origin/master
git push -f

@fbarl fbarl force-pushed the 1746-sort-ips-numerically branch from 3128bc7 to 3a8b81c Compare November 17, 2016 10:05
@fbarl
Copy link
Contributor Author

fbarl commented Nov 17, 2016

@davkal PTAL before I merge (I will squash all the commits into one as Simon suggested).

@davkal
Copy link
Contributor

davkal commented Nov 22, 2016

LGTM

@fbarl fbarl merged commit d15e884 into master Nov 22, 2016
@fbarl fbarl deleted the 1746-sort-ips-numerically branch January 17, 2017 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants