diff --git a/ui/app/adapters/auth-method.js b/ui/app/adapters/auth-method.js index 6d441ae2a5ac..dc7a5e12295e 100644 --- a/ui/app/adapters/auth-method.js +++ b/ui/app/adapters/auth-method.js @@ -48,6 +48,7 @@ export default ApplicationAdapter.extend({ return this.ajax(this.url(path), 'POST', { data }).then(() => { // ember data doesn't like 204s if it's not a DELETE + data.config.id = path; // config relationship needs an id so use path for now return { data: assign({}, data, { path: path + '/', id: path }), }; @@ -63,6 +64,7 @@ export default ApplicationAdapter.extend({ }, tune(path, data) { - return this.ajax(`${this.url(path)}tune`, 'POST', { data }); + const url = `${this.buildURL()}/${this.pathForType()}/${encodePath(path)}tune`; + return this.ajax(url, 'POST', { data }); }, }); diff --git a/ui/app/components/auth-config-form/options.js b/ui/app/components/auth-config-form/options.js index 31951f5b4751..a0ccfb1ea662 100644 --- a/ui/app/components/auth-config-form/options.js +++ b/ui/app/components/auth-config-form/options.js @@ -18,8 +18,10 @@ import { waitFor } from '@ember/test-waiters'; */ export default AuthConfigComponent.extend({ + flashMessages: service(), router: service(), wizard: service(), + saveModel: task( waitFor(function* () { let data = this.model.config.serialize(); diff --git a/ui/app/components/auth-form.js b/ui/app/components/auth-form.js index eddbb9b27b04..9b753b2bd3fe 100644 --- a/ui/app/components/auth-form.js +++ b/ui/app/components/auth-form.js @@ -277,7 +277,6 @@ export default Component.extend(DEFAULTS, { delayAuthMessageReminder: task(function* () { if (Ember.testing) { - this.showLoading = true; yield timeout(0); } else { yield timeout(5000); @@ -285,15 +284,9 @@ export default Component.extend(DEFAULTS, { }), actions: { - doSubmit() { - let passedData, e; - if (arguments.length > 1) { - [passedData, e] = arguments; - } else { - [e] = arguments; - } - if (e) { - e.preventDefault(); + doSubmit(passedData, event) { + if (event) { + event.preventDefault(); } let data = {}; this.setProperties({ diff --git a/ui/app/components/configure-aws-secret.js b/ui/app/components/configure-aws-secret.js index b9d6e9b61bc0..84f53adf2e62 100644 --- a/ui/app/components/configure-aws-secret.js +++ b/ui/app/components/configure-aws-secret.js @@ -31,12 +31,14 @@ import { action } from '@ember/object'; */ export default class ConfigureAwsSecretComponent extends Component { @action - saveRootCreds(data) { + saveRootCreds(data, event) { + event.preventDefault(); this.args.saveAWSRoot(data); } @action - saveLease(data) { + saveLease(data, event) { + event.preventDefault(); this.args.saveAWSLease(data); } } diff --git a/ui/app/components/configure-ssh-secret.js b/ui/app/components/configure-ssh-secret.js index 562dd732e358..0c8803a62c40 100644 --- a/ui/app/components/configure-ssh-secret.js +++ b/ui/app/components/configure-ssh-secret.js @@ -18,7 +18,8 @@ import { action } from '@ember/object'; */ export default class ConfigureSshSecretComponent extends Component { @action - saveConfig(data) { - this.args.saveConfig(data); + saveConfig(event) { + event.preventDefault(); + this.args.saveConfig(event); } } diff --git a/ui/app/components/diff-version-selector.js b/ui/app/components/diff-version-selector.js index e4d9752919b9..25b8ad1f44db 100644 --- a/ui/app/components/diff-version-selector.js +++ b/ui/app/components/diff-version-selector.js @@ -3,7 +3,7 @@ import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; -import { htmlSafe } from '@ember/string'; +import { htmlSafe } from '@ember/template'; /** * @module DiffVersionSelector diff --git a/ui/app/components/flash-message.js b/ui/app/components/flash-message.js index 788e0a34caeb..49f026db37b2 100644 --- a/ui/app/components/flash-message.js +++ b/ui/app/components/flash-message.js @@ -1,15 +1,11 @@ -import { computed } from '@ember/object'; +/* eslint-disable ember/no-computed-properties-in-native-classes */ import FlashMessage from 'ember-cli-flash/components/flash-message'; -export default FlashMessage.extend({ +export default class FlashMessageComponent extends FlashMessage { // override alertType to get Bulma specific prefix - //https://github.com/poteto/ember-cli-flash/blob/master/addon/components/flash-message.js#L35 - alertType: computed('flash.type', { - get() { - const flashType = this.flash.type || ''; - let prefix = 'is-'; - - return `${prefix}${flashType}`; - }, - }), -}); + //https://github.com/poteto/ember-cli-flash/blob/master/addon/components/flash-message.js#L55 + get alertType() { + const flashType = this.args.flash.type || ''; + return `is-${flashType}`; + } +} diff --git a/ui/app/components/generate-credentials.js b/ui/app/components/generate-credentials.js index 630c0a0ba0d9..0b197f8e8532 100644 --- a/ui/app/components/generate-credentials.js +++ b/ui/app/components/generate-credentials.js @@ -66,7 +66,9 @@ export default Component.extend({ }, willDestroy() { - this.model.unloadRecord(); + if (!this.model.isDestroyed && !this.model.isDestroying) { + this.model.unloadRecord(); + } this._super(...arguments); }, diff --git a/ui/app/components/kv-object-editor.js b/ui/app/components/kv-object-editor.js index 907e2f997f3c..100aadc36e4b 100644 --- a/ui/app/components/kv-object-editor.js +++ b/ui/app/components/kv-object-editor.js @@ -33,12 +33,6 @@ import KVObject from 'vault/lib/kv-object'; export default class KvObjectEditor extends Component { @tracked kvData; - constructor() { - super(...arguments); - this.kvData = KVObject.create({ content: [] }).fromJSON(this.args.value); - this.addRow(); - } - get placeholders() { return { key: this.args.keyPlaceholder || 'key', @@ -49,6 +43,12 @@ export default class KvObjectEditor extends Component { return this.kvData.uniqBy('name').length !== this.kvData.get('length'); } + // fired on did-insert from render modifier + @action + createKvData(elem, [value]) { + this.kvData = KVObject.create({ content: [] }).fromJSON(value); + this.addRow(); + } @action addRow() { if (!isNone(this.kvData.findBy('name', ''))) { diff --git a/ui/app/components/mount-backend-form.js b/ui/app/components/mount-backend-form.js index 980e0586dbd3..b3b3a6bff3b0 100644 --- a/ui/app/components/mount-backend-form.js +++ b/ui/app/components/mount-backend-form.js @@ -95,7 +95,8 @@ export default class MountBackendForm extends Component { @task @waitFor - *mountBackend() { + *mountBackend(event) { + event.preventDefault(); const mountModel = this.mountModel; const { type, path } = mountModel; // only submit form if validations pass diff --git a/ui/app/components/oidc/provider-form.js b/ui/app/components/oidc/provider-form.js index 404a3c25344a..2b0f4224f585 100644 --- a/ui/app/components/oidc/provider-form.js +++ b/ui/app/components/oidc/provider-form.js @@ -31,12 +31,6 @@ export default class OidcProviderForm extends Component { ? 'allow_all' : 'limited'; - constructor() { - super(...arguments); - const { model } = this.args; - model.issuer = model.isNew ? '' : parseURL(model.issuer).origin; - } - // function passed to search select renderInfoTooltip(selection, dropdownOptions) { // if a client has been deleted it will not exist in dropdownOptions (response from search select's query) @@ -44,6 +38,12 @@ export default class OidcProviderForm extends Component { return !clientExists ? 'The application associated with this client_id no longer exists' : false; } + // fired on did-insert from render modifier + @action + setIssuer(elem, [model]) { + model.issuer = model.isNew ? '' : parseURL(model.issuer).origin; + } + @action handleClientSelection(selection) { // if array then coming from search-select component, set selection as model clients diff --git a/ui/app/components/pki/config-pki-ca.js b/ui/app/components/pki/config-pki-ca.js index c7ae3172ab39..223b8928686a 100644 --- a/ui/app/components/pki/config-pki-ca.js +++ b/ui/app/components/pki/config-pki-ca.js @@ -70,7 +70,7 @@ export default Component.extend({ willDestroy() { const ca = this.model; - if (ca) { + if (ca && !ca.isDestroyed && !ca.isDestroying) { ca.unloadRecord(); } this._super(...arguments); diff --git a/ui/app/components/raft-join.js b/ui/app/components/raft-join.js index 41de3921deb3..67b7acae1f9c 100644 --- a/ui/app/components/raft-join.js +++ b/ui/app/components/raft-join.js @@ -24,7 +24,8 @@ export default Component.extend({ preference: 'join', showJoinForm: false, actions: { - advanceFirstScreen() { + advanceFirstScreen(event) { + event.preventDefault(); if (this.preference !== 'join') { this.onDismiss(); return; diff --git a/ui/app/components/secret-create-or-update.js b/ui/app/components/secret-create-or-update.js index ea7ba030942f..52b86a879517 100644 --- a/ui/app/components/secret-create-or-update.js +++ b/ui/app/components/secret-create-or-update.js @@ -27,11 +27,9 @@ import Component from '@glimmer/component'; import ControlGroupError from 'vault/lib/control-group-error'; import Ember from 'ember'; import keys from 'vault/lib/keycodes'; - import { action, set } from '@ember/object'; import { inject as service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; - import { isBlank, isNone } from '@ember/utils'; import { task, waitForEvent } from 'ember-concurrency'; @@ -52,9 +50,9 @@ export default class SecretCreateOrUpdate extends Component { @service store; @service wizard; - constructor() { - super(...arguments); - this.codemirrorString = this.args.secretData.toJSONString(); + @action + setup(elem, [secretData, model, mode]) { + this.codemirrorString = secretData.toJSONString(); this.validationMessages = { path: '', }; @@ -62,16 +60,16 @@ export default class SecretCreateOrUpdate extends Component { if (Ember.testing) { this.secretPaths = ['beep', 'bop', 'boop']; } else { - let adapter = this.store.adapterFor('secret-v2'); - let type = { modelName: 'secret-v2' }; - let query = { backend: this.args.model.backend }; + const adapter = this.store.adapterFor('secret-v2'); + const type = { modelName: 'secret-v2' }; + const query = { backend: model.backend }; adapter.query(this.store, type, query).then((result) => { this.secretPaths = result.data.keys; }); } this.checkRows(); - if (this.args.mode === 'edit') { + if (mode === 'edit') { this.addRow(); } } diff --git a/ui/app/components/secret-edit.js b/ui/app/components/secret-edit.js index 65b3f29d9cc2..52c06e560b6a 100644 --- a/ui/app/components/secret-edit.js +++ b/ui/app/components/secret-edit.js @@ -34,18 +34,17 @@ export default class SecretEdit extends Component { @tracked isV2 = false; @tracked codemirrorString = null; - constructor() { - super(...arguments); - let secrets = this.args.model.secretData; - if (!secrets && this.args.model.selectedVersion) { + // fired on did-insert from render modifier + @action + createKvData(elem, [model]) { + if (!model.secretData && model.selectedVersion) { this.isV2 = true; - secrets = this.args.model.belongsTo('selectedVersion').value().secretData; + model.secretData = model.belongsTo('selectedVersion').value().secretData; } - const data = KVObject.create({ content: [] }).fromJSON(secrets); - this.secretData = data; - this.codemirrorString = data.toJSONString(); + this.secretData = KVObject.create({ content: [] }).fromJSON(model.secretData); + this.codemirrorString = this.secretData.toJSONString(); if (this.wizard.featureState === 'details' && this.args.mode === 'create') { - let engine = this.args.model.backend.includes('kv') ? 'kv' : this.args.model.backend; + const engine = model.backend.includes('kv') ? 'kv' : model.backend; this.wizard.transitionFeatureMachine('details', 'CONTINUE', engine); } } diff --git a/ui/app/components/transform-role-edit.js b/ui/app/components/transform-role-edit.js index ac02d1ae8a76..23d5caf505c7 100644 --- a/ui/app/components/transform-role-edit.js +++ b/ui/app/components/transform-role-edit.js @@ -2,6 +2,7 @@ import TransformBase, { addToList, removeFromList } from './transform-edit-base' import { inject as service } from '@ember/service'; export default TransformBase.extend({ + flashMessages: service(), store: service(), initialTransformations: null, diff --git a/ui/app/components/transformation-edit.js b/ui/app/components/transformation-edit.js index 9ce050a51de8..ec65ea3e88fb 100644 --- a/ui/app/components/transformation-edit.js +++ b/ui/app/components/transformation-edit.js @@ -2,6 +2,7 @@ import TransformBase, { addToList, removeFromList } from './transform-edit-base' import { inject as service } from '@ember/service'; export default TransformBase.extend({ + flashMessages: service(), store: service(), initialRoles: null, diff --git a/ui/app/components/transit-key-actions.js b/ui/app/components/transit-key-actions.js index 1fd3894923b4..42f5a9d999c9 100644 --- a/ui/app/components/transit-key-actions.js +++ b/ui/app/components/transit-key-actions.js @@ -216,7 +216,11 @@ export default Component.extend(TRANSIT_PARAMS, { this.toggleProperty('isModalActive'); }, - doSubmit(data, options = {}) { + doSubmit(data, options = {}, maybeEvent) { + const event = options.type === 'submit' ? options : maybeEvent; + if (event) { + event.preventDefault(); + } const { backend, id } = this.getModelInfo(); const action = this.selectedAction; const { encodedBase64, ...formData } = data || {}; diff --git a/ui/app/components/wrap-ttl.js b/ui/app/components/wrap-ttl.js index 19b5afb74aa0..395a657c4835 100644 --- a/ui/app/components/wrap-ttl.js +++ b/ui/app/components/wrap-ttl.js @@ -32,8 +32,8 @@ export default Component.extend({ label='Wrap response' helperTextDisabled='Will not wrap response' helperTextEnabled='Will wrap response with a lease of' - enableTTL=wrapResponse - initialValue=ttl + enableTTL=this.wrapResponse + initialValue=this.ttl onChange=(action 'changedValue') }} diff --git a/ui/app/controllers/vault/cluster.js b/ui/app/controllers/vault/cluster.js index 8528655e82d4..cd33af43b01f 100644 --- a/ui/app/controllers/vault/cluster.js +++ b/ui/app/controllers/vault/cluster.js @@ -10,6 +10,7 @@ export default Controller.extend({ router: service(), permissions: service(), namespaceService: service('namespace'), + flashMessages: service(), vaultVersion: service('version'), console: service(), diff --git a/ui/app/controllers/vault/cluster/access/methods.js b/ui/app/controllers/vault/cluster/access/methods.js index 222874afc85e..4ed0409331ac 100644 --- a/ui/app/controllers/vault/cluster/access/methods.js +++ b/ui/app/controllers/vault/cluster/access/methods.js @@ -1,7 +1,10 @@ import Controller from '@ember/controller'; import { task } from 'ember-concurrency'; +import { inject as service } from '@ember/service'; export default Controller.extend({ + flashMessages: service(), + queryParams: { page: 'page', pageFilter: 'pageFilter', diff --git a/ui/app/controllers/vault/cluster/auth.js b/ui/app/controllers/vault/cluster/auth.js index 496ceaf1c8bc..76f9bb9f78a6 100644 --- a/ui/app/controllers/vault/cluster/auth.js +++ b/ui/app/controllers/vault/cluster/auth.js @@ -4,20 +4,18 @@ import Controller, { inject as controller } from '@ember/controller'; import { task, timeout } from 'ember-concurrency'; export default Controller.extend({ + flashMessages: service(), vaultController: controller('vault'), clusterController: controller('vault.cluster'), namespaceService: service('namespace'), featureFlagService: service('featureFlag'), auth: service(), router: service(), - queryParams: [{ authMethod: 'with', oidcProvider: 'o' }], - namespaceQueryParam: alias('clusterController.namespaceQueryParam'), wrappedToken: alias('vaultController.wrappedToken'), redirectTo: alias('vaultController.redirectTo'), managedNamespaceRoot: alias('featureFlagService.managedNamespaceRoot'), - authMethod: '', oidcProvider: '', diff --git a/ui/app/controllers/vault/cluster/secrets/backends.js b/ui/app/controllers/vault/cluster/secrets/backends.js index d3daf50134f7..95b173d2bcf6 100644 --- a/ui/app/controllers/vault/cluster/secrets/backends.js +++ b/ui/app/controllers/vault/cluster/secrets/backends.js @@ -3,9 +3,11 @@ import { computed } from '@ember/object'; import Controller from '@ember/controller'; import { task } from 'ember-concurrency'; import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends'; +import { inject as service } from '@ember/service'; const LINKED_BACKENDS = supportedSecretBackends(); export default Controller.extend({ + flashMessages: service(), displayableBackends: filterBy('model', 'shouldIncludeInList'), supportedBackends: computed('displayableBackends', 'displayableBackends.[]', function () { diff --git a/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js b/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js index 9ce582a1d6b0..6908b07ecac5 100644 --- a/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js +++ b/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js @@ -57,7 +57,6 @@ export default Controller.extend(CONFIG_ATTRS, { }, }) .then(() => { - this.model.send('pushedData'); this.reset(); this.flashMessages.success('The backend configuration saved successfully!'); }) diff --git a/ui/app/modifiers/code-mirror.js b/ui/app/modifiers/code-mirror.js index f018c0974855..d1a31041079b 100644 --- a/ui/app/modifiers/code-mirror.js +++ b/ui/app/modifiers/code-mirror.js @@ -29,7 +29,10 @@ export default class CodeMirrorModifier extends Modifier { @action _onChange(editor) { - this.args.named.onUpdate(editor.getValue(), this._editor); + // avoid sending change event after initial setup when editor value is set to content + if (this.args.named.content !== editor.getValue()) { + this.args.named.onUpdate(editor.getValue(), this._editor); + } } @action diff --git a/ui/app/serializers/auth-method.js b/ui/app/serializers/auth-method.js index 9b2ba244ccfc..f68e50e37af0 100644 --- a/ui/app/serializers/auth-method.js +++ b/ui/app/serializers/auth-method.js @@ -8,7 +8,7 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, { normalize(modelClass, data) { // embedded records need a unique value to be stored // use the uuid from the auth-method as the unique id for mount-config - if (data.config) { + if (data.config && !data.config.id) { data.config.id = data.uuid; } return this._super(modelClass, data); diff --git a/ui/app/templates/components/auth-form.hbs b/ui/app/templates/components/auth-form.hbs index db216af8a376..4924ac01cfdd 100644 --- a/ui/app/templates/components/auth-form.hbs +++ b/ui/app/templates/components/auth-form.hbs @@ -91,7 +91,7 @@ /> {{else}} -