2020-06-04 16:53:37 -04:00
|
|
|
import factory from '../generated/factories/host-catalog';
|
2020-08-19 16:12:53 -04:00
|
|
|
import { trait } from 'ember-cli-mirage';
|
2021-08-19 16:06:47 -07:00
|
|
|
import permissions from '../helpers/permissions';
|
2020-06-04 16:53:37 -04:00
|
|
|
|
2020-08-19 16:12:53 -04:00
|
|
|
export default factory.extend({
|
2021-08-19 16:06:47 -07:00
|
|
|
authorized_actions: () =>
|
|
|
|
|
permissions.authorizedActionsFor('host-catalog') || [
|
|
|
|
|
'no-op',
|
|
|
|
|
'read',
|
|
|
|
|
'update',
|
|
|
|
|
'delete',
|
|
|
|
|
],
|
2021-09-02 15:28:40 -07:00
|
|
|
authorized_collection_actions: () => {
|
|
|
|
|
return {
|
|
|
|
|
hosts: ['create', 'list'],
|
2021-09-02 13:01:58 -07:00
|
|
|
'host-sets': ['create', 'list'],
|
2021-09-02 15:28:40 -07:00
|
|
|
};
|
|
|
|
|
},
|
2020-08-19 16:12:53 -04:00
|
|
|
withChildren: trait({
|
|
|
|
|
afterCreate(hostCatalog, server) {
|
2021-12-15 13:15:31 -05:00
|
|
|
const { scope, type } = hostCatalog;
|
|
|
|
|
const hosts = server.createList('host', 10, { scope, hostCatalog, type });
|
|
|
|
|
server.createList('host-set', 3, { scope, hostCatalog, hosts, type });
|
2021-03-04 15:47:38 -05:00
|
|
|
},
|
|
|
|
|
}),
|
2020-08-19 16:12:53 -04:00
|
|
|
});
|