Client count: remove default period and extra controllers (#14050)

* remove controllerS

* remove default report months

* remove default months from the config page

* fix tests

* clean up edit config
This commit is contained in:
Angel Garbarino 2022-02-14 11:30:48 -07:00 committed by GitHub
parent 2a08838ed5
commit 687469552c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 131 additions and 174 deletions

View file

@ -34,11 +34,6 @@ export default class ConfigComponent extends Component {
helperText: 'The number of months of activity logs to maintain for client tracking.',
valueKey: 'retentionMonths',
},
{
label: 'Default display',
helperText: 'The number of months well display in the Vault usage dashboard by default.',
valueKey: 'defaultReportMonths',
},
];
}

View file

@ -1,3 +0,0 @@
import Controller from '@ember/controller';
export default class ConfigController extends Controller {}

View file

@ -1,3 +0,0 @@
import Controller from '@ember/controller';
export default class CurrentController extends Controller {}

View file

@ -1,3 +0,0 @@
import Controller from '@ember/controller';
export default class HistoryController extends Controller {}

View file

@ -1,3 +0,0 @@
import Controller from '@ember/controller';
export default class ClientsController extends Controller {}

View file

@ -6,10 +6,6 @@ import { apiPath } from 'vault/macros/lazy-capabilities';
const M = Model.extend({
queriesAvailable: attr('boolean'),
defaultReportMonths: attr('number', {
label: 'Default display',
subText: 'The number of months well display in the Vault usage dashboard by default.',
}),
retentionMonths: attr('number', {
label: 'Retention period',
subText: 'The number of months of activity logs to maintain for client tracking.',
@ -24,7 +20,7 @@ const M = Model.extend({
}),
configAttrs: computed(function () {
let keys = ['enabled', 'defaultReportMonths', 'retentionMonths'];
let keys = ['enabled', 'retentionMonths'];
return expandAttributeMeta(this, keys);
}),
});

View file

@ -22,9 +22,8 @@ export default ApplicationSerializer.extend({
const oldEnabled = json.enabled;
json.enabled = oldEnabled === 'On' ? 'enable' : 'disable';
}
json.default_report_months = parseInt(json.default_report_months, 10);
json.retention_months = parseInt(json.retention_months, 10);
if (isNaN(json.default_report_months) || isNaN(json.retention_months)) {
if (isNaN(json.retention_months)) {
throw new Error('Invalid number value');
}
delete json.queries_available;

View file

@ -1,6 +1,3 @@
{{#if @isLoading}}
<LayoutLoading />
{{else}}
{{#if (eq @mode "edit")}}
<form onsubmit={{action "onSaveChanges"}} data-test-pricing-metrics-config-form>
<div class="box is-sideless is-fullwidth is-marginless">
@ -132,4 +129,3 @@
{{/each}}
</div>
{{/if}}
{{/if}}

View file

@ -45,9 +45,6 @@
</DocLink>
</AlertBanner>
{{/if}}
{{#if @isLoading}}
<LayoutLoading />
{{else}}
{{#if this.totalUsageCounts}}
<Clients::UsageStats
@title={{date-format this.responseTimestamp "MMMM"}}
@ -66,5 +63,4 @@
{{/if}}
{{/if}}
{{/if}}
{{/if}}
</div>

View file

@ -1,9 +1 @@
<PageHeader as |p|>
<p.levelLeft>
<h1 class="title is-3">
Configure usage tracking
</h1>
</p.levelLeft>
</PageHeader>
<Clients::Config @model={{@model}} @mode="edit" />

View file

@ -34,7 +34,6 @@ module('Integration | Component | client count config', function (hooks) {
configAttrs: [
createAttr('enabled', 'string', { editType: 'boolean' }),
createAttr('retentionMonths', 'number'),
createAttr('defaultReportMonths', 'number'),
],
changedAttributes: () => ({}),
save: () => {},
@ -54,7 +53,7 @@ module('Integration | Component | client count config', function (hooks) {
assert.dom('[data-test-pricing-metrics-config-table]').exists('Pricing metrics config table exists');
const rows = document.querySelectorAll('.info-table-row');
assert.equal(rows.length, 3, 'renders 3 infotable rows');
assert.equal(rows.length, 2, 'renders 2 infotable rows');
assert.ok(
find('[data-test-row-value="Usage data collection"]').textContent.includes('On'),
'Enabled value matches model'
@ -63,10 +62,6 @@ module('Integration | Component | client count config', function (hooks) {
find('[data-test-row-value="Retention period"]').textContent.includes('24'),
'Retention period value matches model'
);
assert.ok(
find('[data-test-row-value="Default display"]').textContent.includes('12'),
'Default display value matches model'
);
});
test('TODO: it shows the config edit form when mode = edit', async function (assert) {
@ -77,7 +72,7 @@ module('Integration | Component | client count config', function (hooks) {
assert.dom('[data-test-pricing-metrics-config-form]').exists('Pricing metrics config form exists');
const fields = document.querySelectorAll('[data-test-field]');
assert.equal(fields.length, 3, 'renders 3 fields');
assert.equal(fields.length, 2, 'renders 2 fields');
});
test('it shows a modal with correct messaging when disabling', async function (assert) {
@ -126,7 +121,7 @@ module('Integration | Component | client count config', function (hooks) {
test('it does not show a modal on save if enable left unchanged', async function (assert) {
// Simulates the model when something other than enabled changed
const simModel = generateModel({
changedAttributes: () => ({ defaultReportMonths: [24, '48'] }),
changedAttributes: () => ({ retentionMonths: [24, '48'] }),
});
this.set('model', simModel);
await render(hbs`