Skip to content

Commit

Permalink
Add page titles to filesystem routes (#6024)
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Aug 1, 2019
1 parent c0ba4ee commit 473ef7a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/app/controllers/allocations/allocation/task/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export default Controller.extend({
directories: filterBy('directoryEntries', 'IsDir'),
files: filterBy('directoryEntries', 'IsDir', false),

pathWithLeadingSlash: computed('path', function() {
const path = this.path;

if (path.startsWith('/')) {
return path;
} else {
return `/${path}`;
}
}),

sortedDirectoryEntries: computed(
'directoryEntries.[]',
'sortProperty',
Expand Down
1 change: 1 addition & 0 deletions ui/app/templates/allocations/allocation/task/fs.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{title pathWithLeadingSlash " - Task " task.name " filesystem"}}
{{task-subnav task=task}}
<section class="section is-closer">
{{#if task.isRunning}}
Expand Down
10 changes: 10 additions & 0 deletions ui/tests/acceptance/task-fs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,22 @@ module('Acceptance | task fs', function(hooks) {
const paths = ['some-file.log', 'a/deep/path/to/a/file.log', '/', 'Unicode™®'];

const testPath = async filePath => {
let pathWithLeadingSlash = filePath;

if (!pathWithLeadingSlash.startsWith('/')) {
pathWithLeadingSlash = `/${filePath}`;
}

await FS.visitPath({ id: allocation.id, name: task.name, path: filePath });
assert.equal(
currentURL(),
`/allocations/${allocation.id}/${task.name}/fs/${encodeURIComponent(filePath)}`,
'No redirect'
);
assert.equal(
document.title,
`${pathWithLeadingSlash} - Task ${task.name} filesystem - Nomad`
);
assert.equal(FS.breadcrumbsText, `${task.name} ${filePath.replace(/\//g, ' ')}`.trim());
};

Expand Down

0 comments on commit 473ef7a

Please sign in to comment.