Skip to content

triggering a param add pop-up if running a cypher with missing params #452

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

Merged
merged 10 commits into from
Apr 10, 2025

Conversation

nnecla
Copy link
Contributor

@nnecla nnecla commented Apr 1, 2025

This pr is to trigger the parameter add pop-up when a user wants to run a query with missing parameters. With these changes:

  • Passing a defaultName to the addParameter and adding param name to the prompt
  • Changing parameter error messages from await to void to prevent the wait for user to manually close the error message before opening the add pop-up for the following missing parameter
  • Adding a function extractParameters which gets an array of strings(queries) and returns distinct paramNames

Copy link

changeset-bot bot commented Apr 1, 2025

⚠️ No Changeset found

Latest commit: 11a99db

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Collaborator

@anderson4j anderson4j left a comment

Choose a reason for hiding this comment

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

Good stuff! I think I found an improvement to speed up tests (or for a computer from the 1900s maybe make it less flakey), but other than that I think it's good to go

Comment on lines 8 to 28
export function extractParameters(strings: string[]): string[] {
const paramSet = new Set<string>();

strings.forEach((str) => {
const matches = str.match(/\$`([^`]+)`|\$(\w+)/g);
if (matches) {
matches.forEach((match) => {
// Remove the '$'
const param = match.slice(1);
if (param.startsWith('`') && param.endsWith('`')) {
// Remove the backticks
paramSet.add(param.slice(1, -1));
} else {
paramSet.add(param);
}
});
}
});

return Array.from(paramSet);
}
Copy link
Collaborator

@ncordon ncordon Apr 3, 2025

Choose a reason for hiding this comment

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

I think it'd make more sense to have a small method in the language support that returns the parameters using the parser instead?

I see you've added the collectedParameters: ParsedParameter[] in #456 so it'd make sense to expose that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I will continue with this pr after I merge #456 and try to use collectedParameters instead of this method.

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've changed the implementation to call createParsingResult, to get the collectedParameters. I'm not sure if it is a too costly operation to be honest, and if I should add a new method only to collect the parameters for this purpose. What do you think?

@@ -7,7 +7,12 @@ export { _internalFeatureFlags } from './featureFlags';
export { formatQuery } from './formatting/formatting';
export { antlrUtils } from './helpers';
export { CypherTokenType, lexerSymbols } from './lexerSymbols';
export { parse, parserWrapper, parseStatementsStrs } from './parserWrapper';
export {
createParsingResult,
Copy link
Collaborator

@ncordon ncordon Apr 7, 2025

Choose a reason for hiding this comment

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

Maybe it'd be better to have a parseParameters method in the language support rather than exposing this internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to have a parseParameters which returns an array of strings(cleared param names)

Copy link
Collaborator

@ncordon ncordon left a comment

Choose a reason for hiding this comment

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

Really noice!

Copy link
Collaborator

@anderson4j anderson4j left a comment

Choose a reason for hiding this comment

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

Good stuff! Was wondering about the new escapeModal method, but if it has to use constant waiting then it looks good to merge to me

Comment on lines +18 to +24
async function escapeModal(count: number) {
for (let i = 0; i < count; i++) {
await browser.pause(500);
await browser.keys([Key.Escape]);
await waitUntilNotification(browser, 'Parameter value cannot be empty.');
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this flaky when you just did waitUntilNotification without browser.pause, or why was this added? In general it feels a little sketchy to use browser.pause() but in some cases it seems hard to avoid. (For example with waiting for the inputBox to open to type things into it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, actually, it was flaky. So, I'd like to keep these just in case, so that the browser wouldn't click on the Escape button before the parameter add pop-up opens :/

@nnecla nnecla merged commit c419f5d into main Apr 10, 2025
2 of 3 checks passed
@nnecla nnecla deleted the trigger-param-add-on-cypher-run branch April 10, 2025 08:25
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.

3 participants