-
Notifications
You must be signed in to change notification settings - Fork 712
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
Conversation
@@ -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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
a5c682f
to
bceee78
Compare
There was a problem hiding this 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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
describe('kubernetes_ip', () => { | ||
it('sorts ascendingly', () => { | ||
component = TestUtils.renderIntoDocument( | ||
<Provider store={configureStore()}> |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
{ | ||
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
da8c70f
to
d9e46c5
Compare
There was a problem hiding this 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.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Nicely done! Keeping the I'm not sure if we really need to render the components to test the sorting though.. you could |
d9e46c5
to
3128bc7
Compare
Ooops! The rebase looks like its gone a bit funny (commits from master now in this branch), You wanna do something like:
|
3128bc7
to
3a8b81c
Compare
@davkal PTAL before I merge (I will squash all the commits into one as Simon suggested). |
LGTM |
No description provided.