-
Notifications
You must be signed in to change notification settings - Fork 2k
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
UI: Alloc FS: File Viewer #6048
Conversation
Based on the task-log component. Commonalities will be refactored.
The new streaming-file component takes an arbitrary logger component along with some mode flags and handles things like polling, DOM updates, and scroll position.
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.
Nice thorough tests! I found some UX problems that I added GIFs for in various comments, though I didn’t dig in to know where the problems they indicate actually are. But this is looking good, close to ready, IMO.
<span class="image-file-caption-primary"> | ||
<strong data-test-file-name>{{fileName}}</strong> | ||
{{#if (and width height)}} | ||
<span data-test-file-stats>({{width}}px × {{height}}{{#if size}}px, {{format-bytes size}}{{/if}})</span> |
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.
The height px
probably belongs outside the #if
?
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.
Yep 🙈
display: block; | ||
color: $grey-light; | ||
font-style: italic; | ||
} |
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 don’t see this style used anywhere, is it an orphan from a previous approach?
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.
Indeed. Will delete.
ui/app/components/task-file.js
Outdated
|
||
isLarge: computed('stat.Size', function() { | ||
return this.stat.Size > 50000; | ||
}), |
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.
Not a big thing but could use gt
?
{{else}} | ||
<div data-test-unsupported-type class="empty-message is-hollow"> | ||
<h3 class="empty-message-headline">Unsupported File Type</h3> | ||
<p class="empty-message-body message">The Nomad UI could not render this file, but you can still call view the file directly.</p> |
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.
Maybe call
is a relic of a previous wording?
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.
Um, how it got there is lost to time, but I'll remove it 🔪
offset: 4, | ||
message: 'One fish, Two fish. Red fish, Blue fish.', | ||
}, | ||
}, |
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.
Nice unit test!
@@ -20,7 +20,6 @@ module('Unit | Adapter | Node', function(hooks) { | |||
this.server.create('allocation', { id: 'node-1-2', nodeId: 'node-1' }); | |||
this.server.create('allocation', { id: 'node-2-1', nodeId: 'node-2' }); | |||
this.server.create('allocation', { id: 'node-2-2', nodeId: 'node-2' }); | |||
this.server.logging = true; |
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 was wondering about this!
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 deletion was special enough to get its own commit 🤓
It was already in the code (as evident by the diff) and I just happened to notice it spewing log lines in the test runner.
If you aren't familiar with this.server.logging = true
, it logs every HTTP request that goes through Pretender. Great for debugging, super noisy though.
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.
yeah, what do you think of this kind of solution that lets you add a query parameter to turn on logging? I like it more than having to edit code 😆
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.
ooOOOoo, that's quite neat indeed. I like that. And nothing about the qunit runner removes that query param in an annoying manner?
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 haven’t had any trouble with it so far! 🎉
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.
+1 to doing this. We do this in consul lots, but we use document.cookie
instead of query params. Using cookies means settings stick around when the URL changes, which is handy. Then we use Web Inspector to edit the cookies, which turns the Web Inspector into kind of a semi 'dev preferences' panel.
Actually, we didn't ever add a setting to turn HTTP logging on and off (we use it more to control mocks/doubles), but I think I'd add that also as we have some noisy logging going on aswell which I don't mind but other folks might.
oh yes, one other thing I meant to include, is that I think the spacing in the breadcrumbs looks a bit off when viewing a file vs a directory I’m not sure what’s preferable: make the container the same height for both to avoid jumping when browsing from a directory into a file, or have the text move down when it’s a file…?? |
Hey folks the other thing I've noticed here (thanks for the grabs @backspace !), there's a lot of testing for emojis going on here, which I believe are URL safe (yet multibyte). Are there tests for paths/filenames with things like spaces and question marks, I can't see anything here? I also had a quick look in the other PRs related to this but I didn't see anything (but I might have missed it). Is this something being tested for elsewhere? John |
This was causing elements to flow off the page, since the element was assuming 100% but also had a 250px margin for the left column. This had previously been "fixed" by setting overflow-x: auto, but that resulted in tooltips from being clipped. This is a better solution to the same problem.
Ooookay, all comments addressed! Everything is in new commits, so that's probably the easiest way to re-review, but I'll go over some of the bigger things.
|
Hey @DingoEatingFuzz , I gave the URL chars a try, some work, but I could definitely get things to go awry with Don't let this hold you up though, if you want to move on with this and look at that later. John |
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.
Thanks for all the changes, my only remaining concerns relate to flapping tests; I’m not sure why the PR build has the failure in the “viewing a file” test and the push build doesn’t, but they both have log messages about “Decycle max depth reached at 6” and significant accompanying noise, maybe it’s related?
When running the tests locally, I occasionally get this failure (in addition to getting the “viewing a file” one once):
It’s rarely happening but still worrisome 😳
ETA: I keep running with the fs
filter and I got this failure too:
ba8305d
to
d36bdf3
Compare
One last re-review? 🤞 I addressed the character encoding issue and fixed the flapping tests (which were due to illegal characters I added to further test the encoding issue). |
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.
ui/out
Outdated
@@ -0,0 +1,1317 @@ | |||
Environment: test |
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 like a stray inclusion of this file?
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.
Lol, I can't win.
d36bdf3
to
a321145
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.
yay 🎉
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Completes the feature set of the allocation explorer by making files viewable. File viewing currently supports:
If a file is not supported by the viewer, there will still be a link to open the API endpoint in a new tab for convenience. Depending on the file, the browser will either embed it (e.g., pdf, video) or download it for you (arbitrary binary).
A text file shown in the file cat view
Tailing a file in the file viewer
An embedded image from within an allocation
An unsupported file type