mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 21:21:06 +02:00
* Add helper combineOpenApiAttrs + test * hydrateModel working with upgradeModelSchema * new registerNewModelWithAttrs method for generated models * Add newFields to generated models * copyright * Glimmerize path-help service * update generated-item-list adapter and path-help usage of it * remove unused methods combineAttributes and combineFields * move expandOpenApiProps to ts helper file * fix auth test * fix bug where adding user to second userpass mount saves to first mount * Add mutableId * fix ent test * remove addressed deprecation * Address PR comments * [VAULT-31208] remove deprecation early-static from decorator tests
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Model from '@ember-data/model';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
// This model is used for OpenApi-generated models in path-help service's getNewModel method
|
|
export default class GeneratedItemModel extends Model {
|
|
allFields = [];
|
|
|
|
@tracked _id;
|
|
get mutableId() {
|
|
return this._id || this.id;
|
|
}
|
|
set mutableId(value) {
|
|
this._id = value;
|
|
}
|
|
|
|
get fieldGroups() {
|
|
const groups = {
|
|
default: [],
|
|
};
|
|
const fieldGroups = [];
|
|
this.constructor.eachAttribute((name, attr) => {
|
|
// if the attr comes in with a fieldGroup from OpenAPI,
|
|
if (attr.options.fieldGroup) {
|
|
if (groups[attr.options.fieldGroup]) {
|
|
groups[attr.options.fieldGroup].push(attr);
|
|
} else {
|
|
groups[attr.options.fieldGroup] = [attr];
|
|
}
|
|
} else {
|
|
// otherwise just add that attr to the default group
|
|
groups.default.push(attr);
|
|
}
|
|
});
|
|
for (const group in groups) {
|
|
fieldGroups.push({ [group]: groups[group] });
|
|
}
|
|
return fieldGroups;
|
|
}
|
|
}
|