github.com/hernad/nomad@v1.6.112/ui/app/routes/variables/new.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Route from '@ember/routing/route'; 7 8 export default class VariablesNewRoute extends Route { 9 async model(params) { 10 const namespaces = await this.store.peekAll('namespace'); 11 return this.store.createRecord('variable', { 12 path: params.path, 13 namespace: namespaces.objectAt(0)?.id, 14 }); 15 } 16 resetController(controller, isExiting) { 17 // If the user navigates away from /new, clear the path 18 controller.set('path', null); 19 if (isExiting) { 20 // If user didn't save, delete the freshly created model 21 if (controller.model.isNew) { 22 controller.model.destroyRecord(); 23 } 24 } 25 } 26 }