mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
UI: Ember 5 deprecations: filterBy, mapBy, auto location (#25546)
* Replace all mapBy * Replace findBys * Remove auto location https://deprecations.emberjs.com/v4.x/\#toc_deprecate-auto-location * fixes Co-authored-by: Kianna <30884335+kiannaquach@users.noreply.github.com>
This commit is contained in:
@@ -132,7 +132,11 @@ export default ApplicationAdapter.extend({
|
|||||||
|
|
||||||
saveZeroAddressConfig(store, type, snapshot) {
|
saveZeroAddressConfig(store, type, snapshot) {
|
||||||
const path = encodePath(snapshot.id);
|
const path = encodePath(snapshot.id);
|
||||||
const roles = store.peekAll('role-ssh').filterBy('zeroAddress').mapBy('id').join(',');
|
const roles = store
|
||||||
|
.peekAll('role-ssh')
|
||||||
|
.filter((role) => role.zeroAddress)
|
||||||
|
.map((role) => role.id)
|
||||||
|
.join(',');
|
||||||
const url = `/v1/${path}/config/zeroaddress`;
|
const url = `/v1/${path}/config/zeroaddress`;
|
||||||
const data = { roles };
|
const data = { roles };
|
||||||
if (roles === '') {
|
if (roles === '') {
|
||||||
|
|||||||
@@ -139,9 +139,9 @@ export default Component.extend(DEFAULTS, {
|
|||||||
}
|
}
|
||||||
// if type is provided we can ignore path since we are attempting to lookup a specific backend by type
|
// if type is provided we can ignore path since we are attempting to lookup a specific backend by type
|
||||||
if (keyIsPath && !type) {
|
if (keyIsPath && !type) {
|
||||||
return methods.findBy('path', selected);
|
return methods.find((m) => m.path === selected);
|
||||||
}
|
}
|
||||||
return this.authMethods.findBy('type', selected);
|
return this.authMethods.find((m) => m.type === selected);
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedAuthIsPath: match('selectedAuth', /\/$/),
|
selectedAuthIsPath: match('selectedAuth', /\/$/),
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
currentUserHasAuthorized: computed('currentUserEntityId', 'model.authorizations.@each.id', function () {
|
currentUserHasAuthorized: computed('currentUserEntityId', 'model.authorizations.@each.id', function () {
|
||||||
const authorizations = this.model.authorizations || [];
|
const authorizations = this.model.authorizations || [];
|
||||||
return Boolean(authorizations.findBy('id', this.currentUserEntityId));
|
return Boolean(authorizations.find((authz) => authz.id === this.currentUserEntityId));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
isSuccess: or('currentUserHasAuthorized', 'model.approved'),
|
isSuccess: or('currentUserHasAuthorized', 'model.approved'),
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default class MfaForm extends Component {
|
|||||||
super(...arguments);
|
super(...arguments);
|
||||||
// trigger validation immediately when passcode is not required
|
// trigger validation immediately when passcode is not required
|
||||||
const passcodeOrSelect = this.constraints.filter((constraint) => {
|
const passcodeOrSelect = this.constraints.filter((constraint) => {
|
||||||
return constraint.methods.length > 1 || constraint.methods.findBy('uses_passcode');
|
return constraint.methods.length > 1 || constraint.methods.find((m) => m.uses_passcode);
|
||||||
});
|
});
|
||||||
if (!passcodeOrSelect.length) {
|
if (!passcodeOrSelect.length) {
|
||||||
this.validate.perform();
|
this.validate.perform();
|
||||||
@@ -112,7 +112,11 @@ export default class MfaForm extends Component {
|
|||||||
|
|
||||||
@action onSelect(constraint, id) {
|
@action onSelect(constraint, id) {
|
||||||
set(constraint, 'selectedId', id);
|
set(constraint, 'selectedId', id);
|
||||||
set(constraint, 'selectedMethod', constraint.methods.findBy('id', id));
|
set(
|
||||||
|
constraint,
|
||||||
|
'selectedMethod',
|
||||||
|
constraint.methods.find((m) => m.id === id)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@action submit(e) {
|
@action submit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ export default class MfaLoginEnforcementForm extends Component {
|
|||||||
}
|
}
|
||||||
async fetchAuthMethods() {
|
async fetchAuthMethods() {
|
||||||
const mounts = (await this.store.findAll('auth-method')).toArray();
|
const mounts = (await this.store.findAll('auth-method')).toArray();
|
||||||
this.authMethods = mounts.mapBy('type');
|
this.authMethods = mounts.map((auth) => auth.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
get selectedTarget() {
|
get selectedTarget() {
|
||||||
return this.targetTypes.findBy('type', this.selectedTargetType);
|
return this.targetTypes.find((tt) => tt.type === this.selectedTargetType);
|
||||||
}
|
}
|
||||||
get errors() {
|
get errors() {
|
||||||
return this.args.modelErrors || this.modelErrors;
|
return this.args.modelErrors || this.modelErrors;
|
||||||
|
|||||||
@@ -52,6 +52,6 @@ export default class MfaLoginEnforcementHeaderComponent extends Component {
|
|||||||
onEnforcementSelect([name]) {
|
onEnforcementSelect([name]) {
|
||||||
// search select returns array of strings, in this case enforcement name
|
// search select returns array of strings, in this case enforcement name
|
||||||
// lookup model and pass to callback
|
// lookup model and pass to callback
|
||||||
this.args.onEnforcementSelect(this._enforcements.findBy('name', name));
|
this.args.onEnforcementSelect(this._enforcements.find((enf) => enf.name === name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default class OidcProviderForm extends Component {
|
|||||||
// function passed to search select
|
// function passed to search select
|
||||||
renderInfoTooltip(selection, dropdownOptions) {
|
renderInfoTooltip(selection, dropdownOptions) {
|
||||||
// if a client has been deleted it will not exist in dropdownOptions (response from search select's query)
|
// if a client has been deleted it will not exist in dropdownOptions (response from search select's query)
|
||||||
const clientExists = !!dropdownOptions.findBy('clientId', selection);
|
const clientExists = !!dropdownOptions.find((opt) => opt.clientId === selection);
|
||||||
return !clientExists ? 'The application associated with this client_id no longer exists' : false;
|
return !clientExists ? 'The application associated with this client_id no longer exists' : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export default class SecretCreateOrUpdate extends Component {
|
|||||||
addRow() {
|
addRow() {
|
||||||
const data = this.args.secretData;
|
const data = this.args.secretData;
|
||||||
// fired off on init
|
// fired off on init
|
||||||
if (isNone(data.findBy('name', ''))) {
|
if (isNone(data.find((d) => d.name === ''))) {
|
||||||
data.pushObject({ name: '', value: '' });
|
data.pushObject({ name: '', value: '' });
|
||||||
this.handleChange();
|
this.handleChange();
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ export default class SecretCreateOrUpdate extends Component {
|
|||||||
@action
|
@action
|
||||||
deleteRow(name) {
|
deleteRow(name) {
|
||||||
const data = this.args.secretData;
|
const data = this.args.secretData;
|
||||||
const item = data.findBy('name', name);
|
const item = data.find((d) => d.name === name);
|
||||||
if (isBlank(item.name)) {
|
if (isBlank(item.name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default Component.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.showReplication === false) {
|
if (this.showReplication === false) {
|
||||||
const feature = this.allFeatures.findBy('key', 'replication');
|
const feature = this.allFeatures.find((f) => f.key === 'replication');
|
||||||
feature.show = false;
|
feature.show = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -134,7 +134,7 @@ export default Component.extend({
|
|||||||
showReplication: or('version.hasPerfReplication', 'version.hasDRReplication'),
|
showReplication: or('version.hasPerfReplication', 'version.hasDRReplication'),
|
||||||
|
|
||||||
selectedFeatures: computed('allFeatures.@each.selected', function () {
|
selectedFeatures: computed('allFeatures.@each.selected', function () {
|
||||||
return this.allFeatures.filterBy('selected').mapBy('key');
|
return this.allFeatures.filter((feature) => feature.selected).map((feature) => feature.key);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
cannotStartWizard: not('selectedFeatures.length'),
|
cannotStartWizard: not('selectedFeatures.length'),
|
||||||
|
|||||||
2
ui/app/config/environment.d.ts
vendored
2
ui/app/config/environment.d.ts
vendored
@@ -11,7 +11,7 @@ declare const config: {
|
|||||||
environment: string;
|
environment: string;
|
||||||
modulePrefix: string;
|
modulePrefix: string;
|
||||||
podModulePrefix: string;
|
podModulePrefix: string;
|
||||||
locationType: 'history' | 'hash' | 'none' | 'auto';
|
locationType: 'history' | 'hash' | 'none';
|
||||||
rootURL: string;
|
rootURL: string;
|
||||||
APP: Record<string, unknown>;
|
APP: Record<string, unknown>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default Controller.extend({
|
|||||||
filterMatchesKey: computed('filter', 'model', 'model.[]', function () {
|
filterMatchesKey: computed('filter', 'model', 'model.[]', function () {
|
||||||
var filter = this.filter;
|
var filter = this.filter;
|
||||||
var content = this.model;
|
var content = this.model;
|
||||||
return !!(content && content.length && content.findBy('id', filter));
|
return !!(content && content.length && content.find((c) => c.id === filter));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function () {
|
firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function () {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default class MountSecretBackendController extends Controller {
|
|||||||
onMountSuccess(type, path, useEngineRoute = false) {
|
onMountSuccess(type, path, useEngineRoute = false) {
|
||||||
let transition;
|
let transition;
|
||||||
if (SUPPORTED_BACKENDS.includes(type)) {
|
if (SUPPORTED_BACKENDS.includes(type)) {
|
||||||
const engineInfo = allEngines().findBy('type', type);
|
const engineInfo = allEngines().find((engine) => engine.type === type);
|
||||||
if (useEngineRoute) {
|
if (useEngineRoute) {
|
||||||
transition = this.router.transitionTo(
|
transition = this.router.transitionTo(
|
||||||
`vault.cluster.secrets.backend.${engineInfo.engineRoute}`,
|
`vault.cluster.secrets.backend.${engineInfo.engineRoute}`,
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ export function allEngines() {
|
|||||||
|
|
||||||
export function isAddonEngine(type, version) {
|
export function isAddonEngine(type, version) {
|
||||||
if (type === 'kv' && version === 1) return false;
|
if (type === 'kv' && version === 1) return false;
|
||||||
const engineRoute = allEngines().findBy('type', type)?.engineRoute;
|
const engineRoute = allEngines().find((engine) => engine.type === type)?.engineRoute;
|
||||||
return !!engineRoute;
|
return !!engineRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export default class MfaLoginEnforcementModel extends Model {
|
|||||||
|
|
||||||
iconForMount(type) {
|
iconForMount(type) {
|
||||||
const mountableMethods = methods();
|
const mountableMethods = methods();
|
||||||
const mount = mountableMethods.findBy('type', type);
|
const mount = mountableMethods.find((method) => method.type === type);
|
||||||
return mount ? mount.glyph || mount.type : 'token';
|
return mount ? mount.glyph || mount.type : 'token';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export default class SecretEngineModel extends Model {
|
|||||||
return 'vault.cluster.secrets.backend.overview';
|
return 'vault.cluster.secrets.backend.overview';
|
||||||
}
|
}
|
||||||
if (isAddonEngine(this.engineType, this.version)) {
|
if (isAddonEngine(this.engineType, this.version)) {
|
||||||
const { engineRoute } = allEngines().findBy('type', this.engineType);
|
const { engineRoute } = allEngines().find((engine) => engine.type === this.engineType);
|
||||||
return `vault.cluster.secrets.backend.${engineRoute}`;
|
return `vault.cluster.secrets.backend.${engineRoute}`;
|
||||||
}
|
}
|
||||||
return `vault.cluster.secrets.backend.list-root`;
|
return `vault.cluster.secrets.backend.list-root`;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default Route.extend({
|
|||||||
model(params) {
|
model(params) {
|
||||||
const { path } = params;
|
const { path } = params;
|
||||||
return this.store.findAll('auth-method').then((modelArray) => {
|
return this.store.findAll('auth-method').then((modelArray) => {
|
||||||
const model = modelArray.findBy('id', path);
|
const model = modelArray.find((m) => m.id === path);
|
||||||
if (!model) {
|
if (!model) {
|
||||||
const error = new AdapterError();
|
const error = new AdapterError();
|
||||||
set(error, 'httpStatus', 404);
|
set(error, 'httpStatus', 404);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default Route.extend({
|
|||||||
const secretEngine = this.store.peekRecord('secret-engine', backend);
|
const secretEngine = this.store.peekRecord('secret-engine', backend);
|
||||||
const type = secretEngine?.engineType;
|
const type = secretEngine?.engineType;
|
||||||
assert('secretEngine.engineType is not defined', !!type);
|
assert('secretEngine.engineType is not defined', !!type);
|
||||||
const engineRoute = allEngines().findBy('type', type)?.engineRoute;
|
const engineRoute = allEngines().find((engine) => engine.type === type)?.engineRoute;
|
||||||
|
|
||||||
if (!type || !SUPPORTED_BACKENDS.includes(type)) {
|
if (!type || !SUPPORTED_BACKENDS.includes(type)) {
|
||||||
return this.router.transitionTo('vault.cluster.secrets');
|
return this.router.transitionTo('vault.cluster.secrets');
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export default Service.extend({
|
|||||||
backend: {
|
backend: {
|
||||||
// add mount path for password reset
|
// add mount path for password reset
|
||||||
mountPath: stored.backend.mountPath,
|
mountPath: stored.backend.mountPath,
|
||||||
...BACKENDS.findBy('type', backend),
|
...BACKENDS.find((b) => b.type === backend),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
@@ -267,7 +267,7 @@ export default Service.extend({
|
|||||||
|
|
||||||
const currentBackend = {
|
const currentBackend = {
|
||||||
mountPath,
|
mountPath,
|
||||||
...BACKENDS.findBy('type', backend),
|
...BACKENDS.find((b) => b.type === backend),
|
||||||
};
|
};
|
||||||
let displayName;
|
let displayName;
|
||||||
if (isArray(currentBackend.displayNamePath)) {
|
if (isArray(currentBackend.displayNamePath)) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export const expandAttributeMeta = function (modelClass, attributeNames) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// lookup attr and return meta
|
// lookup attr and return meta
|
||||||
return modelAttrs[klass.modelName].findBy('name', attrKey);
|
return modelAttrs[klass.modelName].find((attr) => attr.name === attrKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
return fields.map((field) => {
|
return fields.map((field) => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import Component from '@glimmer/component';
|
import Component from '@glimmer/component';
|
||||||
import { assert } from '@ember/debug';
|
import { assert } from '@ember/debug';
|
||||||
import flightIconMap from '@hashicorp/flight-icons/catalog.json';
|
import flightIconMap from '@hashicorp/flight-icons/catalog.json';
|
||||||
const flightIconNames = flightIconMap.assets.mapBy('iconName').uniq();
|
const flightIconNames = flightIconMap.assets.map((asset) => asset.iconName).uniq();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module Icon
|
* @module Icon
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export default class InfoTableItemArray extends Component {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.allOptions = modelRecords ? modelRecords.mapBy('id') : null;
|
this.allOptions = modelRecords ? modelRecords.map((record) => record.id) : null;
|
||||||
if (this.args.renderItemName && modelRecords) {
|
if (this.args.renderItemName && modelRecords) {
|
||||||
modelRecords.forEach(({ id, name }) => {
|
modelRecords.forEach(({ id, name }) => {
|
||||||
// create key/value pair { item-id: item-name } for each record
|
// create key/value pair { item-id: item-name } for each record
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default class KvObjectEditor extends Component {
|
|||||||
}
|
}
|
||||||
@action
|
@action
|
||||||
addRow() {
|
addRow() {
|
||||||
if (!isNone(this.kvData.findBy('name', ''))) {
|
if (!isNone(this.kvData.find((datum) => datum.name === ''))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newObj = { name: '', value: '' };
|
const newObj = { name: '', value: '' };
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default class SearchSelectWithModal extends Component {
|
|||||||
// inputValues are initially an array of strings from @inputValue
|
// inputValues are initially an array of strings from @inputValue
|
||||||
// map over so selectedOptions are objects
|
// map over so selectedOptions are objects
|
||||||
return inputValues.map((option) => {
|
return inputValues.map((option) => {
|
||||||
const matchingOption = this.dropdownOptions.findBy('id', option);
|
const matchingOption = this.dropdownOptions.find((opt) => opt.id === option);
|
||||||
// remove any matches from dropdown list
|
// remove any matches from dropdown list
|
||||||
this.dropdownOptions.removeObject(matchingOption);
|
this.dropdownOptions.removeObject(matchingOption);
|
||||||
return {
|
return {
|
||||||
@@ -140,11 +140,10 @@ export default class SearchSelectWithModal extends Component {
|
|||||||
|
|
||||||
shouldShowCreate(id, searchResults) {
|
shouldShowCreate(id, searchResults) {
|
||||||
if (searchResults && searchResults.length && searchResults.firstObject.groupName) {
|
if (searchResults && searchResults.length && searchResults.firstObject.groupName) {
|
||||||
return !searchResults.some((group) => group.options.findBy('id', id));
|
return !searchResults.some((group) => group.options.find((opt) => opt.id === id));
|
||||||
}
|
}
|
||||||
const existingOption =
|
const existingOption =
|
||||||
this.dropdownOptions &&
|
this.dropdownOptions && this.dropdownOptions.find((opt) => opt.id === id || opt.name === id);
|
||||||
(this.dropdownOptions.findBy('id', id) || this.dropdownOptions.findBy('name', id));
|
|
||||||
return !existingOption;
|
return !existingOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default class SearchSelect extends Component {
|
|||||||
// inputValues are initially an array of strings from @inputValue
|
// inputValues are initially an array of strings from @inputValue
|
||||||
// map over so selectedOptions are objects
|
// map over so selectedOptions are objects
|
||||||
return inputValues.map((option) => {
|
return inputValues.map((option) => {
|
||||||
const matchingOption = this.dropdownOptions.findBy(this.idKey, option);
|
const matchingOption = this.dropdownOptions.find((opt) => opt[this.idKey] === option);
|
||||||
// tooltip text comes from return of parent function
|
// tooltip text comes from return of parent function
|
||||||
const addTooltip = this.args.renderInfoTooltip
|
const addTooltip = this.args.renderInfoTooltip
|
||||||
? this.args.renderInfoTooltip(option, this.dropdownOptions)
|
? this.args.renderInfoTooltip(option, this.dropdownOptions)
|
||||||
@@ -170,7 +170,7 @@ export default class SearchSelect extends Component {
|
|||||||
const options = yield this.store.query(modelType, queryParams);
|
const options = yield this.store.query(modelType, queryParams);
|
||||||
|
|
||||||
// store both select + unselected options in tracked property used by wildcard filter
|
// store both select + unselected options in tracked property used by wildcard filter
|
||||||
this.allOptions = [...this.allOptions, ...options.mapBy('id')];
|
this.allOptions = [...this.allOptions, ...options.map((option) => option.id)];
|
||||||
|
|
||||||
// add to dropdown options
|
// add to dropdown options
|
||||||
this.dropdownOptions = [...this.dropdownOptions, ...this.addSearchText(options)];
|
this.dropdownOptions = [...this.dropdownOptions, ...this.addSearchText(options)];
|
||||||
@@ -209,11 +209,10 @@ export default class SearchSelect extends Component {
|
|||||||
|
|
||||||
shouldShowCreate(id, searchResults) {
|
shouldShowCreate(id, searchResults) {
|
||||||
if (searchResults && searchResults.length && searchResults.firstObject.groupName) {
|
if (searchResults && searchResults.length && searchResults.firstObject.groupName) {
|
||||||
return !searchResults.some((group) => group.options.findBy('id', id));
|
return !searchResults.some((group) => group.options.find((opt) => opt.id === id));
|
||||||
}
|
}
|
||||||
const existingOption =
|
const existingOption =
|
||||||
this.dropdownOptions &&
|
this.dropdownOptions && this.dropdownOptions.find((opt) => opt.id === id || opt.name === id);
|
||||||
(this.dropdownOptions.findBy('id', id) || this.dropdownOptions.findBy('name', id));
|
|
||||||
if (this.args.disallowNewItems && !existingOption) {
|
if (this.args.disallowNewItems && !existingOption) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export default class StringList extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toVal() {
|
toVal() {
|
||||||
const inputs = this.inputList.filter((x) => x.value).mapBy('value');
|
const inputs = this.inputList.filter((x) => x.value).map((x) => x.value);
|
||||||
if (this.args.type === 'string') {
|
if (this.args.type === 'string') {
|
||||||
return inputs.join(',');
|
return inputs.join(',');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ export function optionsForBackend(backend, tab) {
|
|||||||
const selected = SECRET_BACKENDS[backend];
|
const selected = SECRET_BACKENDS[backend];
|
||||||
let backendOptions;
|
let backendOptions;
|
||||||
if (selected && selected.tabs) {
|
if (selected && selected.tabs) {
|
||||||
const tabData =
|
const tabData = selected.tabs.find((t) => t.name === tab || t.modelPrefix === tab) || selected.tabs[0];
|
||||||
selected.tabs.findBy('name', tab) || selected.tabs.findBy('modelPrefix', tab) || selected.tabs[0];
|
|
||||||
backendOptions = { ...selected, ...tabData };
|
backendOptions = { ...selected, ...tabData };
|
||||||
} else if (selected) {
|
} else if (selected) {
|
||||||
backendOptions = selected;
|
backendOptions = selected;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default Mixin.create({
|
|||||||
|
|
||||||
filterMatchesKey: computed('filter', 'model', 'model.[]', function () {
|
filterMatchesKey: computed('filter', 'model', 'model.[]', function () {
|
||||||
const { filter, model: content } = this;
|
const { filter, model: content } = this;
|
||||||
return !!(content.length && content.findBy('id', filter));
|
return !!(content.length && content.find((c) => c.id === filter));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function () {
|
firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function () {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default function handleHasManySelection(selectedIds, modelCollection, sto
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// now check for selected items that don't exist and add them to the model
|
// now check for selected items that don't exist and add them to the model
|
||||||
const modelIds = modelCollection.mapBy('id');
|
const modelIds = modelCollection.map((model) => model.id);
|
||||||
selectedIds.forEach((id) => {
|
selectedIds.forEach((id) => {
|
||||||
if (!modelIds.includes(id)) {
|
if (!modelIds.includes(id)) {
|
||||||
const model = store.peekRecord(modelRecord, id);
|
const model = store.peekRecord(modelRecord, id);
|
||||||
|
|||||||
@@ -99,11 +99,11 @@ export default class CreateAndEditRolePageComponent extends Component {
|
|||||||
this.selectedTemplateId = '1';
|
this.selectedTemplateId = '1';
|
||||||
|
|
||||||
if (generatedRoleRules) {
|
if (generatedRoleRules) {
|
||||||
const template = rulesTemplates.findBy('rules', generatedRoleRules);
|
const template = rulesTemplates.find((t) => t.rules === generatedRoleRules);
|
||||||
if (template) {
|
if (template) {
|
||||||
this.selectedTemplateId = template.id;
|
this.selectedTemplateId = template.id;
|
||||||
} else {
|
} else {
|
||||||
rulesTemplates.findBy('id', '1').rules = generatedRoleRules;
|
rulesTemplates.find((t) => t.id === '1').rules = generatedRoleRules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.roleRulesTemplates = rulesTemplates;
|
this.roleRulesTemplates = rulesTemplates;
|
||||||
@@ -134,7 +134,7 @@ export default class CreateAndEditRolePageComponent extends Component {
|
|||||||
*save() {
|
*save() {
|
||||||
try {
|
try {
|
||||||
// set generatedRoleRoles to value of selected template
|
// set generatedRoleRoles to value of selected template
|
||||||
const selectedTemplate = this.roleRulesTemplates?.findBy('id', this.selectedTemplateId);
|
const selectedTemplate = this.roleRulesTemplates?.find((t) => t.id === this.selectedTemplateId);
|
||||||
if (selectedTemplate) {
|
if (selectedTemplate) {
|
||||||
this.args.model.generatedRoleRules = selectedTemplate.rules;
|
this.args.model.generatedRoleRules = selectedTemplate.rules;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ export default class KvSecretPaths extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get commands() {
|
get commands() {
|
||||||
const cliPath = this.paths.findBy('label', 'CLI path').snippet;
|
const cliPath = this.paths.find((p) => p.label === 'CLI path').snippet;
|
||||||
const apiPath = this.paths.findBy('label', 'API path').snippet;
|
const apiPath = this.paths.find((p) => p.label === 'API path').snippet;
|
||||||
// as a future improvement, it might be nice to use window.location.protocol here:
|
// as a future improvement, it might be nice to use window.location.protocol here:
|
||||||
const url = `https://127.0.0.1:8200${apiPath}`;
|
const url = `https://127.0.0.1:8200${apiPath}`;
|
||||||
|
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ export default Component.extend({
|
|||||||
secretList = result.secret;
|
secretList = result.secret;
|
||||||
authList = result.auth;
|
authList = result.auth;
|
||||||
}
|
}
|
||||||
var currentSecrets = lastOptions && lastOptions.findBy('groupName', 'Secret Engines');
|
var currentSecrets = lastOptions && lastOptions.find((opt) => opt.groupName === 'Secret Engines');
|
||||||
var currentAuths = lastOptions && lastOptions.findBy('groupName', 'Auth Methods');
|
var currentAuths = lastOptions && lastOptions.find((opt) => opt.groupName === 'Auth Methods');
|
||||||
const formattedNamespaces = namespaces.map((val) => {
|
const formattedNamespaces = namespaces.map((val) => {
|
||||||
return {
|
return {
|
||||||
id: val,
|
id: val,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default function (server) {
|
|||||||
server.get('/:path/roles', (schema) => {
|
server.get('/:path/roles', (schema) => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
keys: schema.db.kubernetesRoles.where({}).mapBy('name'),
|
keys: schema.db.kubernetesRoles.where({}).map((role) => role.name),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -126,7 +126,11 @@ module('Acceptance | init', function (hooks) {
|
|||||||
'shows all of the recovery keys'
|
'shows all of the recovery keys'
|
||||||
);
|
);
|
||||||
assert.strictEqual(initPage.buttonText, 'Continue to Authenticate', 'links to authenticate');
|
assert.strictEqual(initPage.buttonText, 'Continue to Authenticate', 'links to authenticate');
|
||||||
assertRequest(this.server.handledRequests.findBy('url', '/v1/sys/init'), assert, true);
|
assertRequest(
|
||||||
|
this.server.handledRequests.find((req) => req.url === '/v1/sys/init'),
|
||||||
|
assert,
|
||||||
|
true
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shamir seal init', async function (assert) {
|
test('shamir seal init', async function (assert) {
|
||||||
@@ -139,6 +143,10 @@ module('Acceptance | init', function (hooks) {
|
|||||||
|
|
||||||
assert.strictEqual(initPage.keys.length, SEAL_RESPONSE.keys.length, 'shows all of the recovery keys');
|
assert.strictEqual(initPage.keys.length, SEAL_RESPONSE.keys.length, 'shows all of the recovery keys');
|
||||||
assert.strictEqual(initPage.buttonText, 'Continue to Unseal', 'links to unseal');
|
assert.strictEqual(initPage.buttonText, 'Continue to Unseal', 'links to unseal');
|
||||||
assertRequest(this.server.handledRequests.findBy('url', '/v1/sys/init'), assert, false);
|
assertRequest(
|
||||||
|
this.server.handledRequests.find((r) => r.url === '/v1/sys/init'),
|
||||||
|
assert,
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ module('Acceptance | mfa-method', function (hooks) {
|
|||||||
// ensure methods are tied to an enforcement
|
// ensure methods are tied to an enforcement
|
||||||
this.server.get('/identity/mfa/login-enforcement', () => {
|
this.server.get('/identity/mfa/login-enforcement', () => {
|
||||||
const record = this.server.create('mfa-login-enforcement', {
|
const record = this.server.create('mfa-login-enforcement', {
|
||||||
mfa_method_ids: this.getMethods().mapBy('id'),
|
mfa_method_ids: this.getMethods().map((m) => m.id),
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ module('Integration | Component | search select', function (hooks) {
|
|||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
const mockFunctionFromParent = (selection, dropdownOptions) => {
|
const mockFunctionFromParent = (selection, dropdownOptions) => {
|
||||||
const modelExists =
|
const modelExists =
|
||||||
!!dropdownOptions.findBy('id', selection) ||
|
!!dropdownOptions.find((opt) => opt.id === selection) ||
|
||||||
!!dropdownOptions.findBy('uuid', selection) ||
|
!!dropdownOptions.find((opt) => opt.uuid === selection) ||
|
||||||
isWildcardString([selection]);
|
isWildcardString([selection]);
|
||||||
return !modelExists ? 'The model associated with this id no longer exists' : false;
|
return !modelExists ? 'The model associated with this id no longer exists' : false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -134,7 +134,11 @@ module('Unit | Service | store', function (hooks) {
|
|||||||
let result;
|
let result;
|
||||||
result = await this.store.fetchPage('transit-key', query);
|
result = await this.store.fetchPage('transit-key', query);
|
||||||
assert.strictEqual(result.get('length'), pageSize, 'returns the correct number of items');
|
assert.strictEqual(result.get('length'), pageSize, 'returns the correct number of items');
|
||||||
assert.deepEqual(result.mapBy('id'), keys.slice(0, pageSize), 'returns the first page of items');
|
assert.deepEqual(
|
||||||
|
result.map((r) => r.id),
|
||||||
|
keys.slice(0, pageSize),
|
||||||
|
'returns the first page of items'
|
||||||
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
result.get('meta'),
|
result.get('meta'),
|
||||||
{
|
{
|
||||||
@@ -157,7 +161,7 @@ module('Unit | Service | store', function (hooks) {
|
|||||||
const pageThreeEnd = 3 * pageSize;
|
const pageThreeEnd = 3 * pageSize;
|
||||||
const pageThreeStart = pageThreeEnd - pageSize;
|
const pageThreeStart = pageThreeEnd - pageSize;
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
result.mapBy('id'),
|
result.map((r) => r.id),
|
||||||
keys.slice(pageThreeStart, pageThreeEnd),
|
keys.slice(pageThreeStart, pageThreeEnd),
|
||||||
'returns the third page of items'
|
'returns the third page of items'
|
||||||
);
|
);
|
||||||
@@ -169,7 +173,7 @@ module('Unit | Service | store', function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
result.mapBy('id'),
|
result.map((r) => r.id),
|
||||||
keys.slice(keys.length - 1),
|
keys.slice(keys.length - 1),
|
||||||
'returns the last page when the page value is beyond the of bounds'
|
'returns the last page when the page value is beyond the of bounds'
|
||||||
);
|
);
|
||||||
@@ -180,7 +184,7 @@ module('Unit | Service | store', function (hooks) {
|
|||||||
responsePath: 'data.keys',
|
responsePath: 'data.keys',
|
||||||
});
|
});
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
result.mapBy('id'),
|
result.map((r) => r.id),
|
||||||
keys.slice(0, pageSize),
|
keys.slice(0, pageSize),
|
||||||
'returns the first page when page value is under the bounds'
|
'returns the first page when page value is under the bounds'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user