diff --git a/changelog/12422.txt b/changelog/12422.txt new file mode 100644 index 000000000..728b4a36e --- /dev/null +++ b/changelog/12422.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: updated client tracking config view +``` \ No newline at end of file diff --git a/ui/app/components/pricing-metrics-config.js b/ui/app/components/pricing-metrics-config.js index 50ad10354..a61ef3d34 100644 --- a/ui/app/components/pricing-metrics-config.js +++ b/ui/app/components/pricing-metrics-config.js @@ -10,19 +10,19 @@ * @param {string} [mode=show] - mode is either show or edit. Show results in a table with the config, show has a form. */ -import { computed } from '@ember/object'; -import Component from '@ember/component'; +import Component from '@glimmer/component'; +import { action } from '@ember/object'; import { inject as service } from '@ember/service'; +import { tracked } from '@glimmer/tracking'; import { task } from 'ember-concurrency'; -export default Component.extend({ - router: service(), - mode: 'show', - model: null, +export default class PricingMetricsConfigComponent extends Component { + @service router; + @tracked mode = 'show'; + @tracked modalOpen = false; + error = null; - error: null, - modalOpen: false, - infoRows: computed(function() { + get infoRows() { return [ { label: 'Usage data collection', @@ -40,35 +40,41 @@ export default Component.extend({ valueKey: 'defaultReportMonths', }, ]; - }), - modalTitle: computed('model.enabled', function() { + } + + get modalTitle() { let content = 'Turn usage tracking off?'; - if (this.model.enabled === 'On') { + if (this.args.model && this.args.model.enabled === 'On') { content = 'Turn usage tracking on?'; } return content; - }), + } - save: task(function*() { - let model = this.model; + @(task(function*() { try { - yield model.save(); + yield this.args.model.save(); } catch (err) { - this.set('error', err.message); + this.error = err.message; return; } this.router.transitionTo('vault.cluster.metrics.config'); - }).drop(), + }).drop()) + save; - actions: { - onSaveChanges: function(evt) { - evt.preventDefault(); - const changed = this.model.changedAttributes(); - if (!changed.enabled) { - this.save.perform(); - return; - } - this.set('modalOpen', true); - }, - }, -}); + @action + updateBooleanValue(attr, value) { + let valueToSet = value === true ? attr.options.trueValue : attr.options.falseValue; + this.args.model[attr.name] = valueToSet; + } + + @action + onSaveChanges(evt) { + evt.preventDefault(); + const changed = this.args.model.changedAttributes(); + if (!changed.enabled) { + this.save.perform(); + return; + } + this.modalOpen = true; + } +} diff --git a/ui/app/templates/components/pricing-metrics-config.hbs b/ui/app/templates/components/pricing-metrics-config.hbs index 4581569bb..b68137357 100644 --- a/ui/app/templates/components/pricing-metrics-config.hbs +++ b/ui/app/templates/components/pricing-metrics-config.hbs @@ -1,13 +1,46 @@ -{{#if (eq mode "edit")}} +{{#if (eq @mode "edit")}}
- - {{#each model.configAttrs as |attr|}} - + + {{#each @model.configAttrs as |attr|}} + {{#if (and (eq attr.type "string") (eq attr.options.editType "boolean"))}} + + {{#if attr.options.helpText}} +

{{attr.options.helpText}} {{#if attr.options.docLink}}See our documentation for help.{{/if}}

+ {{/if}} +
+ + +
+ {{else if (eq attr.type "number")}} +
+ + {{#if attr.options.subText}} +

{{attr.options.subText}} {{#if attr.options.docLink}}See our documentation for help.{{/if}}

+ {{/if}} +
+ +
+
+ {{/if}} {{/each}}
@@ -29,14 +62,14 @@