From 473ef7a662f50a75ac0f062e5f93e12e0ed40b71 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Thu, 1 Aug 2019 11:17:46 -0500 Subject: [PATCH] Add page titles to filesystem routes (#6024) --- ui/app/controllers/allocations/allocation/task/fs.js | 10 ++++++++++ ui/app/templates/allocations/allocation/task/fs.hbs | 1 + ui/tests/acceptance/task-fs-test.js | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/ui/app/controllers/allocations/allocation/task/fs.js b/ui/app/controllers/allocations/allocation/task/fs.js index b8084fd6342..d4b0f27d0ff 100644 --- a/ui/app/controllers/allocations/allocation/task/fs.js +++ b/ui/app/controllers/allocations/allocation/task/fs.js @@ -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', diff --git a/ui/app/templates/allocations/allocation/task/fs.hbs b/ui/app/templates/allocations/allocation/task/fs.hbs index 9854d73417d..be5edc4267a 100644 --- a/ui/app/templates/allocations/allocation/task/fs.hbs +++ b/ui/app/templates/allocations/allocation/task/fs.hbs @@ -1,3 +1,4 @@ +{{title pathWithLeadingSlash " - Task " task.name " filesystem"}} {{task-subnav task=task}}
{{#if task.isRunning}} diff --git a/ui/tests/acceptance/task-fs-test.js b/ui/tests/acceptance/task-fs-test.js index 28d1d9ee2a1..1fea33b2f8e 100644 --- a/ui/tests/acceptance/task-fs-test.js +++ b/ui/tests/acceptance/task-fs-test.js @@ -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()); };