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

UI: Refactor path-help service #28444

Merged
merged 18 commits into from
Sep 25, 2024

Conversation

hashishaw
Copy link
Contributor

@hashishaw hashishaw commented Sep 19, 2024

Description

Prep for ember-data upgrade -- refactors the path-help service so that it no longer uses deprecated Ember Data method ember-data:deprecate-model-reopen. Our goal with this work is to keep the functionality the same (ability to hydrate new and existing models with OpenAPI data) with more modern patterns. There should be no user-facing changes.

@hashishaw hashishaw added this to the 1.19.0-rc milestone Sep 19, 2024
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Sep 19, 2024
Copy link

github-actions bot commented Sep 19, 2024

CI Results:
All Go tests succeeded! ✅

@hashishaw hashishaw force-pushed the ui/VAULT-23576/ember-data-path-help-refactor branch 2 times, most recently from dc92a29 to cbbe403 Compare September 20, 2024 19:16
@hashishaw hashishaw marked this pull request as ready for review September 24, 2024 21:46
@hashishaw hashishaw requested a review from a team as a code owner September 24, 2024 21:46
Copy link

Build Results:
All builds succeeded! ✅

Copy link
Contributor

@Monkeychip Monkeychip left a comment

Choose a reason for hiding this comment

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

I wanted to get my comments in so you had plenty of time to review. Nothing blocking. I'll move on to smoke testing.

ui/app/adapters/generated-item-list.js Outdated Show resolved Hide resolved
ui/app/adapters/generated-item-list.js Outdated Show resolved Hide resolved
urlForItem(id, isList, dynamicApiPath) {
const itemType = sanitizePath(this.getPath);
let url;
id = encodePath(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

For my own understanding, because we're encoding the id here, i would expect it could be something like /test?. Is that correct? ID to me indicates a string that shouldn't need encoding, but then again we manual change ids to be concatenations of strange things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this can be anything that an auth item (such as userpass username) can be. In that case, things like spaces or special characters need to be encoded, which is why we do this here.

get mutableId() {
return this._id || this.id;
}
set mutableId(value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

*/
_registerModel(owner, NewKlass, modelType, isNew = false) {
const store = owner.lookup('service:store');
// bust cache in ember's registry
Copy link
Contributor

Choose a reason for hiding this comment

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

very helpful comments, thank you.

* @param {Attribute[]} attrs array of attributes {name, type, options}
* @returns new ModelClass extended from passed one, with the passed attributes added
*/
_upgradeModelSchema(Klass, attrs, newFields) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how you worked around the off-limits Class name, and used Klass 😎

@@ -8,11 +8,12 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid';

import authPage from 'vault/tests/pages/auth';
import { login, loginNs } from 'vault/tests/helpers/auth/auth-helpers';
Copy link
Contributor

Choose a reason for hiding this comment

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

🤩

ui/tests/unit/models/generated-item-test.js Outdated Show resolved Hide resolved
@hashishaw hashishaw enabled auto-merge (squash) September 25, 2024 17:56
@hashishaw hashishaw merged commit 8d6d26e into main Sep 25, 2024
31 checks passed
@hashishaw hashishaw deleted the ui/VAULT-23576/ember-data-path-help-refactor branch September 25, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants