-
Couldn't load subscription status.
- Fork 6
expanding bot names in main layout #4
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didnt see a reason to do any of this here. Let the function do the work.
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.
Looks good to me!
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.