Conversation
|
|
||
| d3.wordwrap = function (line, maxCharactersPerLine, maxLines = 2) { | ||
| var parts = line.split(/([^a-z][a-z]*)/), //split at non-words | ||
| d3.wordwrap = function (line = '', maxCharactersPerLine = 43, maxLines = 3) { |
There was a problem hiding this comment.
maxCharactersPerLine updated to have a default of 43, maxLines updated to 3 (43 * 3 = 129, most of AWS names are 128 maximum from what I could find).
| d3.wordwrap = function (line, maxCharactersPerLine, maxLines = 2) { | ||
| var parts = line.split(/([^a-z][a-z]*)/), //split at non-words | ||
| d3.wordwrap = function (line = '', maxCharactersPerLine = 43, maxLines = 3) { | ||
| const regexChecks = [/_/ig, /-/ig, /([A-Z])/g]; |
There was a problem hiding this comment.
many bot names are not following a standard naming structure... As such you can find the following names:
test_bot_123
test-bot-123
testBot123
This regex will check all forms and separate accordingly.
ui/js/components/elements/tree.jsx
Outdated
| if (line.search(regexChecks[num]) >= 0) { | ||
| parts = line.replace(regexChecks[num], (num == 2 ? ' $1' : ' ')).split(' '); | ||
| } | ||
| } |
There was a problem hiding this comment.
loop through until you find the correct regex, split accordingly.
if it is camel-case, I had to check with a ternary: (num == 2 ? ' $1' : ' '))
| if (lines.length > maxLines) { | ||
| lines = lines.slice(0, maxLines) | ||
| lines[1] += '...' | ||
| lines[maxLines - 1] += '...' |
There was a problem hiding this comment.
seemed more efficient instead of hardcoding
|
|
||
| nodeText.tspans2(function (d) { | ||
| return d3.wordwrap((d.label || '').toString().replace(/_/ig, ' '), 20) //12 | ||
| return d3.wordwrap((d.label || '')); |
There was a problem hiding this comment.
I didnt see a reason to do any of this here. Let the function do the work.
|
My only concern at this point is the lack of testing. I have no idea how to test any of this code at this point, so this may wait for Clint to return from vacation and assist with testing before merge/release. |
ui/js/components/elements/tree.jsx
Outdated
|
|
||
| for(let num in regexChecks) { | ||
| if (line.search(regexChecks[num]) >= 0) { | ||
| parts = line.replace(regexChecks[num], (num == 2 ? ' $1' : ' ')).split(' '); |
There was a problem hiding this comment.
This will overwrite the array that parts was instantiated as, and will not accumulate more than a single regex replacement - This should instead be something like parts.push(... - Also might be a little cleaner to wrap this loop up as a reduce rather than a for loop.
No description provided.