open-nomad/ui/mirage/factories/variable.js
Phil Renaud d7def242b8
UI variables made to be unique by namespace and path (#14072)
* Starting on namespaced id

* Traversal for variables uniqued by namespace

* Delog

* Basic CRUD complete w namespaces included

* Correct secvar breadcrumb joining and testfix now that namespaces are included

* Testfixes with namespaces in place

* Namespace-aware duplicate path warning

* Duplicate path warning test additions

* Trimpath reimplemented on dupe check

* Solves a bug where slash was not being passed to the can write check

* PR fixes

* variable paths integration test fix now uses store

* Seems far less hacky in retrospect

* PR feedback addressed

* test fixes after inclusion of path as local non-model var

* Prevent confusion by dropping namespace from QPs on PUT, since its already in .data

* Solves a harsh bug where you have namespace access but no secvars access (#14098)

* Solves a harsh bug where you have namespace access but no secvars access

* Lint cleanup

* Remove unneeded condition
2022-08-15 11:56:09 -04:00

36 lines
1 KiB
JavaScript

import { Factory } from 'ember-cli-mirage';
import faker from 'nomad-ui/mirage/faker';
import { provide, pickOne } from '../utils';
export default Factory.extend({
id: () => faker.random.words(3).split(' ').join('/').toLowerCase(),
path() {
return this.id;
},
namespace: null,
createdIndex: 100,
modifiedIndex: 100,
createTime: () => faker.date.past(15) * 1000000,
modifyTime: () => faker.date.recent(1) * 1000000,
items() {
return (
this.Items || {
[faker.database.column()]: faker.database.collation(),
[faker.database.column()]: faker.database.collation(),
[faker.database.column()]: faker.database.collation(),
[faker.database.column()]: faker.database.collation(),
[faker.database.column()]: faker.database.collation(),
}
);
},
afterCreate(variable, server) {
if (!variable.namespace) {
const namespace = pickOne(server.db.jobs)?.namespace || 'default';
variable.update({
namespace,
});
}
},
});