diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bfef90ef..c536af6d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ BUG FIXES: * ui: Fixed runtime error when clicking "Run Job" while a prefix filter is set [[GH-8412](https://github.com/hashicorp/nomad/issues/8412)] * ui: Fixed the absence of the region query parameter on various actions, such as job stop, allocation restart, node drain. [[GH-8477](https://github.com/hashicorp/nomad/issues/8477)] * ui: Fixed issue where an orphaned child job would make it so navigating to a job detail page would hang the UI [[GH-8319](https://github.com/hashicorp/nomad/issues/8319)] + * ui: Fixed issue where clicking View Raw File in a non-default region would not provide the region param resulting in a 404 [[GH-8509](https://github.com/hashicorp/nomad/issues/8509)] * vault: Fixed a bug where vault identity policies not considered in permissions check [[GH-7732](https://github.com/hashicorp/nomad/issues/7732)] ## 0.12.0 (July 9, 2020) diff --git a/ui/app/components/fs/file.js b/ui/app/components/fs/file.js index e977c7519..dd579724f 100644 --- a/ui/app/components/fs/file.js +++ b/ui/app/components/fs/file.js @@ -12,6 +12,7 @@ import classic from 'ember-classic-decorator'; @classNames('boxed-section', 'task-log') export default class File extends Component { @service token; + @service system; 'data-test-file-viewer' = true; @@ -54,7 +55,11 @@ export default class File extends Component { get catUrl() { const taskUrlPrefix = this.taskState ? `${this.taskState.name}/` : ''; const encodedPath = encodeURIComponent(`${taskUrlPrefix}${this.file}`); - return `/v1/client/fs/cat/${this.allocation.id}?path=${encodedPath}`; + let apiPath = `/v1/client/fs/cat/${this.allocation.id}?path=${encodedPath}`; + if (this.system.shouldIncludeRegion) { + apiPath += `®ion=${this.system.activeRegion}`; + } + return apiPath; } @computed('isLarge', 'mode') diff --git a/ui/tests/integration/fs/file-test.js b/ui/tests/integration/fs/file-test.js index 54a0f541c..3126fd3a0 100644 --- a/ui/tests/integration/fs/file-test.js +++ b/ui/tests/integration/fs/file-test.js @@ -13,15 +13,22 @@ module('Integration | Component | fs/file', function(hooks) { hooks.beforeEach(function() { this.server = new Pretender(function() { - this.get('/v1/regions', () => [200, {}, JSON.stringify(['default'])]); + this.get('/v1/agent/members', () => [ + 200, + {}, + JSON.stringify({ ServerRegion: 'default', Members: [] }), + ]); + this.get('/v1/regions', () => [200, {}, JSON.stringify(['default', 'region-2'])]); this.get('/v1/client/fs/stream/:alloc_id', () => [200, {}, logEncode(['Hello World'], 0)]); this.get('/v1/client/fs/cat/:alloc_id', () => [200, {}, 'Hello World']); this.get('/v1/client/fs/readat/:alloc_id', () => [200, {}, 'Hello World']); }); + this.system = this.owner.lookup('service:system'); }); hooks.afterEach(function() { this.server.shutdown(); + window.localStorage.clear(); }); const commonTemplate = hbs` @@ -145,6 +152,26 @@ module('Integration | Component | fs/file', function(hooks) { ); }); + test('The view raw button respects the active region', async function(assert) { + const region = 'region-2'; + window.localStorage.nomadActiveRegion = region; + + const props = makeProps(fileStat('image/png', 1234)); + this.setProperties(props); + + await this.system.get('regions'); + await render(commonTemplate); + + const rawLink = find('[data-test-log-action="raw"]'); + assert.equal( + rawLink.getAttribute('href'), + `/v1/client/fs/cat/${props.allocation.id}?path=${encodeURIComponent( + `${props.taskState.name}/${props.file}` + )}®ion=${region}`, + 'Raw link href includes the active region from local storage' + ); + }); + test('The head and tail buttons are not shown when the file is small', async function(assert) { const props = makeProps(fileStat('application/json', 5000)); this.setProperties(props);