diff --git a/ui/app/adapters/task-state.js b/ui/app/adapters/task-state.js deleted file mode 100644 index f9f98ca6271e..000000000000 --- a/ui/app/adapters/task-state.js +++ /dev/null @@ -1,39 +0,0 @@ -import ApplicationAdapter from './application'; -import { inject as service } from '@ember/service'; - -export default ApplicationAdapter.extend({ - token: service(), - - ls(model, path) { - return this.token - .authorizedRequest(`/v1/client/fs/ls/${model.allocation.id}?path=${encodeURIComponent(path)}`) - .then(handleFSResponse); - }, - - stat(model, path) { - return this.token - .authorizedRequest( - `/v1/client/fs/stat/${model.allocation.id}?path=${encodeURIComponent(path)}` - ) - .then(handleFSResponse); - }, -}); - -async function handleFSResponse(response) { - if (response.ok) { - return response.json(); - } else { - const body = await response.text(); - - // TODO update this if/when endpoint returns 404 as expected - const statusIs500 = response.status === 500; - const bodyIncludes404Text = body.includes('no such file or directory'); - - const translatedCode = statusIs500 && bodyIncludes404Text ? 404 : response.status; - - throw { - code: translatedCode, - toString: () => body, - }; - } -} diff --git a/ui/app/models/task-state.js b/ui/app/models/task-state.js index e6afba7e862d..fb9736ab7e49 100644 --- a/ui/app/models/task-state.js +++ b/ui/app/models/task-state.js @@ -51,12 +51,4 @@ export default Fragment.extend({ restart() { return this.allocation.restart(this.name); }, - - ls(path) { - return this.store.adapterFor('task-state').ls(this, path); - }, - - stat(path) { - return this.store.adapterFor('task-state').stat(this, path); - }, }); diff --git a/ui/app/routes/allocations/allocation/task/fs.js b/ui/app/routes/allocations/allocation/task/fs.js index 097ba686a4d5..7627a8d61c26 100644 --- a/ui/app/routes/allocations/allocation/task/fs.js +++ b/ui/app/routes/allocations/allocation/task/fs.js @@ -6,6 +6,7 @@ export default Route.extend({ model({ path = '/' }) { const decodedPath = decodeURIComponent(path); const task = this.modelFor('allocations.allocation.task'); + const allocation = task.allocation; const pathWithTaskName = `${task.name}${decodedPath.startsWith('/') ? '' : '/'}${decodedPath}`; @@ -16,13 +17,13 @@ export default Route.extend({ }; } - return RSVP.all([task.stat(pathWithTaskName), task.get('allocation.node')]) + return RSVP.all([allocation.stat(pathWithTaskName), task.get('allocation.node')]) .then(([statJson]) => { if (statJson.IsDir) { return RSVP.hash({ path: decodedPath, task, - directoryEntries: task.ls(pathWithTaskName).catch(notifyError(this)), + directoryEntries: allocation.ls(pathWithTaskName).catch(notifyError(this)), isFile: false, }); } else {