Skip to content

Commit 607aac4

Browse files
Merge pull request #9172 from hashicorp/b-ui/logs-for-fails
UI: Always show the file browser for allocations and tasks.
2 parents 50372a1 + 05f3bf2 commit 607aac4

File tree

5 files changed

+55
-106
lines changed

5 files changed

+55
-106
lines changed

ui/app/routes/allocations/allocation/fs.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ export default class FsRoute extends Route {
77
const decodedPath = decodeURIComponent(path);
88
const allocation = this.modelFor('allocations.allocation');
99

10-
if (!allocation.isRunning) {
11-
return {
12-
path: decodedPath,
13-
allocation,
14-
};
15-
}
10+
if (!allocation) return;
1611

1712
return RSVP.all([allocation.stat(decodedPath), allocation.get('node')])
1813
.then(([statJson]) => {

ui/app/routes/allocations/allocation/task/fs.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ export default class FsRoute extends Route {
66
model({ path = '/' }) {
77
const decodedPath = decodeURIComponent(path);
88
const taskState = this.modelFor('allocations.allocation.task');
9-
const allocation = taskState.allocation;
109

10+
if (!taskState || !taskState.allocation) return;
11+
12+
const allocation = taskState.allocation;
1113
const pathWithTaskName = `${taskState.name}${
1214
decodedPath.startsWith('/') ? '' : '/'
1315
}${decodedPath}`;
1416

15-
if (!taskState.isRunning) {
16-
return {
17-
path: decodedPath,
18-
taskState,
19-
};
20-
}
21-
2217
return RSVP.all([allocation.stat(pathWithTaskName), taskState.get('allocation.node')])
2318
.then(([statJson]) => {
2419
if (statJson.IsDir) {
+32-41
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,38 @@
11
<section class="section is-closer {{if this.isFile "is-full-width"}}">
2-
{{#if this.model.isRunning}}
3-
{{#if this.isFile}}
4-
<Fs::File @allocation={{this.allocation}} @taskState={{this.taskState}} @file={{this.path}} @stat={{this.stat}} @class="fs-explorer">
2+
{{#if this.isFile}}
3+
<Fs::File @allocation={{this.allocation}} @taskState={{this.taskState}} @file={{this.path}} @stat={{this.stat}} @class="fs-explorer">
4+
<Fs::Breadcrumbs @allocation={{this.allocation}} @taskState={{this.taskState}} @path={{this.path}} />
5+
</Fs::File>
6+
{{else}}
7+
<div class="fs-explorer boxed-section">
8+
<div class="boxed-section-head">
59
<Fs::Breadcrumbs @allocation={{this.allocation}} @taskState={{this.taskState}} @path={{this.path}} />
6-
</Fs::File>
7-
{{else}}
8-
<div class="fs-explorer boxed-section">
9-
<div class="boxed-section-head">
10-
<Fs::Breadcrumbs @allocation={{this.allocation}} @taskState={{this.taskState}} @path={{this.path}} />
11-
</div>
12-
{{#if this.directoryEntries}}
13-
<ListTable
14-
@source={{this.sortedDirectoryEntries}}
15-
@sortProperty={{this.sortProperty}}
16-
@sortDescending={{this.sortDescending}}
17-
@class="boxed-section-body is-full-bleed is-compact" as |t|>
18-
<t.head>
19-
<t.sort-by @prop="Name" @class="is-two-thirds">Name</t.sort-by>
20-
<t.sort-by @prop="Size" @class="has-text-right">File Size</t.sort-by>
21-
<t.sort-by @prop="ModTime" @class="has-text-right">Last Modified</t.sort-by>
22-
</t.head>
23-
<t.body as |row|>
24-
<Fs::DirectoryEntry @path={{this.path}} @allocation={{this.allocation}} @taskState={{this.taskState}} @entry={{row.model}} />
25-
</t.body>
26-
</ListTable>
27-
{{else}}
28-
<div class="boxed-section-body">
29-
<div data-test-empty-directory class="empty-message">
30-
<h3 data-test-empty-directory-headline class="empty-message-headline">No Files</h3>
31-
<p data-test-empty-directory-body class="empty-message-body">
32-
Directory is currently empty.
33-
</p>
34-
</div>
35-
</div>
36-
{{/if}}
3710
</div>
38-
{{/if}}
39-
{{else}}
40-
<div data-test-not-running class="empty-message">
41-
<h3 data-test-not-running-headline class="empty-message-headline">{{capitalize this.type}} is not Running</h3>
42-
<p data-test-not-running-body class="empty-message-body">
43-
Cannot access files of a{{if this.allocation 'n'}} {{this.type}} that is not running.
44-
</p>
11+
{{#if this.directoryEntries}}
12+
<ListTable
13+
@source={{this.sortedDirectoryEntries}}
14+
@sortProperty={{this.sortProperty}}
15+
@sortDescending={{this.sortDescending}}
16+
@class="boxed-section-body is-full-bleed is-compact" as |t|>
17+
<t.head>
18+
<t.sort-by @prop="Name" @class="is-two-thirds">Name</t.sort-by>
19+
<t.sort-by @prop="Size" @class="has-text-right">File Size</t.sort-by>
20+
<t.sort-by @prop="ModTime" @class="has-text-right">Last Modified</t.sort-by>
21+
</t.head>
22+
<t.body as |row|>
23+
<Fs::DirectoryEntry @path={{this.path}} @allocation={{this.allocation}} @taskState={{this.taskState}} @entry={{row.model}} />
24+
</t.body>
25+
</ListTable>
26+
{{else}}
27+
<div class="boxed-section-body">
28+
<div data-test-empty-directory class="empty-message">
29+
<h3 data-test-empty-directory-headline class="empty-message-headline">No Files</h3>
30+
<p data-test-empty-directory-body class="empty-message-body">
31+
Directory is currently empty.
32+
</p>
33+
</div>
34+
</div>
35+
{{/if}}
4536
</div>
4637
{{/if}}
4738
</section>

ui/tests/acceptance/allocation-fs-test.js

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/* eslint-disable ember-a11y-testing/a11y-audit-called */ // Covered in behaviours/fs
2-
import { module, test } from 'qunit';
2+
import { module } from 'qunit';
33
import { setupApplicationTest } from 'ember-qunit';
44

55
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
6-
import Response from 'ember-cli-mirage/response';
76

87
import browseFilesystem from './behaviors/fs';
98

10-
import FS from 'nomad-ui/tests/pages/allocations/fs';
11-
129
let allocation;
1310
let files;
1411

@@ -48,24 +45,6 @@ module('Acceptance | allocation fs', function(hooks) {
4845
this.nestedDirectory = files[1];
4946
});
5047

51-
test('when the allocation is not running, an empty state is shown', async function(assert) {
52-
// The API 500s on stat when not running
53-
this.server.get('/client/fs/stat/:allocation_id', () => {
54-
return new Response(500, {}, 'no such file or directory');
55-
});
56-
57-
allocation.update({
58-
clientStatus: 'complete',
59-
});
60-
61-
await FS.visitAllocation({ id: allocation.id });
62-
assert.ok(FS.hasEmptyState, 'Non-running allocation has no files');
63-
assert.ok(
64-
FS.emptyState.headline.includes('Allocation is not Running'),
65-
'Empty state explains the condition'
66-
);
67-
});
68-
6948
browseFilesystem({
7049
visitSegments: ({ allocation }) => ({ id: allocation.id }),
7150
getExpectedPathBase: ({ allocation }) => `/allocations/${allocation.id}/fs/`,

ui/tests/acceptance/task-fs-test.js

+18-29
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/* eslint-disable ember-a11y-testing/a11y-audit-called */ // Covered in behaviours/fs
2-
import { module, test } from 'qunit';
2+
import { module } from 'qunit';
33
import { setupApplicationTest } from 'ember-qunit';
44

55
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
6-
import Response from 'ember-cli-mirage/response';
76

87
import browseFilesystem from './behaviors/fs';
98

10-
import FS from 'nomad-ui/tests/pages/allocations/fs';
11-
129
let allocation;
1310
let task;
1411
let files, taskDirectory, directory, nestedDirectory;
@@ -37,10 +34,18 @@ module('Acceptance | task fs', function(hooks) {
3734
files.push(taskDirectory);
3835

3936
// Nested files
40-
directory = server.create('allocFile', { isDir: true, name: 'directory', parent: taskDirectory });
37+
directory = server.create('allocFile', {
38+
isDir: true,
39+
name: 'directory',
40+
parent: taskDirectory,
41+
});
4142
files.push(directory);
4243

43-
nestedDirectory = server.create('allocFile', { isDir: true, name: 'another', parent: directory });
44+
nestedDirectory = server.create('allocFile', {
45+
isDir: true,
46+
name: 'another',
47+
parent: directory,
48+
});
4449
files.push(nestedDirectory);
4550

4651
files.push(
@@ -51,7 +56,9 @@ module('Acceptance | task fs', function(hooks) {
5156
})
5257
);
5358

54-
files.push(server.create('allocFile', { isDir: true, name: 'empty-directory', parent: taskDirectory }));
59+
files.push(
60+
server.create('allocFile', { isDir: true, name: 'empty-directory', parent: taskDirectory })
61+
);
5562
files.push(server.create('allocFile', 'file', { fileType: 'txt', parent: taskDirectory }));
5663
files.push(server.create('allocFile', 'file', { fileType: 'txt', parent: taskDirectory }));
5764

@@ -60,29 +67,11 @@ module('Acceptance | task fs', function(hooks) {
6067
this.nestedDirectory = nestedDirectory;
6168
});
6269

63-
test('when the task is not running, an empty state is shown', async function(assert) {
64-
// The API 500s on stat when not running
65-
this.server.get('/client/fs/stat/:allocation_id', () => {
66-
return new Response(500, {}, 'no such file or directory');
67-
});
68-
69-
task.update({
70-
finishedAt: new Date(),
71-
});
72-
73-
await FS.visitTask({ id: allocation.id, name: task.name });
74-
assert.ok(FS.hasEmptyState, 'Non-running task has no files');
75-
assert.ok(
76-
FS.emptyState.headline.includes('Task is not Running'),
77-
'Empty state explains the condition'
78-
);
79-
});
80-
8170
browseFilesystem({
82-
visitSegments: ({allocation,task}) => ({ id: allocation.id, name: task.name }),
83-
getExpectedPathBase: ({allocation,task}) => `/allocations/${allocation.id}/${task.name}/fs/`,
84-
getTitleComponent: ({task}) => `Task ${task.name} filesystem`,
85-
getBreadcrumbComponent: ({task}) => task.name,
71+
visitSegments: ({ allocation, task }) => ({ id: allocation.id, name: task.name }),
72+
getExpectedPathBase: ({ allocation, task }) => `/allocations/${allocation.id}/${task.name}/fs/`,
73+
getTitleComponent: ({ task }) => `Task ${task.name} filesystem`,
74+
getBreadcrumbComponent: ({ task }) => task.name,
8675
getFilesystemRoot: ({ task }) => task.name,
8776
pageObjectVisitFunctionName: 'visitTask',
8877
pageObjectVisitPathFunctionName: 'visitTaskPath',

0 commit comments

Comments
 (0)