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

Parse sObjects in the landing page and return them in an array #51

Merged
merged 21 commits into from
Nov 14, 2023

Conversation

sfdctaka
Copy link
Collaborator

@sfdctaka sfdctaka commented Nov 8, 2023

No description provided.

@sfdctaka sfdctaka requested a review from a team as a code owner November 8, 2023 19:32
@khawkins
Copy link
Collaborator

khawkins commented Nov 8, 2023

You're going to need to rebase against main.

src/utils/uemParser.ts Outdated Show resolved Hide resolved
@sfdctaka
Copy link
Collaborator Author

sfdctaka commented Nov 8, 2023

@khawkins On resolving the conflict now. I was talking with @dbreese but after resolving we will need a refinement in how we render the table as we'll now have both what sObjects that we are generating for and what sObjects' QAs already exist. So this may not come clear after my merge conflict, just a heads up.

@khawkins
Copy link
Collaborator

khawkins commented Nov 8, 2023

@khawkins On resolving the conflict now. I was talking with @dbreese but after resolving we will need a refinement in how we render the table as we'll now have both what sObjects that we are generating for and what sObjects' QAs already exist. So this may not come clear after my merge conflict, just a heads up.

Yeah we need to resolve, for sure. Looking at both implementations, I don't think the results of your functionality (finding the sObjects represented in the landing page) should be going back to the UI. That's functionality that the LWC generation code needs to invoke, to understand what it needs to generate. To me, that's what should be (and currently is) going back to the UI. I think the sObject interrogation in the landing page should just be represented as functionality internal to the process.

Cc: @dbreese

@sfdctaka
Copy link
Collaborator Author

sfdctaka commented Nov 8, 2023

@dbreese @khawkins I am now working on exactly that, making interrogation as a part or internal to finding which sobject's QA to generate(view/edit/create). The way it is set up now window.load will need to make to separate calls for finding what sobjects there are on the landing page and which QA's are there for those sobjects. Mashing them into one is the way to go.

package.json Show resolved Hide resolved
Copy link
Collaborator

@dbreese dbreese left a comment

Choose a reason for hiding this comment

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

LGTM!

src/utils/uemParser.ts Outdated Show resolved Hide resolved
return results;
}

static findObjectsWithValues(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I'm still not convinced on "searching" the JSON. The JSON in question in this case is a well-known data structure. We should be querying it, not searching it. For all of its unwieldiness, it's still deterministic that objectApiName keys can be found at view.regions.components.components[_x_].regions.components.components[_y_].properties.objectApiName (or something along those lines). I haven't looked across all of the templates to see whether or not there may be a similar path to other ones—but if there is, it will be just as deterministic.

I feel like we should be deliberate about access these data properties. To me, searching for them is just opening a door to false positives, with no real upside. We should query the data structure we know.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wasn't sure if it will always be in that location. I suggested to @sfdctaka that as long as we find an mcf/list or mcf/timedList, then from there .properties.objectApiName should be populated. I thought that with the UEM file, it can be arbitrarily deep and nested in other components such as an mcf/card or something else perhaps.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I support continuing to have some measure of a UEM "fronting" class for these data structures, because they are so unwieldy, and accessing properties therein in a more friendly encapsulated manner could be useful down the road.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought that with the UEM file, it can be arbitrarily deep and nested in other components such as an mcf/card or something else perhaps.

It'd be good to understand if that's the case, and then if so what the constraints are on that definition, and how we'd respond to them.

My point is more that we should strive to leverage our understanding of this data structure that we're supporting. To do a "find" is kind of punting on that understanding, and to me exposes a gap that we need to close.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cc: @Taost

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wrote a xpath-ish query function to replace the recursive deep search. @khawkins please check it out.

src/utils/uemParser.ts Outdated Show resolved Hide resolved
@sfdctaka
Copy link
Collaborator Author

sfdctaka commented Nov 11, 2023

@khawkins Made the search to simpler, to look for all objectApiName. I will do prettier update in another PR.

src/utils/uemParser.ts Outdated Show resolved Hide resolved
src/utils/uemParser.ts Outdated Show resolved Hide resolved
src/utils/uemParser.ts Outdated Show resolved Hide resolved
src/utils/uiUtils.ts Outdated Show resolved Hide resolved
src/utils/uiUtils.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@khawkins khawkins left a comment

Choose a reason for hiding this comment

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

It looks good to me overall! A few minor corrections, but otherwise it's lookin' good.

src/utils/uiUtils.ts Outdated Show resolved Hide resolved
@sfdctaka
Copy link
Collaborator Author

I think the last commit could be the final dagger, @khawkins .

@khawkins
Copy link
Collaborator

I think the last commit could be the final dagger, @khawkins .

Pretty close! 😆 I think all that's left is to just remove those now-redundant tests in uiUtils.test.ts. Otherwise 🧑‍🍳😚 looking good to me!

Copy link
Collaborator

@khawkins khawkins left a comment

Choose a reason for hiding this comment

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

🎉

@sfdctaka sfdctaka merged commit 4030b50 into salesforce:main Nov 14, 2023
9 checks passed
@sfdctaka sfdctaka deleted the uemParser branch November 14, 2023 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants