open-nomad/ui/app/controllers/allocations/allocation/task/index.js
Michael Lange 52a7a48177 Don't use generic ACL error messages
When the error is actually a 403, an ACL error is appropriate, but when
it isn't, fallback on what the API returns.
2021-01-28 12:18:53 -08:00

31 lines
744 B
JavaScript

import Controller from '@ember/controller';
import { computed as overridable } from 'ember-overridable-computed';
import { task } from 'ember-concurrency';
import classic from 'ember-classic-decorator';
import messageForError from 'nomad-ui/utils/message-from-adapter-error';
@classic
export default class IndexController extends Controller {
@overridable(() => {
// { title, description }
return null;
})
error;
onDismiss() {
this.set('error', null);
}
@task(function*() {
try {
yield this.model.restart();
} catch (err) {
this.set('error', {
title: 'Could Not Restart Task',
description: messageForError(err, 'manage allocation lifecycle'),
});
}
})
restartTask;
}