-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Refactor path-help service (#28444)
* 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
- Loading branch information
Showing
14 changed files
with
887 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* 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; | ||
} | ||
} |
Oops, something went wrong.