Skip to content

feat: Fetching index suggestions and dealing with the states CLOUDP-311786 #6887

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

rubydong
Copy link
Collaborator

@rubydong rubydong commented May 1, 2025

Description

https://jira.mongodb.org/browse/CLOUDP-311786

With data:
image

Loading:
image

Error state to be fully implemented in another ticket

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@github-actions github-actions bot added the feat label May 1, 2025
@rubydong rubydong added the no release notes Fix or feature not for release notes label May 1, 2025
@rubydong rubydong marked this pull request as ready for review May 5, 2025 15:40
package.json Outdated
@@ -103,5 +103,9 @@
"chai-enzyme": {
"cheerio": "1.0.0-rc.10"
}
},
"dependencies": {
"@leafygreen-ui/skeleton-loader": "^2.0.11",
Copy link
Member

Choose a reason for hiding this comment

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

Can we add this dependency to the packages/compass-components/package.json instead?
Similar with the mongodb-mql-engines dependency, let's have that in the compass-indexes package.json

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

Looking good, left a couple questions/thoughts!

marginBottom: spacing[600],
padding: spacing[600],
background: palette.gray.light3,
border: `1px solid ${palette.gray.light2}`,
Copy link
Member

Choose a reason for hiding this comment

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

We add a dark mode styles so this border looks good in both themes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://jira.mongodb.org/browse/CLOUDP-313986 dark mode ticket is here! will go through all the components at that point and make sure it looks good in dark mode

@@ -117,7 +154,7 @@ const QueryFlowSection = ({
<div className={editorActionContainerStyles}>
<Button
onClick={() => {
// TODO in CLOUDP-311786
void handleSuggestedIndexButtonClick();
Copy link
Member

Choose a reason for hiding this comment

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

nit: Could we instead pass the handleSuggestedIndexButtonClick here, and then in the callback method there use void? That way we're passing a constant function here most of the time.

fetchingSuggestionsState: IndexSuggestionState;

// error specific to fetching index suggestions
fetchingSuggestionsError: Error | string | null;
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the code we could make this type just string | null. That being said I think we'd ideally want to be using the Error type here, so in those places where we set this error we can do

fetchingSuggestionsError: new Error('ERROR_STRING')

and then update this type to be only Error | null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how come you recommend Error instead of string? i'm basing it off of ErrorEncountered and that one seems to be string

sampleDocs: sampleDocuments,
indexSuggestions: null,
fetchingSuggestionsError:
'Error parsing query. Please follow query structure.',
Copy link
Member

Choose a reason for hiding this comment

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

Should we include anything from the error here? I'm wondering if the message might help folks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed it but note that it will not show up right now, going to fix up the error state and disabled in another ticket but just added some of it in this one

sampleDocs: sampleDocuments,
indexSuggestions,
fetchingSuggestionsError:
'No suggested index found. Please choose Start with an Index at the top to continue.',
Copy link
Member

Choose a reason for hiding this comment

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

Maybe:

Suggested change
'No suggested index found. Please choose Start with an Index at the top to continue.',
'No suggested index found. Please choose "Start with an Index" at the top to continue.',

(fine as is too, feel free to resolve).

);

const query = mql.parseQuery(
EJSON.parse(inputQuery, { relaxed: false }),
Copy link
Member

Choose a reason for hiding this comment

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

Does this work as expected with some queries? On a quick glance we might need to be parsing them with a different method. Should it be using this instead?

const parsed = _parseShellBSON(source, { mode: ParseMode.Loose });

I might be wrong, haven't checked out the branch and tried it yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it works for the most part but will break if there's a new line

working:
image

breaks:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants