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: Add allocation directory sorting #5914

Merged
merged 125 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
6f984ac
Remove multi-path test for now
backspace Jun 21, 2019
274d1d6
Add rudimentary directory listing
backspace Jun 21, 2019
2796b07
Add placeholder for file/directory icons
backspace Jun 21, 2019
5f0e0a9
Replace placeholders with Structure icons
backspace Jun 21, 2019
875e09c
Change sorting to list directories first
backspace Jun 21, 2019
1d0c200
Convert list to table
backspace Jun 21, 2019
6025ede
Add entry sizes
backspace Jun 21, 2019
ca2baf3
Add tbody
backspace Jun 21, 2019
b8a5c42
Add file mode to table
backspace Jun 21, 2019
75edb48
Add hardcoded Mirage directory listing
backspace Jun 21, 2019
30e6771
Change files link to include path
backspace Jun 21, 2019
3726a6d
Add scenario for stable preview demonstration
backspace Jun 21, 2019
71c8c82
Add empty commit
backspace Jun 24, 2019
ad5621b
Add last modified column
backspace Jun 24, 2019
976cff0
Remove size from directory entries
backspace Jun 24, 2019
8eefd43
Remove file icon
backspace Jun 24, 2019
f1a4729
Add navigation into directories
backspace Jun 24, 2019
65635bc
Move directory endpoint into general Mirage config
backspace Jun 24, 2019
0856bb0
Add preliminary styling
backspace Jun 24, 2019
df5b49e
Remove file mode column
backspace Jun 24, 2019
abf4f94
Merge branch 'master' into f-ui/alloc-fs-directories
backspace Jun 24, 2019
acfed97
Add preliminary explorer breadcrumbs
backspace Jun 24, 2019
3eadd6d
Merge branch 'master' into f-ui/alloc-fs-directories
backspace Jun 24, 2019
4dae829
Add links to breadcrumb entries
backspace Jun 24, 2019
2a41ca6
Add active styling to final breadcrumb
backspace Jun 24, 2019
095ac6a
Add assertions on complete breadcrumbs text
backspace Jun 24, 2019
cc36fe5
Fix breadcrumb paths
backspace Jun 24, 2019
d89d5b7
Fix typo
backspace Jun 24, 2019
92266ee
Update test name
backspace Jun 24, 2019
04975f1
Add check for file vs directory
backspace Jun 24, 2019
999f57a
Restore skipped test
backspace Jun 24, 2019
02867c0
Change test name
backspace Jun 24, 2019
7a15b23
Add extensions to files in mock structure
backspace Jun 24, 2019
c59282e
Change example filenames to contain emoji
backspace Jun 24, 2019
e77f2eb
Add assertion about final filename breadcrumb
backspace Jun 24, 2019
53213a0
Add extension to nested file
backspace Jun 24, 2019
912f730
Rename page object property
backspace Jun 25, 2019
6ca3b5a
Add check for leading slash in path
backspace Jun 25, 2019
806b9bf
Remove temporary title
backspace Jun 25, 2019
dfba2b2
Add preliminary table styling
backspace Jun 25, 2019
c0fc9a4
Update file size heading
backspace Jun 25, 2019
9490c74
Add title for raw file modification datetime
backspace Jun 25, 2019
fc7baa7
Move breadcrumbs into table
backspace Jun 25, 2019
3d0f4e2
Updating styling of breadcrumbs
backspace Jun 25, 2019
d12df39
Add missing class name
backspace Jun 25, 2019
5593ae6
Add auto-updating to modification times
backspace Jun 25, 2019
0e8f569
Change to use less-redundant datetime formatter
backspace Jun 25, 2019
343a093
Add another example modification date
backspace Jun 25, 2019
16fcf9c
Restore file icon
backspace Jun 25, 2019
8c28f57
Add handling for empty directories
backspace Jun 26, 2019
3fafe68
Update Mirage scenario to work reliably
backspace Jun 26, 2019
df53346
Add modification times to all example files
backspace Jun 26, 2019
8fd85b5
Update routing so …/fs shows root directory
backspace Jun 26, 2019
c0d1cdd
Remove placeholder title
backspace Jun 26, 2019
65ddf93
Change fs retrieval to happen via token service
backspace Jun 26, 2019
dab54a6
Move fs API queries into adapter
backspace Jun 26, 2019
84a4b78
Rename property for directory listing
backspace Jun 26, 2019
4e91134
Change to consistently use double quotes
backspace Jun 26, 2019
f9a25d9
Extract directory entry component
backspace Jun 26, 2019
96200ba
Add line to turn off table-groups template lint
backspace Jun 26, 2019
d34433b
Fix indentation
backspace Jun 26, 2019
8d390f9
Change table container to not be full-width
backspace Jun 26, 2019
bdf681d
Convert task subnav partial to component
backspace Jun 26, 2019
19313e6
Change files link to be active at all levels
backspace Jun 26, 2019
3313a2e
Add prototype loading animation
backspace Jun 27, 2019
ac94741
Replace loading animation with Bulma .is-loading
backspace Jun 27, 2019
74fc0ce
Add loading animation for breadcrumb links
backspace Jun 27, 2019
0ca2353
Change width of name column
backspace Jun 27, 2019
d7232fa
Combine path tests into root FS file
backspace Jun 27, 2019
23623ec
Combine directory and file iterations
backspace Jun 27, 2019
6aae341
Remove doubled slashes in directory entry paths
backspace Jun 27, 2019
d0f6028
Remove doubled slashes from breadcrumb paths
backspace Jun 27, 2019
853add7
Add handling for fs/ API errors
backspace Jun 27, 2019
492e1d7
Merge branch 'f-ui/alloc-fs' into f-ui/alloc-fs-directories
backspace Jun 27, 2019
cc93a79
Rename breadcrumbs property
backspace Jun 27, 2019
4c13f15
Remove unused property
backspace Jun 27, 2019
da971d6
Refactor breadcrumbs computed property
backspace Jun 27, 2019
aa2c08d
Replace custom filter with isEmpty
backspace Jun 27, 2019
4e8e2f3
Remove unused dependent key
backspace Jun 27, 2019
6d53d05
Remove unused animation
backspace Jun 27, 2019
c601a27
Fix comment
backspace Jun 27, 2019
d6f71f2
Change to double quotes
backspace Jun 27, 2019
7c0b35c
Remove FIXME re Mirage fs endpoint
backspace Jun 27, 2019
48ce41f
Change test to use hardcoded task name
backspace Jun 27, 2019
07e8863
Correct import name
backspace Jun 28, 2019
2215038
Rename task property in controller
backspace Jun 28, 2019
4c845e8
Remove custom right-align class and use Bulma one
backspace Jun 28, 2019
ea6685d
Move FS table closer to tabs
backspace Jun 28, 2019
94de177
Remove unused properties
backspace Jun 28, 2019
95664ee
Reduce assertion complexity
backspace Jun 28, 2019
dbba6a2
Update comment about 404/500
backspace Jun 28, 2019
7793c85
Add externally-set controller property defaults
backspace Jul 2, 2019
51079cb
Rename component style file
backspace Jul 2, 2019
506d235
Remove unnecessary selector specificity
backspace Jul 2, 2019
a62308d
Move FS breadcrumbs styling inside component class
backspace Jul 2, 2019
f6421b4
Update style name for consistency
backspace Jul 2, 2019
e4da8bf
Change FS breadcrumbs dividers to grey
backspace Jul 2, 2019
09d88f3
Convert FS table head to boxed-section
backspace Jul 2, 2019
ae93227
Change to use x-icon
backspace Jul 2, 2019
437492b
Add Mirage handlers for other-host FS requests
backspace Jul 2, 2019
2d221bd
Add assertion explanations for double-slash
backspace Jul 2, 2019
d18ede9
Fix another double-slash issue
backspace Jul 2, 2019
24c25f6
Update entry hover with standard timestamp format
backspace Jul 2, 2019
ea4fd68
Add notifyError calls to route
backspace Jul 2, 2019
8b95bee
Add sorting by name
backspace Jul 2, 2019
b5de009
Add sorting by modification date
backspace Jul 2, 2019
8fb47e1
Add space for right-aligned sorted head cells
backspace Jul 2, 2019
b93b25c
Update test with more revealing sample data
backspace Jul 2, 2019
7eb4d42
Fix case of sort property name
backspace Jul 2, 2019
0fe61b4
Add sorting by size
backspace Jul 2, 2019
b3d9624
Restore spacing of above-table elements
backspace Jul 3, 2019
6ff2229
Merge branch 'f-ui/alloc-fs' into f-ui/alloc-fs-directory-sort
backspace Jul 3, 2019
7d7ed16
Add controller unit test for sorting
backspace Jul 3, 2019
5fb5ef8
Restore original test data
backspace Jul 3, 2019
d5393fa
Fix alignment of sort arrow in right-aligned cols
backspace Jul 3, 2019
1ad3d09
Move sort arrow to left in right-aligned columns
backspace Jul 3, 2019
21a5b77
Move sort arrow to immediately follow text
backspace Jul 3, 2019
548dc42
Merge branch 'f-ui/closer-sort-arrow' into f-ui/alloc-fs-directory-sort
backspace Jul 3, 2019
2117dc8
Change pseudoelement to be always present
backspace Jul 3, 2019
adc9b44
Merge branch 'f-ui/closer-sort-arrow' into f-ui/alloc-fs-directory-sort
backspace Jul 3, 2019
6aaf38d
Change sort arrows to be absolutely-positioned
backspace Jul 4, 2019
ad626e0
Move arrow in right-aligned search close to text
backspace Jul 4, 2019
7ab94ea
Merge branch 'f-ui/alloc-fs' into f-ui/alloc-fs-directory-sort
backspace Jul 4, 2019
04a9240
Remove TODO
backspace Jul 4, 2019
19667dd
Remove controller unit test
backspace Jul 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions ui/app/controllers/allocations/allocation/task/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { filterBy } from '@ember/object/computed';
import { isEmpty } from '@ember/utils';

