From 537e4f1d3f2a692a51c8b42cb18c28ae00538d3a Mon Sep 17 00:00:00 2001 From: Arnav Palnitkar Date: Wed, 25 Aug 2021 14:22:15 -0700 Subject: [PATCH] Client count config view (#12422) * Client count config view - Switched to toggle button from checkbox and updated the design - Switched to ember octane - Update ember concurrency dependency * Fixed integration tests * Added changelog * Update switch label on toggle * Code cleanup * Fixed test --- changelog/12422.txt | 3 + ui/app/components/pricing-metrics-config.js | 66 ++++++++++--------- .../components/pricing-metrics-config.hbs | 63 +++++++++++++----- ui/package.json | 2 +- .../components/pricing-metrics-config-test.js | 10 +-- ui/yarn.lock | 17 ++++- 6 files changed, 107 insertions(+), 54 deletions(-) create mode 100644 changelog/12422.txt diff --git a/changelog/12422.txt b/changelog/12422.txt new file mode 100644 index 0000000000000..728b4a36e876e --- /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 50ad103545b72..a61ef3d3420cf 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; + + @action + updateBooleanValue(attr, value) { + let valueToSet = value === true ? attr.options.trueValue : attr.options.falseValue; + this.args.model[attr.name] = valueToSet; + } - actions: { - onSaveChanges: function(evt) { - evt.preventDefault(); - const changed = this.model.changedAttributes(); - if (!changed.enabled) { - this.save.perform(); - return; - } - this.set('modalOpen', true); - }, - }, -}); + @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 4581569bbf8d8..b6813735770cf 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 @@