2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2022-08-01 16:04:41 -04:00
|
|
|
import Route from '@ember/routing/route';
|
2022-08-26 11:50:53 -04:00
|
|
|
import { action } from '@ember/object';
|
|
|
|
|
import { loading } from 'ember-loading';
|
|
|
|
|
import { notifyError, notifySuccess } from 'core/decorators/notify';
|
2022-11-07 15:17:23 -08:00
|
|
|
import { inject as service } from '@ember/service';
|
2022-08-01 16:04:41 -04:00
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
export default class ScopesScopeWorkersNewRoute extends Route {
|
2022-11-07 15:17:23 -08:00
|
|
|
// =services
|
|
|
|
|
|
|
|
|
|
@service store;
|
|
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
// =methods
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new unsaved worker.
|
|
|
|
|
* @return {WorkerModel}
|
|
|
|
|
*/
|
|
|
|
|
model() {
|
|
|
|
|
const scopeModel = this.modelFor('scopes.scope');
|
2022-12-06 14:29:58 -05:00
|
|
|
const record = this.store.createRecord('worker');
|
|
|
|
|
record.scopeModel = scopeModel;
|
|
|
|
|
return record;
|
2022-08-26 11:50:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created the worker and notifies the user of success or error.
|
|
|
|
|
* @param {WorkerModel} worker
|
|
|
|
|
* @param {string} workerGeneratedAuthToken
|
|
|
|
|
*/
|
|
|
|
|
@action
|
|
|
|
|
@loading
|
|
|
|
|
@notifyError(({ message }) => message, { catch: true })
|
|
|
|
|
@notifySuccess('notifications.add-success')
|
|
|
|
|
async createWorkerLed(worker, workerGeneratedAuthToken) {
|
|
|
|
|
await worker.createWorkerLed(workerGeneratedAuthToken);
|
|
|
|
|
}
|
|
|
|
|
}
|