export default Controller.extend({
queryParams: {
sortProperty: 'sort',
sortDescending: 'desc',
},

sortProperty: 'Name',
sortDescending: false,

path: null,
task: null,
directoryEntries: null,
Expand All @@ -12,6 +20,28 @@ export default Controller.extend({
directories: filterBy('directoryEntries', 'IsDir'),
files: filterBy('directoryEntries', 'IsDir', false),

sortedDirectoryEntries: computed(
'directoryEntries.[]',
'sortProperty',
'sortDescending',
function() {
const sortProperty = this.sortProperty;

const directorySortProperty = sortProperty === 'Size' ? 'Name' : sortProperty;

const sortedDirectories = this.directories.sortBy(directorySortProperty);
const sortedFiles = this.files.sortBy(sortProperty);

const sortedDirectoryEntries = sortedDirectories.concat(sortedFiles);

if (this.sortDescending) {
return sortedDirectoryEntries.reverse();
} else {
return sortedDirectoryEntries;
}
}
),

breadcrumbs: computed('path', function() {
const breadcrumbs = this.path
.split('/')
Expand Down
4 changes: 4 additions & 0 deletions ui/app/styles/components/boxed-section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
.pull-right {
margin-left: auto;
}

&.is-compact {
padding: 0.75em;
}
}

.boxed-section-head {
Expand Down
49 changes: 35 additions & 14 deletions ui/app/styles/core/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
td {
padding: 0.75em;
}

.is-selectable a {
padding: 0.75em;
}
}

&.is-darkened {
Expand Down Expand Up @@ -149,33 +153,50 @@
padding: 0.75em 1.5em;
width: 100%;
text-decoration: none;
position: relative;

&:hover {
background-color: darken($white-ter, 5%);
}

&::before,
&::after {
position: absolute;
pointer-events: none;
color: $grey-light;
}

&::after {
transform: translateX(6px);
}

&::before {
transform: translateX(-20px);
}
}
}

&.is-active {
position: relative;

&::after {
content: '';
width: 10px;
right: 1.5em;
top: 0.75em;
bottom: 0.75em;
position: absolute;
display: block;
pointer-events: none;
&.desc a::after {
content: '⬆';
}

&.asc::after {
&.asc a::after {
content: '⬇';
}

&.desc::after {
content: '⬆';
&.has-text-right {
a::after {
content: none;
}

&.desc a::before {
content: '⬆';
}

&.asc a::before {
content: '⬇';
}
}
}

Expand Down
31 changes: 15 additions & 16 deletions ui/app/templates/allocations/allocation/task/fs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="section is-closer">
{{#if task.isRunning}}
<div class="fs-explorer boxed-section">
<div class="boxed-section-head">
<div class="boxed-section-head is-compact">
<nav class="breadcrumb" data-test-fs-breadcrumbs>
<ul>
<li class={{if breadcrumbs "" "is-active"}}>
Expand All @@ -26,21 +26,20 @@
<div data-test-file-viewer>placeholder file viewer</div>
</div>
{{else}}
{{! template-lint-disable table-groups }}
<table class="table boxed-section-body is-full-bleed is-compact">
{{#list-table
source=sortedDirectoryEntries
sortProperty=sortProperty
sortDescending=sortDescending
class="boxed-section-body is-full-bleed is-compact" as |t|}}
{{#if directoryEntries}}
<thead>
<tr>
<th class="is-two-thirds">Name</th>
<th class="has-text-right">File Size</th>
<th class="has-text-right">Last Modified</th>
</tr>
</thead>
<tbody>
{{#each (append directories files) as |entry|}}
{{fs-directory-entry path=path task=task entry=entry}}
{{/each}}
</tbody>
{{#t.head}}
{{#t.sort-by prop="Name" class="is-two-thirds"}}Name{{/t.sort-by}}
{{#t.sort-by prop="Size" class="has-text-right"}}File Size{{/t.sort-by}}
{{#t.sort-by prop="ModTime" class="has-text-right"}}Last Modified{{/t.sort-by}}
{{/t.head}}
{{#t.body as |row|}}
{{fs-directory-entry path=path task=task entry=row.model}}
{{/t.body}}
{{else}}
<tbody>
<tr data-test-entry>
Expand All @@ -51,7 +50,7 @@
</tr>
</tbody>
{{/if}}
</table>
{{/list-table}}
{{/if}}
</div>
{{else}}
Expand Down
126 changes: 126 additions & 0 deletions ui/tests/acceptance/task-fs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setupApplicationTest } from 'ember-qunit';

import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import Response from 'ember-cli-mirage/response';
import moment from 'moment';

import FS from 'nomad-ui/tests/pages/allocations/task/fs';

Expand Down Expand Up @@ -129,6 +130,131 @@ module('Acceptance | task fs', function(hooks) {
assert.equal(FS.breadcrumbs.length, 2);
});

test('sorting allocation filesystem directory', async function(assert) {
this.server.get('/client/fs/ls/:allocation_id', () => {
return [
{
Name: 'aaa-big-old-file',
IsDir: false,
Size: 19190000,
ModTime: moment()
.subtract(1, 'year')
.format(),
},
{
Name: 'mmm-small-mid-file',
IsDir: false,
Size: 1919,
ModTime: moment()
.subtract(6, 'month')
.format(),
},
{
Name: 'zzz-med-new-file',
IsDir: false,
Size: 191900,
ModTime: moment().format(),
},
{
Name: 'aaa-big-old-directory',
IsDir: true,
Size: 19190000,
ModTime: moment()
.subtract(1, 'year')
.format(),
},
{
Name: 'mmm-small-mid-directory',
IsDir: true,
Size: 1919,
ModTime: moment()
.subtract(6, 'month')
.format(),
},
{
Name: 'zzz-med-new-directory',
IsDir: true,
Size: 191900,
ModTime: moment().format(),
},
];
});

await FS.visitPath({ id: allocation.id, name: task.name, path: '/' });

assert.deepEqual(FS.directoryEntryNames(), [
'aaa-big-old-directory',
'mmm-small-mid-directory',
'zzz-med-new-directory',
'aaa-big-old-file',
'mmm-small-mid-file',
'zzz-med-new-file',
]);

await FS.sortBy('Name');

assert.deepEqual(FS.directoryEntryNames(), [
'zzz-med-new-file',
'mmm-small-mid-file',
'aaa-big-old-file',
'zzz-med-new-directory',
'mmm-small-mid-directory',
'aaa-big-old-directory',
]);

await FS.sortBy('ModTime');

assert.deepEqual(FS.directoryEntryNames(), [
'zzz-med-new-file',
'mmm-small-mid-file',
'aaa-big-old-file',
'zzz-med-new-directory',
'mmm-small-mid-directory',
'aaa-big-old-directory',
]);

await FS.sortBy('ModTime');

assert.deepEqual(FS.directoryEntryNames(), [
'aaa-big-old-directory',
'mmm-small-mid-directory',
'zzz-med-new-directory',
'aaa-big-old-file',
'mmm-small-mid-file',
'zzz-med-new-file',
]);

await FS.sortBy('Size');

assert.deepEqual(
FS.directoryEntryNames(),
[
'aaa-big-old-file',
'zzz-med-new-file',
'mmm-small-mid-file',
'zzz-med-new-directory',
'mmm-small-mid-directory',
'aaa-big-old-directory',
],
'expected files to be sorted by descending size and directories to be sorted by descending name'
);

await FS.sortBy('Size');

assert.deepEqual(
FS.directoryEntryNames(),
[
'aaa-big-old-directory',
'mmm-small-mid-directory',
'zzz-med-new-directory',
'mmm-small-mid-file',
'zzz-med-new-file',
'aaa-big-old-file',
],
'expected directories to be sorted by name and files to be sorted by ascending size'
);
});

backspace marked this conversation as resolved.
Show resolved Hide resolved
test('viewing a file', async function(assert) {
await FS.visitPath({ id: allocation.id, name: task.name, path: '/' });
await FS.directoryEntries[2].visit();
Expand Down
16 changes: 16 additions & 0 deletions ui/tests/pages/allocations/task/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ export default create({
isActive: hasClass('is-active'),
}),

sortOptions: collection('[data-test-sort-by]', {
id: attribute('data-test-sort-by'),
sort: clickable(),
}),

sortBy(id) {
return this.sortOptions
.toArray()
.findBy('id', id)
.sort();
},

directoryEntries: collection('[data-test-entry]', {
name: text('[data-test-name]'),

Expand All @@ -39,6 +51,10 @@ export default create({
path: attribute('href', 'a'),
}),

directoryEntryNames() {
return this.directoryEntries.toArray().mapBy('name');
},

hasEmptyState: isPresent('[data-test-not-running]'),
emptyState: {
headline: text('[data-test-not-running-headline]'),
Expand Down