Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade bug and test fixes #17500

Merged
merged 10 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ui/app/adapters/auth-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
};
Expand All @@ -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 });
},
});
2 changes: 2 additions & 0 deletions ui/app/components/auth-config-form/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 3 additions & 10 deletions ui/app/components/auth-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,16 @@ export default Component.extend(DEFAULTS, {

delayAuthMessageReminder: task(function* () {
if (Ember.testing) {
this.showLoading = true;
yield timeout(0);
} else {
yield timeout(5000);
}
}),

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({
Expand Down
6 changes: 4 additions & 2 deletions ui/app/components/configure-aws-secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 3 additions & 2 deletions ui/app/components/configure-ssh-secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion ui/app/components/diff-version-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
zofskeez marked this conversation as resolved.
Show resolved Hide resolved

/**
* @module DiffVersionSelector
Expand Down
20 changes: 8 additions & 12 deletions ui/app/components/flash-message.js
Original file line number Diff line number Diff line change
@@ -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}`;
}
}
Comment on lines +1 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed to be updated after upgrading to the latest version since they converted to native class.

4 changes: 3 additions & 1 deletion ui/app/components/generate-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},

Expand Down
12 changes: 6 additions & 6 deletions ui/app/components/kv-object-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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', ''))) {
Expand Down
3 changes: 2 additions & 1 deletion ui/app/components/mount-backend-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export default class MountBackendForm extends Component {

@task
@waitFor
*mountBackend() {
*mountBackend(event) {
event.preventDefault();
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
const mountModel = this.mountModel;
const { type, path } = mountModel;
// only submit form if validations pass
Expand Down
12 changes: 6 additions & 6 deletions ui/app/components/oidc/provider-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ 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)
let clientExists = !!dropdownOptions.findBy('clientId', selection);
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
Expand Down
2 changes: 1 addition & 1 deletion ui/app/components/pki/config-pki-ca.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ui/app/components/raft-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 7 additions & 9 deletions ui/app/components/secret-create-or-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -52,26 +50,26 @@ 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: '',
};
// for validation, return array of path names already assigned
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();
}
}
Expand Down
17 changes: 8 additions & 9 deletions ui/app/components/secret-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions ui/app/components/transform-role-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
1 change: 1 addition & 0 deletions ui/app/components/transformation-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
6 changes: 5 additions & 1 deletion ui/app/components/transit-key-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/wrap-ttl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}}
</div>
Expand Down
1 change: 1 addition & 0 deletions ui/app/controllers/vault/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default Controller.extend({
router: service(),
permissions: service(),
namespaceService: service('namespace'),
flashMessages: service(),

vaultVersion: service('version'),
console: service(),
Expand Down
3 changes: 3 additions & 0 deletions ui/app/controllers/vault/cluster/access/methods.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
4 changes: 1 addition & 3 deletions ui/app/controllers/vault/cluster/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',

Expand Down
2 changes: 2 additions & 0 deletions ui/app/controllers/vault/cluster/secrets/backends.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default Controller.extend(CONFIG_ATTRS, {
},
})
.then(() => {
this.model.send('pushedData');
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
this.reset();
this.flashMessages.success('The backend configuration saved successfully!');
})
Expand Down
5 changes: 4 additions & 1 deletion ui/app/modifiers/code-mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Comment on lines -32 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Monkeychip this was this issue causing the same computation error. Since we are setting the editor value to the content arg in the setup the change event was firing immediately.

}

@action
Expand Down
Loading