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

UI: Alloc FS: File Viewer #6048

Merged
merged 38 commits into from
Aug 19, 2019
Merged

UI: Alloc FS: File Viewer #6048

merged 38 commits into from
Aug 19, 2019

Conversation

DingoEatingFuzz
Copy link
Contributor

Completes the feature set of the allocation explorer by making files viewable. File viewing currently supports:

  1. Text files (logs, json, code, etc.)
  2. Images (jpg, png, svg, webp, gif, etc.)

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).

image
A text file shown in the file cat view

image
Tailing a file in the file viewer

image
An embedded image from within an allocation

image
An unsupported file type

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.
Copy link
Contributor

@backspace backspace left a 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 &times; {{height}}{{#if size}}px, {{format-bytes size}}{{/if}})</span>
Copy link
Contributor

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?

Copy link
Contributor Author

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;
}
Copy link
Contributor

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?

Copy link
Contributor Author

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/streaming-file.js Show resolved Hide resolved

isLarge: computed('stat.Size', function() {
return this.stat.Size > 50000;
}),
Copy link
Contributor

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>
Copy link
Contributor

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?

Copy link
Contributor Author

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 🔪

ui/app/templates/components/task-file.hbs Show resolved Hide resolved
ui/app/templates/components/task-file.hbs Show resolved Hide resolved
offset: 4,
message: 'One fish, Two fish. Red fish, Blue fish.',
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice unit test!

ui/tests/integration/image-file-test.js Show resolved Hide resolved
@@ -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;
Copy link
Contributor

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!

Copy link
Contributor Author

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.

Copy link
Contributor

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 😆

Copy link
Contributor Author

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?

Copy link
Contributor

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! 🎉

Copy link
Contributor

@johncowen johncowen Aug 7, 2019

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.

@backspace
Copy link
Contributor

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

ls-spacing

file-spacing

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…??

@johncowen
Copy link
Contributor

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

@DingoEatingFuzz
Copy link
Contributor Author

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.

  • Errant No Connection error: This was due to the allocation's client not being loaded in time, which I fixed and added a test for.
  • File cat can go off screen: This was some CSS that was oddly related to the clipped tooltip overflow-x:auto bug from a couple months ago. I set the width while accounting for the margin and it's good now.
  • Breadcrumbs have awkward bottom-margin when viewing a file: This was due to the button height, which was no secret. I fixed it with an existing style that I forget existed: is-compact. This modifier also needed to be tweaked since this is the first time it's being used for multiple buttons in a bar.
  • Missing test coverage for tricky characters like "?": I added a new set of possible characters to the mirage factory. Everything is still working fine!

@johncowen
Copy link
Contributor

Hey @DingoEatingFuzz ,

I gave the URL chars a try, some work, but I could definitely get things to go awry with %'s at least. I could reasonably consistently get a 'URI malformed' to appear.

Screenshot 2019-08-09 at 09 25 48

Don't let this hold you up though, if you want to move on with this and look at that later.

John

Copy link
Contributor

@backspace backspace left a 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):

image

It’s rarely happening but still worrisome 😳

ETA: I keep running with the fs filter and I got this failure too:

image

ui/app/components/task-file.js Show resolved Hide resolved
ui/tests/acceptance/task-fs-test.js Show resolved Hide resolved
@DingoEatingFuzz
Copy link
Contributor Author

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).

Copy link
Contributor

@backspace backspace left a comment

Choose a reason for hiding this comment

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

Looking good, I think ui/out is a mistaken inclusion, but otherwise, congratulations on seeing this through!

image

ui/out Outdated
@@ -0,0 +1,1317 @@
Environment: test
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@backspace backspace left a comment

Choose a reason for hiding this comment

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

yay 🎉

@DingoEatingFuzz DingoEatingFuzz merged commit 354da0f into f-ui/alloc-fs Aug 19, 2019
@DingoEatingFuzz DingoEatingFuzz deleted the f-ui/alloc-fs-files branch August 19, 2019 17:36
@github-actions
Copy link

github-actions bot commented Feb 4, 2023

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants