mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
UI: Ember deprecation prep for 5.0: ember-data:deprecate-array-like (#26170)
* remove .get() from cluster and vault route * replace .get() use in adapters * remove .get() from components part 1 * remove .get() from string-list * remaining components * controller .get() removal * remove .get() use in mixins * routes/cluster/access* .get() replacement * policy index route * routes/secrets/backend* * route/cluster* * serializers * is-active-route * remaining top-level addon gets * replication get() * revery change that broke things * woops, revert other store service change * revert some controller changes * revert get on URLSearchParams class * remove .sortBy ember method * small cleanup items * small cleanups from PR review
This commit is contained in:
@@ -8,6 +8,7 @@ import { encodePath } from 'vault/utils/path-encoding-helpers';
|
||||
import { service } from '@ember/service';
|
||||
import AdapterError from '@ember-data/adapter/error';
|
||||
import { addManyToArray } from 'vault/helpers/add-to-array';
|
||||
import sortObjects from 'vault/utils/sort-objects';
|
||||
|
||||
export default class LdapRoleAdapter extends NamedPathAdapter {
|
||||
@service flashMessages;
|
||||
@@ -72,7 +73,7 @@ export default class LdapRoleAdapter extends NamedPathAdapter {
|
||||
}
|
||||
// must return an object in this shape for lazyPaginatedQuery to function
|
||||
// changing the responsePath or providing the extractLazyPaginatedData serializer method causes normalizeResponse to return data: [undefined]
|
||||
return { data: { keys: roles.sortBy('name') } };
|
||||
return { data: { keys: sortObjects(roles, 'name') } };
|
||||
}
|
||||
queryRecord(store, type, query) {
|
||||
const { backend, name, type: roleType } = query;
|
||||
|
||||
@@ -34,7 +34,7 @@ export default ApplicationAdapter.extend({
|
||||
|
||||
deleteRecord(store, type, snapshot) {
|
||||
const { id } = snapshot;
|
||||
return this.ajax(this.urlForRole(snapshot.record.get('backend'), id), 'DELETE');
|
||||
return this.ajax(this.urlForRole(snapshot.record.backend, id), 'DELETE');
|
||||
},
|
||||
|
||||
pathForType() {
|
||||
|
||||
@@ -34,7 +34,7 @@ export default ApplicationAdapter.extend({
|
||||
|
||||
deleteRecord(store, type, snapshot) {
|
||||
const { id } = snapshot;
|
||||
return this.ajax(this.urlForRole(snapshot.record.get('backend'), id), 'DELETE');
|
||||
return this.ajax(this.urlForRole(snapshot.record.backend, id), 'DELETE');
|
||||
},
|
||||
|
||||
pathForType() {
|
||||
|
||||
@@ -33,7 +33,7 @@ export default ApplicationAdapter.extend({
|
||||
|
||||
deleteRecord(store, type, snapshot) {
|
||||
const { id } = snapshot;
|
||||
return this.ajax(this.urlForTransformations(snapshot.record.get('backend'), id), 'DELETE');
|
||||
return this.ajax(this.urlForTransformations(snapshot.record.backend, id), 'DELETE');
|
||||
},
|
||||
|
||||
pathForType() {
|
||||
|
||||
@@ -36,7 +36,7 @@ export default ApplicationAdapter.extend({
|
||||
|
||||
deleteRecord(store, type, snapshot) {
|
||||
const { id } = snapshot;
|
||||
return this.ajax(this.url(snapshot.record.get('backend'), type.modelName, id), 'DELETE');
|
||||
return this.ajax(this.url(snapshot.record.backend, type.modelName, id), 'DELETE');
|
||||
},
|
||||
|
||||
url(backend, modelType, id) {
|
||||
|
||||
@@ -14,7 +14,7 @@ export default ApplicationAdapter.extend({
|
||||
const serializer = store.serializerFor(type.modelName);
|
||||
const data = serializer.serialize(snapshot, requestType);
|
||||
const name = snapshot.attr('name');
|
||||
let url = this.urlForSecret(snapshot.record.get('backend'), name);
|
||||
let url = this.urlForSecret(snapshot.record.backend, name);
|
||||
if (requestType === 'update') {
|
||||
url = url + '/config';
|
||||
}
|
||||
@@ -36,7 +36,7 @@ export default ApplicationAdapter.extend({
|
||||
|
||||
deleteRecord(store, type, snapshot) {
|
||||
const { id } = snapshot;
|
||||
return this.ajax(this.urlForSecret(snapshot.record.get('backend'), id), 'DELETE');
|
||||
return this.ajax(this.urlForSecret(snapshot.record.backend, id), 'DELETE');
|
||||
},
|
||||
|
||||
pathForType(type) {
|
||||
|
||||
@@ -105,7 +105,7 @@ export default Component.extend({
|
||||
|
||||
refreshRoute: task(function* () {
|
||||
const owner = getOwner(this);
|
||||
const currentRoute = owner.lookup(`router:main`).get('currentRouteName');
|
||||
const currentRoute = owner.lookup(`router:main`).currentRouteName;
|
||||
|
||||
try {
|
||||
this.store.clearAllDatasets();
|
||||
|
||||
@@ -77,7 +77,7 @@ export default Component.extend({
|
||||
// components are torn down after store is disconnected and will cause an error if attempt to unload record
|
||||
const noTeardown = this.store && !this.store.isDestroying;
|
||||
const model = this.model;
|
||||
if (noTeardown && model && model.get('isDirty') && !model.isDestroyed && !model.isDestroying) {
|
||||
if (noTeardown && model && model.isDirty && !model.isDestroyed && !model.isDestroying) {
|
||||
model.rollbackAttributes();
|
||||
}
|
||||
this._super(...arguments);
|
||||
|
||||
@@ -60,7 +60,8 @@ export default Component.extend({
|
||||
return;
|
||||
}
|
||||
const isAdding = leaves.length > lastLeaves.length;
|
||||
const changedLeaf = (isAdding ? leaves : lastLeaves).get('lastObject');
|
||||
const changedLeaves = isAdding ? leaves : lastLeaves;
|
||||
const [changedLeaf] = changedLeaves.slice(-1);
|
||||
this.set('isAdding', isAdding);
|
||||
this.set('changedLeaf', changedLeaf);
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ export default class SecretCreateOrUpdate extends Component {
|
||||
const secret = this.args.model;
|
||||
const secretData = this.args.modelForData;
|
||||
|
||||
let key = secretData.get('path') || secret.id;
|
||||
let key = secretData?.path || secret.id;
|
||||
|
||||
if (key.startsWith('/')) {
|
||||
key = key.replace(/^\/+/g, '');
|
||||
|
||||
@@ -28,7 +28,7 @@ export default Component.extend({
|
||||
isBuiltin: computed('item', 'itemType', function () {
|
||||
const item = this.item;
|
||||
if (this.itemType === 'alphabet' || this.itemType === 'template') {
|
||||
return item.get('id').startsWith('builtin/');
|
||||
return item.id.startsWith('builtin/');
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
|
||||
@@ -24,7 +24,7 @@ export default Controller.extend(ListController, {
|
||||
|
||||
actions: {
|
||||
delete(model) {
|
||||
const type = model.get('identityType');
|
||||
const type = model.identityType;
|
||||
const id = model.id;
|
||||
return model
|
||||
.destroyRecord()
|
||||
@@ -41,8 +41,8 @@ export default Controller.extend(ListController, {
|
||||
},
|
||||
|
||||
toggleDisabled(model) {
|
||||
const action = model.get('disabled') ? ['enabled', 'enabling'] : ['disabled', 'disabling'];
|
||||
const type = model.get('identityType');
|
||||
const action = model.disabled ? ['enabled', 'enabling'] : ['disabled', 'disabling'];
|
||||
const type = model.identityType;
|
||||
const id = model.id;
|
||||
model.toggleProperty('disabled');
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { dropTask } from 'ember-concurrency';
|
||||
import { service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import sortObjects from 'vault/utils/sort-objects';
|
||||
|
||||
export default class VaultClusterAccessMethodsController extends Controller {
|
||||
@service flashMessages;
|
||||
@@ -23,6 +24,7 @@ export default class VaultClusterAccessMethodsController extends Controller {
|
||||
pageFilter = null;
|
||||
filter = null;
|
||||
|
||||
// list returned by getter is sorted in template
|
||||
get authMethodList() {
|
||||
// return an options list to filter by engine type, ex: 'kv'
|
||||
if (this.selectedAuthType) {
|
||||
@@ -39,7 +41,7 @@ export default class VaultClusterAccessMethodsController extends Controller {
|
||||
if (this.selectedAuthName) {
|
||||
return this.model.filter((method) => this.selectedAuthName === method.id);
|
||||
}
|
||||
// no filters, return full sorted list.
|
||||
// no filters, return full list
|
||||
return this.model;
|
||||
}
|
||||
|
||||
@@ -85,4 +87,7 @@ export default class VaultClusterAccessMethodsController extends Controller {
|
||||
this.methodToDisable = null;
|
||||
}
|
||||
}
|
||||
|
||||
// template helper
|
||||
sortMethods = (methods) => sortObjects(methods.slice(), 'path');
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export default Controller.extend({
|
||||
return filterMatchesKey
|
||||
? null
|
||||
: content.find(function (key) {
|
||||
return re.test(key.get('id'));
|
||||
return re.test(key.id);
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -62,7 +62,7 @@ export default Controller.extend({
|
||||
this.set('filterFocused', bool);
|
||||
},
|
||||
deletePolicy(model) {
|
||||
const policyType = model.get('policyType');
|
||||
const { policyType } = model;
|
||||
const name = model.id;
|
||||
const flash = this.flashMessages;
|
||||
model
|
||||
|
||||
@@ -36,7 +36,7 @@ export default Controller.extend({
|
||||
|
||||
newModel() {
|
||||
const model = this.model;
|
||||
const roleModel = model.get('role');
|
||||
const roleModel = model.role;
|
||||
model.unloadRecord();
|
||||
const newModel = this.store.createRecord('ssh-sign', {
|
||||
role: roleModel,
|
||||
|
||||
@@ -58,7 +58,7 @@ export default Route.extend({
|
||||
// Assuming we have a URL, push it into browser history and update the
|
||||
// location bar for the user
|
||||
if (errorURL) {
|
||||
router.get('location').setURL(errorURL);
|
||||
router.location.setURL(errorURL);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -42,7 +42,7 @@ export default class VaultRoute extends Route {
|
||||
}
|
||||
|
||||
redirect(model, transition) {
|
||||
if (model.get('length') === 1 && transition.targetName === 'vault.index') {
|
||||
if (model.length === 1 && transition.targetName === 'vault.index') {
|
||||
return this.router.transitionTo('vault.cluster', model[0].name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, {
|
||||
const { cluster_name } = params;
|
||||
const records = this.store.peekAll('cluster');
|
||||
const cluster = records.find((record) => record.name === cluster_name);
|
||||
return cluster ? cluster.get('id') : null;
|
||||
return cluster?.id ?? null;
|
||||
},
|
||||
|
||||
async beforeModel() {
|
||||
const params = this.paramsFor(this.routeName);
|
||||
let namespace = params.namespaceQueryParam;
|
||||
const currentTokenName = this.auth.get('currentTokenName');
|
||||
const currentTokenName = this.auth.currentTokenName;
|
||||
const managedRoot = this.featureFlagService.managedNamespaceRoot;
|
||||
assert(
|
||||
'Cannot use VAULT_CLOUD_ADMIN_NAMESPACE flag with non-enterprise Vault version',
|
||||
|
||||
@@ -30,7 +30,7 @@ export default Route.extend({
|
||||
let model = this.store.peekRecord(modelType, params.item_id);
|
||||
|
||||
// if we don't have creationTime, we only have a partial model so reload
|
||||
if (model && !model.get('creationTime')) {
|
||||
if (model && !model?.creationTime) {
|
||||
model = model.reload();
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ export default Route.extend({
|
||||
if (this.currentModel) {
|
||||
next(() => {
|
||||
/* eslint-disable-next-line ember/no-controller-access-in-routes */
|
||||
this.controller.get('model').reload();
|
||||
this.controller.model.reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
afterModel(resolvedModel) {
|
||||
const { section, model } = resolvedModel;
|
||||
if (model.get('identityType') === 'group' && model.get('type') === 'internal' && section === 'aliases') {
|
||||
if (model?.identityType === 'group' && model?.type === 'internal' && section === 'aliases') {
|
||||
return this.router.transitionTo('vault.cluster.access.identity.show', model.id, 'details');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -10,10 +10,7 @@ export default class LeasesIndexRoute extends Route {
|
||||
@service router;
|
||||
|
||||
beforeModel(transition) {
|
||||
if (
|
||||
this.modelFor('vault.cluster.access.leases').get('canList') &&
|
||||
transition.targetName === this.routeName
|
||||
) {
|
||||
if (this.modelFor('vault.cluster.access.leases').canList && transition.targetName === this.routeName) {
|
||||
return this.router.replaceWith('vault.cluster.access.leases.list-root');
|
||||
} else {
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,7 @@ export default Route.extend({
|
||||
|
||||
model(params) {
|
||||
const prefix = params.prefix || '';
|
||||
if (this.modelFor('vault.cluster.access.leases').get('canList')) {
|
||||
if (this.modelFor('vault.cluster.access.leases').canList) {
|
||||
return hash({
|
||||
leases: this.store
|
||||
.lazyPaginatedQuery('lease', {
|
||||
@@ -73,7 +73,7 @@ export default Route.extend({
|
||||
}
|
||||
controller.setProperties({
|
||||
filter: filter || '',
|
||||
page: model.leases.get('meta.currentPage'),
|
||||
page: model.leases?.meta?.currentPage,
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -91,7 +91,7 @@ export default Route.extend({
|
||||
|
||||
set(error, 'keyId', prefix);
|
||||
/* eslint-disable-next-line ember/no-controller-access-in-routes */
|
||||
const hasModel = this.controllerFor(this.routeName).get('hasModel');
|
||||
const hasModel = this.controllerFor(this.routeName).hasModel;
|
||||
// only swallow the error if we have a previous model
|
||||
if (hasModel && error.httpStatus === 404) {
|
||||
this.set('has404', true);
|
||||
|
||||
@@ -63,7 +63,7 @@ export default Route.extend(UnloadModel, {
|
||||
actions: {
|
||||
error(error, transition) {
|
||||
/* eslint-disable-next-line ember/no-controller-access-in-routes */
|
||||
const hasModel = this.controllerFor(this.routeName).get('hasModel');
|
||||
const hasModel = this.controllerFor(this.routeName).hasModel;
|
||||
if (hasModel && error.httpStatus === 404) {
|
||||
this.set('has404', true);
|
||||
transition.abort();
|
||||
|
||||
@@ -29,7 +29,7 @@ export default class VaultClusterOidcProviderRoute extends Route {
|
||||
}
|
||||
|
||||
beforeModel(transition) {
|
||||
const currentToken = this.auth.get('currentTokenName');
|
||||
const currentToken = this.auth.currentTokenName;
|
||||
const qp = transition.to.queryParams;
|
||||
// remove redirect_to if carried over from auth
|
||||
qp.redirect_to = null;
|
||||
|
||||
@@ -13,7 +13,7 @@ export default Route.extend(ClusterRoute, ListRoute, {
|
||||
version: service(),
|
||||
|
||||
shouldReturnEmptyModel(policyType, version) {
|
||||
return policyType !== 'acl' && (version.get('isCommunity') || !version.get('hasSentinel'));
|
||||
return policyType !== 'acl' && (version.isCommunity || !version.hasSentinel);
|
||||
},
|
||||
|
||||
model(params) {
|
||||
@@ -49,7 +49,7 @@ export default Route.extend(ClusterRoute, ListRoute, {
|
||||
controller.setProperties({
|
||||
model,
|
||||
filter: params.pageFilter || '',
|
||||
page: model.get('meta.currentPage') || 1,
|
||||
page: model.meta?.currentPage || 1,
|
||||
policyType: this.policyType(),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@ export default Route.extend({
|
||||
},
|
||||
|
||||
afterModel(model, transition) {
|
||||
const path = model && model.get('path');
|
||||
const path = model && model.path;
|
||||
if (transition.targetName === this.routeName) {
|
||||
return this.router.replaceWith('vault.cluster.secrets.backend.list-root', path);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@ export default Route.extend({
|
||||
router: service(),
|
||||
store: service(),
|
||||
|
||||
backendModel() {
|
||||
return this.modelFor('vault.cluster.secrets.backend');
|
||||
},
|
||||
|
||||
beforeModel() {
|
||||
const { backend } = this.paramsFor('vault.cluster.secrets.backend');
|
||||
if (backend != 'ssh') {
|
||||
@@ -57,15 +53,13 @@ export default Route.extend({
|
||||
|
||||
async model(params) {
|
||||
const role = params.secret;
|
||||
const backendModel = this.backendModel();
|
||||
const backendPath = backendModel.get('id');
|
||||
const backendType = backendModel.get('type');
|
||||
const { id: backendPath, type: backendType } = this.modelFor('vault.cluster.secrets.backend');
|
||||
const roleType = params.roleType;
|
||||
let dbCred;
|
||||
if (backendType === 'database') {
|
||||
dbCred = await this.getDatabaseCredential(backendPath, role, roleType);
|
||||
}
|
||||
if (!SUPPORTED_DYNAMIC_BACKENDS.includes(backendModel.get('type'))) {
|
||||
if (!SUPPORTED_DYNAMIC_BACKENDS.includes(backendType)) {
|
||||
return this.router.transitionTo('vault.cluster.secrets.backend.list-root', backendPath);
|
||||
}
|
||||
return resolve({
|
||||
|
||||
@@ -146,7 +146,7 @@ export default Route.extend({
|
||||
const backendModel = this.store.peekRecord('secret-engine', backend);
|
||||
const has404 = this.has404;
|
||||
// only clear store cache if this is a new model
|
||||
if (secret !== controller.get('baseKey.id')) {
|
||||
if (secret !== controller?.baseKey?.id) {
|
||||
this.store.clearAllDatasets();
|
||||
}
|
||||
controller.set('hasModel', true);
|
||||
@@ -156,7 +156,7 @@ export default Route.extend({
|
||||
backend,
|
||||
backendModel,
|
||||
baseKey: { id: secret },
|
||||
backendType: backendModel.get('engineType'),
|
||||
backendType: backendModel.engineType,
|
||||
});
|
||||
if (!has404) {
|
||||
const pageFilter = secretParams.pageFilter;
|
||||
@@ -187,7 +187,7 @@ export default Route.extend({
|
||||
const backend = this.enginePathParam();
|
||||
const is404 = error.httpStatus === 404;
|
||||
/* eslint-disable-next-line ember/no-controller-access-in-routes */
|
||||
const hasModel = this.controllerFor(this.routeName).get('hasModel');
|
||||
const hasModel = this.controllerFor(this.routeName).hasModel;
|
||||
|
||||
// this will occur if we've deleted something,
|
||||
// and navigate to its parent and the parent doesn't exist -
|
||||
|
||||
@@ -68,7 +68,7 @@ export default Route.extend({
|
||||
},
|
||||
|
||||
backendType() {
|
||||
return this.modelFor('vault.cluster.secrets.backend').get('engineType');
|
||||
return this.modelFor('vault.cluster.secrets.backend').engineType;
|
||||
},
|
||||
|
||||
templateName: 'vault/cluster/secrets/backend/secretEditLayout',
|
||||
@@ -116,7 +116,7 @@ export default Route.extend({
|
||||
|
||||
modelType(backend, secret, options = {}) {
|
||||
const backendModel = this.modelFor('vault.cluster.secrets.backend', backend);
|
||||
const type = backendModel.get('engineType');
|
||||
const { engineType } = backendModel;
|
||||
const types = {
|
||||
database: secret && secret.startsWith('role/') ? 'database/role' : 'database/connection',
|
||||
transit: 'transit-key',
|
||||
@@ -128,12 +128,12 @@ export default Route.extend({
|
||||
keymgmt: `keymgmt/${options.queryParams?.itemType || 'key'}`,
|
||||
generic: 'secret',
|
||||
};
|
||||
return types[type];
|
||||
return types[engineType];
|
||||
},
|
||||
|
||||
handleSecretModelError(capabilities, secretId, modelType, error) {
|
||||
// can't read the path and don't have update capability, so re-throw
|
||||
if (!capabilities.get('canUpdate') && modelType === 'secret') {
|
||||
if (!capabilities.canUpdate && modelType === 'secret') {
|
||||
throw error;
|
||||
}
|
||||
this.store.push({
|
||||
@@ -192,7 +192,7 @@ export default Route.extend({
|
||||
const backend = this.enginePathParam();
|
||||
const preferAdvancedEdit =
|
||||
/* eslint-disable-next-line ember/no-controller-access-in-routes */
|
||||
this.controllerFor('vault.cluster.secrets.backend').get('preferAdvancedEdit') || false;
|
||||
this.controllerFor('vault.cluster.secrets.backend').preferAdvancedEdit || false;
|
||||
const backendType = this.backendType();
|
||||
model.secret.setProperties({ backend });
|
||||
controller.setProperties({
|
||||
|
||||
@@ -29,13 +29,13 @@ export default Route.extend(UnloadModel, {
|
||||
model(params) {
|
||||
const role = params.secret;
|
||||
const backendModel = this.backendModel();
|
||||
const backend = backendModel.get('id');
|
||||
const backend = backendModel.id;
|
||||
|
||||
if (backendModel.get('type') !== 'ssh') {
|
||||
if (backendModel.type !== 'ssh') {
|
||||
return this.router.transitionTo('vault.cluster.secrets.backend.list-root', backend);
|
||||
}
|
||||
return this.store.queryRecord('capabilities', this.pathQuery(role, backend)).then((capabilities) => {
|
||||
if (!capabilities.get('canUpdate')) {
|
||||
if (!capabilities.canUpdate) {
|
||||
return this.router.transitionTo('vault.cluster.secrets.backend.list-root', backend);
|
||||
}
|
||||
return this.store.createRecord('ssh-sign', {
|
||||
|
||||
@@ -53,7 +53,7 @@ export default Route.extend(UnloadModelRoute, {
|
||||
section,
|
||||
});
|
||||
}
|
||||
const modelType = this.modelType(backend.get('type'), section);
|
||||
const modelType = this.modelType(backend.type, section);
|
||||
if (!modelType) {
|
||||
const error = new AdapterError();
|
||||
set(error, 'httpStatus', 404);
|
||||
|
||||
@@ -16,7 +16,7 @@ export default Route.extend({
|
||||
const { backend } = this.paramsFor(this.routeName);
|
||||
return this.store.query('secret-engine', { path: backend }).then((modelList) => {
|
||||
const model = modelList && modelList[0];
|
||||
if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.get('type'))) {
|
||||
if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.type)) {
|
||||
const error = new AdapterError();
|
||||
set(error, 'httpStatus', 404);
|
||||
throw error;
|
||||
@@ -33,7 +33,7 @@ export default Route.extend({
|
||||
},
|
||||
|
||||
afterModel(model) {
|
||||
const type = model.get('type');
|
||||
const type = model.type;
|
||||
|
||||
if (type === 'aws') {
|
||||
return this.store
|
||||
@@ -50,7 +50,7 @@ export default Route.extend({
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
if (model.get('publicKey')) {
|
||||
if (model.publicKey) {
|
||||
controller.set('configured', true);
|
||||
}
|
||||
return this._super(...arguments);
|
||||
|
||||
@@ -66,10 +66,7 @@ export default RESTSerializer.extend({
|
||||
|
||||
serializeAttribute(snapshot, json, key, attributes) {
|
||||
// Don't send values that are undefined
|
||||
if (
|
||||
undefined !== snapshot.attr(key) &&
|
||||
(snapshot.record.get('isNew') || snapshot.changedAttributes()[key])
|
||||
) {
|
||||
if (snapshot.attr(key) !== undefined && (snapshot.record.isNew || snapshot.changedAttributes()[key])) {
|
||||
this._super(snapshot, json, key, attributes);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -78,7 +78,7 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
||||
},
|
||||
|
||||
serialize(snapshot) {
|
||||
const type = snapshot.record.get('engineType');
|
||||
const type = snapshot.record.engineType;
|
||||
const data = this._super(...arguments);
|
||||
// move version back to options
|
||||
data.options = data.version ? { version: data.version } : {};
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</ToolbarActions>
|
||||
</Toolbar>
|
||||
|
||||
{{#each (sort-by "path" this.authMethodList) as |method|}}
|
||||
{{#each (this.sortMethods this.authMethodList) as |method|}}
|
||||
<LinkedBlock
|
||||
@params={{array "vault.cluster.access.method" method.id}}
|
||||
class="list-item-row"
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
/*
|
||||
this util sorts the original array
|
||||
pass in a copy of the array, i.e. myArray.slice(), if you do not want to modify the original array
|
||||
*/
|
||||
export default function sortObjects(array, key) {
|
||||
if (Array.isArray(array) && array?.every((e) => e[key] && typeof e[key] === 'string')) {
|
||||
return array.sort((a, b) => {
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class MessagesList extends Component {
|
||||
super.willDestroy();
|
||||
const noTeardown = this.store && !this.store.isDestroying;
|
||||
const { model } = this;
|
||||
if (noTeardown && model && model.get('isDirty') && !model.isDestroyed && !model.isDestroying) {
|
||||
if (noTeardown && model && model.isDirty && !model.isDestroyed && !model.isDestroying) {
|
||||
model.rollbackAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export default Component.extend({
|
||||
return;
|
||||
}
|
||||
if (this.flashEnabled) {
|
||||
this.flashMessages.success(this.get(messageKey));
|
||||
this.flashMessages.success(this[messageKey]);
|
||||
}
|
||||
if (this.callOnSaveAfterRender) {
|
||||
next(() => {
|
||||
@@ -87,7 +87,7 @@ export default Component.extend({
|
||||
// components are torn down after store is unloaded and will cause an error if attempt to unload record
|
||||
const noTeardown = this.store && !this.store.isDestroying;
|
||||
const { model } = this;
|
||||
if (noTeardown && model && model.get('isDirty') && !model.isDestroyed && !model.isDestroying) {
|
||||
if (noTeardown && model && model.isDirty && !model.isDestroyed && !model.isDestroying) {
|
||||
model.rollbackAttributes();
|
||||
}
|
||||
this._super(...arguments);
|
||||
|
||||
@@ -50,7 +50,7 @@ export default class KvObjectEditor extends Component {
|
||||
};
|
||||
}
|
||||
get hasDuplicateKeys() {
|
||||
return this.kvData.uniqBy('name').length !== this.kvData.get('length');
|
||||
return this.kvData.uniqBy('name').length !== this.kvData.length;
|
||||
}
|
||||
|
||||
// fired on did-insert from render modifier
|
||||
|
||||
@@ -106,9 +106,9 @@ export default class StringList extends Component {
|
||||
|
||||
@action
|
||||
addInput() {
|
||||
const inputList = this.inputList;
|
||||
if (inputList.get('lastObject.value') !== '') {
|
||||
inputList.pushObject({ value: '' });
|
||||
const [lastItem] = this.inputList.slice(-1);
|
||||
if (lastItem?.value !== '') {
|
||||
this.inputList.pushObject({ value: '' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ export default Helper.extend({
|
||||
|
||||
compute([routeName, model], { isExact }) {
|
||||
const router = this.router;
|
||||
const currentRoute = router.get('currentRouteName');
|
||||
let currentURL = router.get('currentURL');
|
||||
const currentRoute = router.currentRouteName;
|
||||
let currentURL = router.currentURL;
|
||||
// if we have any query params we want to discard them
|
||||
currentURL = currentURL?.split('?')[0];
|
||||
const comparator = isExact ? exact : startsWith;
|
||||
|
||||
@@ -9,7 +9,7 @@ export function pathOrArray([maybeArray, target]) {
|
||||
if (Array.isArray(maybeArray)) {
|
||||
return maybeArray;
|
||||
}
|
||||
return target.get(maybeArray);
|
||||
return target[maybeArray];
|
||||
}
|
||||
|
||||
export default buildHelper(pathOrArray);
|
||||
|
||||
@@ -30,7 +30,7 @@ export default Component.extend({
|
||||
if (model.operationNone) {
|
||||
return falseString;
|
||||
}
|
||||
return model.get(field.name) ? trueString : falseString;
|
||||
return model[field.name] ? trueString : falseString;
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
@@ -29,13 +29,13 @@ export default class SwaggerUiComponent extends Component {
|
||||
return (
|
||||
taggedOps
|
||||
.map((tagObj) => {
|
||||
const operations = tagObj.get('operations').filter((operationObj) => {
|
||||
return operationObj.get('path').includes(phrase);
|
||||
const operations = tagObj.operations.filter((operationObj) => {
|
||||
return operationObj.path.includes(phrase);
|
||||
});
|
||||
return tagObj.set('operations', operations);
|
||||
})
|
||||
// then traverse again and remove the top level item if there are no operations left after filtering
|
||||
.filter((tagObj) => !!tagObj.get('operations').size)
|
||||
.filter((tagObj) => !!tagObj.operations.size)
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ export default Controller.extend({
|
||||
replicationMode: alias('rm.mode'),
|
||||
actions: {
|
||||
resetConfig(config) {
|
||||
if (config.get('isNew')) {
|
||||
if (config.isNew) {
|
||||
config.setProperties({
|
||||
mode: null,
|
||||
paths: [],
|
||||
|
||||
@@ -33,10 +33,10 @@ export default Route.extend(ClusterRoute, {
|
||||
return hash({
|
||||
canEnablePrimary: this.store
|
||||
.findRecord('capabilities', 'sys/replication/primary/enable')
|
||||
.then((c) => c.get('canUpdate')),
|
||||
.then((c) => c.canUpdate),
|
||||
canEnableSecondary: this.store
|
||||
.findRecord('capabilities', 'sys/replication/secondary/enable')
|
||||
.then((c) => c.get('canUpdate')),
|
||||
.then((c) => c.canUpdate),
|
||||
}).then(({ canEnablePrimary, canEnableSecondary }) => {
|
||||
setProperties(model, {
|
||||
canEnablePrimary,
|
||||
|
||||
@@ -18,10 +18,10 @@ export default Route.extend({
|
||||
cluster: this.modelFor('mode'),
|
||||
canAddSecondary: this.store
|
||||
.findRecord('capabilities', `sys/replication/${replicationMode}/primary/secondary-token`)
|
||||
.then((c) => c.get('canUpdate')),
|
||||
.then((c) => c.canUpdate),
|
||||
canRevokeSecondary: this.store
|
||||
.findRecord('capabilities', `sys/replication/${replicationMode}/primary/revoke-secondary`)
|
||||
.then((c) => c.get('canUpdate')),
|
||||
.then((c) => c.canUpdate),
|
||||
}).then(({ cluster, canAddSecondary, canRevokeSecondary }) => {
|
||||
setProperties(cluster, {
|
||||
canRevokeSecondary,
|
||||
|
||||
@@ -27,12 +27,12 @@ export default Route.extend({
|
||||
const model = this.modelFor('mode');
|
||||
|
||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||
const clusterMode = model.get(replicationMode).get('modeForUrl');
|
||||
const clusterMode = model[replicationMode].modeForUrl;
|
||||
const actions = replicationActionForMode([replicationMode, clusterMode]);
|
||||
return all(
|
||||
actions.map((action) => {
|
||||
return store.findRecord('capabilities', pathForAction(action)).then((capability) => {
|
||||
model.set(`can${camelize(action)}`, capability.get('canUpdate'));
|
||||
model.set(`can${camelize(action)}`, capability.canUpdate);
|
||||
});
|
||||
})
|
||||
).then(() => {
|
||||
@@ -43,10 +43,8 @@ export default Route.extend({
|
||||
beforeModel() {
|
||||
const model = this.modelFor('mode');
|
||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||
if (
|
||||
model.get(replicationMode).get('replicationDisabled') ||
|
||||
model.get(replicationMode).get('replicationUnsupported')
|
||||
) {
|
||||
const modeModel = model[replicationMode];
|
||||
if (modeModel.replicationDisabled || modeModel.replicationUnsupported) {
|
||||
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -18,10 +18,10 @@ export default Route.extend({
|
||||
cluster: this.modelFor('mode'),
|
||||
canAddSecondary: this.store
|
||||
.findRecord('capabilities', `sys/replication/${replicationMode}/primary/secondary-token`)
|
||||
.then((c) => c.get('canUpdate')),
|
||||
.then((c) => c.canUpdate),
|
||||
canRevokeSecondary: this.store
|
||||
.findRecord('capabilities', `sys/replication/${replicationMode}/primary/revoke-secondary`)
|
||||
.then((c) => c.get('canUpdate')),
|
||||
.then((c) => c.canUpdate),
|
||||
}).then(({ cluster, canAddSecondary, canRevokeSecondary }) => {
|
||||
setProperties(cluster, {
|
||||
canRevokeSecondary,
|
||||
@@ -32,11 +32,8 @@ export default Route.extend({
|
||||
},
|
||||
afterModel(model) {
|
||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||
if (
|
||||
!model.get(`${replicationMode}.isPrimary`) ||
|
||||
model.get(`${replicationMode}.replicationDisabled`) ||
|
||||
model.get(`${replicationMode}.replicationUnsupported`)
|
||||
) {
|
||||
const modeModel = model[replicationMode];
|
||||
if (!modeModel.isPrimary || modeModel.replicationDisabled || modeModel.replicationUnsupported) {
|
||||
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ export default Base.extend({
|
||||
|
||||
redirect(model) {
|
||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||
if (!model.get(`${replicationMode}.isPrimary`) || !model.get('canAddSecondary')) {
|
||||
if (!model[replicationMode].isPrimary || !model.canAddSecondary) {
|
||||
return this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -46,8 +46,8 @@ export default Base.extend({
|
||||
if (
|
||||
!this.version.hasPerfReplication ||
|
||||
replicationMode !== 'performance' ||
|
||||
!cluster.get(`${replicationMode}.isPrimary`) ||
|
||||
!cluster.get('canAddSecondary')
|
||||
!cluster[replicationMode].isPrimary ||
|
||||
!cluster.canAddSecondary
|
||||
) {
|
||||
return this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ export default Base.extend({
|
||||
if (
|
||||
!this.version.hasPerfReplication ||
|
||||
replicationMode !== 'performance' ||
|
||||
!cluster.get(`${replicationMode}.isPrimary`) ||
|
||||
!cluster.get('canAddSecondary')
|
||||
!cluster[replicationMode].isPrimary ||
|
||||
!cluster.canAddSecondary
|
||||
) {
|
||||
return this.transitionTo('mode', replicationMode);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ export default Base.extend({
|
||||
if (
|
||||
!this.version.hasPerfReplication ||
|
||||
replicationMode !== 'performance' ||
|
||||
!cluster.get(`${replicationMode}.isPrimary`)
|
||||
!cluster[replicationMode].isPrimary
|
||||
) {
|
||||
return this.transitionTo('mode', cluster.get('name'), replicationMode);
|
||||
return this.transitionTo('mode', cluster.name, replicationMode);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ export default Base.extend({
|
||||
|
||||
redirect(model) {
|
||||
const replicationMode = this.replicationMode;
|
||||
if (!model.get(`${replicationMode}.isPrimary`) || !model.get('canRevokeSecondary')) {
|
||||
if (!model[replicationMode].isPrimary || !model.canRevokeSecondary) {
|
||||
return this.transitionTo('index');
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user