-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
config.js
50 lines (40 loc) · 1.46 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import Model, { attr } from '@ember-data/model';
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import { withModelValidations } from 'vault/decorators/model-validations';
const validations = {
retentionMonths: [
{
validator: (model) => parseInt(model.retentionMonths) >= model.minimumRetentionMonths,
message: (model) =>
`Retention period must be greater than or equal to ${model.minimumRetentionMonths}.`,
},
],
};
@withModelValidations(validations)
export default class ClientsConfigModel extends Model {
@attr('boolean') queriesAvailable; // true only if historical data exists, will be false if there is only current month data
@attr('number', {
label: 'Retention period',
subText: 'The number of months of activity logs to maintain for client tracking.',
})
retentionMonths;
@attr('number') minimumRetentionMonths;
@attr('string') enabled;
@attr('boolean') reportingEnabled;
@attr('date') billingStartTimestamp;
@lazyCapabilities(apiPath`sys/internal/counters/config`) configPath;
get canRead() {
return this.configPath.get('canRead') !== false;
}
get canEdit() {
return this.configPath.get('canUpdate') !== false;
}
_formFields = null;
get formFields() {
if (!this._formFields) {
this._formFields = expandAttributeMeta(this, ['enabled', 'retentionMonths']);
}
return this._formFields;
}
}