-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clients config updates for census reporting (#20125)
* updates clients config view for census reporting * adds changelog entry * fixes issue with modal staying open and error not showing on clients config save failure * adds min retention months to clients config model and form validation
- Loading branch information
Showing
9 changed files
with
217 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
ui: updates clients configuration edit form state based on census reporting configuration | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,43 @@ | ||
import Model, { attr } from '@ember-data/model'; | ||
import { computed } from '@ember/object'; | ||
import attachCapabilities from 'vault/lib/attach-capabilities'; | ||
import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; | ||
import { apiPath } from 'vault/macros/lazy-capabilities'; | ||
|
||
const M = Model.extend({ | ||
queriesAvailable: attr('boolean'), | ||
retentionMonths: attr('number', { | ||
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; | ||
import { withFormFields } from 'vault/decorators/model-form-fields'; | ||
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) | ||
@withFormFields(['enabled', 'retentionMonths']) | ||
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.', | ||
}), | ||
enabled: attr('string', { | ||
editType: 'boolean', | ||
trueValue: 'On', | ||
falseValue: 'Off', | ||
label: 'Enable usage data collection', | ||
helpText: | ||
'Enable or disable client tracking. Keep in mind that disabling tracking will delete the data for the current month.', | ||
}), | ||
|
||
configAttrs: computed(function () { | ||
let keys = ['enabled', 'retentionMonths']; | ||
return expandAttributeMeta(this, keys); | ||
}), | ||
}); | ||
|
||
export default attachCapabilities(M, { | ||
configPath: apiPath`sys/internal/counters/config`, | ||
}); | ||
}) | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.