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

feat: show wizard data on Editor UI from BOS #936

Merged

Conversation

Kevin101Zhang
Copy link
Contributor

@Kevin101Zhang Kevin101Zhang commented Jul 29, 2024

When users start on launchpad/wizard and populate the form with a valid checkbox state, BOS will send a request that the nextjs frontend consumes to check if the current Editor UI is one with launchpad data. If this is the case, the editor will call the generate/api and display the wizard code on editor.

@Kevin101Zhang Kevin101Zhang linked an issue Jul 29, 2024 that may be closed by this pull request
@Kevin101Zhang Kevin101Zhang changed the title feat: showcase dummy data in EditorUI feat: show wizard data on Editor UI from BOS Jul 29, 2024
@Kevin101Zhang Kevin101Zhang marked this pull request as ready for review July 30, 2024 19:44
@Kevin101Zhang Kevin101Zhang requested a review from a team as a code owner July 30, 2024 19:44
Copy link
Collaborator

@darunrs darunrs left a comment

Choose a reason for hiding this comment

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

Mostly good. Some comments on future plans and code clarity.

if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we validate the data returned as well? To make sure it has jsCode and sqlCode fields? And how do we handle a failure here visually? If something goes wrong, what would be the next best customer experience? Being redirected to a page which lets them explore existing indexers? The Create new indexer page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I can validate it to check for a correct response. Im not sure what the correct user response would be if the generateAPI fails. we have already forcefully already navigated them to the editor component outside of BOS.

const childKey = `${item.method_name}::${property}`;
if (checkboxState[childKey]) {
acc[property] = item.schema.properties[property];
if (!item.schema) return null;
Copy link
Collaborator

@darunrs darunrs Jul 31, 2024

Choose a reason for hiding this comment

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

If you have an if statement like this, you don't need to have item.schema checks in following if statements. You can leave it out as you know following code is guaranteed to have item.schema. The same follows for any other things you check. If you want that to be readily apparent, you can leave in the else block that's omitted here. All subsequent code lives in the else instead. This leads to a lot of tabbing, which can then be a signal that maybe a refactor is needed. You can maybe try something like the following:

  1. Perform checks which return null
  2. Store combined conditionals as boolean with a name. E.g. parentChecked || Object.keys(filteredProperties).length > 0 gets stored as a variable called hasPropertiesFromParent or something. As is, I have no clue what that if statement checks.
  3. Move filter logic to its own function called filterSchemaProperties()
  4. Move some conditional logic to return such as ...(var && { var }) which only spreads if var exists.

Something like that. In any case, my main point is this code is confusing. Can you refactor this code to make its logic more apparent at first glance?

@Kevin101Zhang Kevin101Zhang merged commit 73d1fdd into main Jul 31, 2024
4 checks passed
@Kevin101Zhang Kevin101Zhang deleted the 935-used-wizard-data-to-generate-sample-code-and-schema branch July 31, 2024 20:00
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.

used wizard Data to generate sample code and schema
2 participants