-
Notifications
You must be signed in to change notification settings - Fork 245
feat: Add UI without functionality for "Start with an index" flow CLOUDP-311781 #6874
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
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0f66f7b
set up border and covered queries button
rubydong 4cddc04
resolve merge conflicts
rubydong 8caf1f8
set up most of the styling for index flow
rubydong 54f8b3f
finished styling + added tooltip and code equivalent
rubydong 2a4a846
updated styling to center more things
rubydong 3cb7fcf
added tests
rubydong af4d61d
do not need to import font
rubydong 1a0964a
Merge remote-tracking branch 'origin/main' into cloudp-311781
rubydong 3d5b574
reverted the control back to initial state
rubydong 233e390
temporarily rmeove tests
rubydong 2acb3fd
adding back tests
rubydong 7260d02
address pr comments
rubydong 7e551e6
fixed infosprinkle and calls to CreateIndexFields
rubydong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
packages/compass-indexes/src/components/create-index-form/index-flow-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| import { | ||
| Body, | ||
| Button, | ||
| css, | ||
| Icon, | ||
| Link, | ||
| palette, | ||
| spacing, | ||
| Toggle, | ||
| Tooltip, | ||
| } from '@mongodb-js/compass-components'; | ||
| import React from 'react'; | ||
|
|
||
| const headerStyles = css({ | ||
| marginBottom: spacing[200], | ||
| }); | ||
|
|
||
| const indexFieldsHeaderContainterStyles = css({ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'space-between', | ||
| }); | ||
|
|
||
| const indexFieldsCalloutStyles = css({ | ||
| border: `1px solid ${palette.gray.light2}`, | ||
| borderRadius: '12px', | ||
| padding: spacing[600], | ||
| marginBottom: spacing[600], | ||
| }); | ||
|
|
||
| const coveredQueriesHeaderContainterStyles = css({ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| }); | ||
|
|
||
| const coveredQueriesCalloutStyles = css({ | ||
| border: `1px solid ${palette.gray.light2}`, | ||
| background: palette.gray.light3, | ||
| borderRadius: '12px', | ||
| padding: spacing[600], | ||
| marginBottom: spacing[600], | ||
| }); | ||
|
|
||
| const buttonContainerStyles = css({ | ||
| display: 'flex', | ||
| justifyContent: 'right', | ||
| }); | ||
|
|
||
| const coveredQueriesButtonStyles = css({ | ||
| height: spacing[600] + 4, | ||
Anemy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| float: 'right', | ||
| marginTop: spacing[400], | ||
| }); | ||
|
|
||
| const codeStyles = css({ | ||
| fontFamily: 'Source Code Pro', | ||
Anemy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| const infoWithCircleIconStyles = css({ | ||
| color: palette.gray.dark1, | ||
| marginLeft: spacing[200], | ||
| }); | ||
|
|
||
| const IndexFlowSection = ({ | ||
| createIndexFieldsComponent, | ||
| }: { | ||
| createIndexFieldsComponent: JSX.Element | null; | ||
| }) => { | ||
| return ( | ||
| <div> | ||
| <div className={indexFieldsHeaderContainterStyles}> | ||
| <Body baseFontSize={16} weight="medium" className={headerStyles}> | ||
| Input Index | ||
| </Body> | ||
| <Toggle | ||
| size="xsmall" | ||
| aria-label="Toggle Auto Preview" | ||
| onChange={() => { | ||
| () => { | ||
| // TODO in CLOUDP-311784 | ||
| }; | ||
| }} | ||
| checked={false} | ||
| > | ||
| Code Equivalent | ||
| </Toggle> | ||
| </div> | ||
| <div className={indexFieldsCalloutStyles}> | ||
| {createIndexFieldsComponent} | ||
|
|
||
| <div className={buttonContainerStyles}> | ||
| <Button | ||
| className={coveredQueriesButtonStyles} | ||
| onClick={() => { | ||
| // TODO in CLOUDP-311782 generate covered queries | ||
| // TODO in CLOUDP-311783 generate optimal queries | ||
| }} | ||
| > | ||
| Show me covered queries | ||
| </Button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className={coveredQueriesHeaderContainterStyles}> | ||
| <Body baseFontSize={16} weight="medium" className={headerStyles}> | ||
| Covered Queries | ||
| </Body> | ||
| <Tooltip | ||
| enabled={true} | ||
| trigger={ | ||
| <span> | ||
| <Icon | ||
| glyph="InfoWithCircle" | ||
Anemy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| className={infoWithCircleIconStyles} | ||
| /> | ||
| </span> | ||
| } | ||
| triggerEvent="hover" | ||
| align="top" | ||
| justify="middle" | ||
| > | ||
| A covered query is a query that can be satisfied entirely using an | ||
| index and does not have to examine any documents. If a query is | ||
| covered, it is highly performant. | ||
| </Tooltip> | ||
| </div> | ||
|
|
||
| <div className={coveredQueriesCalloutStyles}> | ||
| {/* Covered Queries, clean up with actual covered queries examples in CLOUDP-311782 */} | ||
| <Body baseFontSize={13} className={codeStyles}> | ||
| {`{ awards.wins:3 }`} <br /> | ||
| {`{ awards.wins:3, imdb.rating:5 }`} <br /> | ||
| {`{ awards.wins:3, imdb.rating:5, awards.nominations:8 }`} <br /> | ||
| </Body> | ||
| <p> | ||
| <u> | ||
| Follow the Equality, Sort, Range (ESR) Rule and this index is | ||
| optimal for queries that have this pattern: | ||
Anemy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </u> | ||
| {/* Optimal queries, clean up with actual optimal queries in CLOUDP-311783 */} | ||
| <Body baseFontSize={13} className={codeStyles}> | ||
| {`{ awards.wins : 5, imdb.rating: {$gt : 5} }.sort({ awards.nominations : 1 }`} | ||
| </Body> | ||
| </p> | ||
|
|
||
| <Link href="https://www.mongodb.com/docs/manual/core/query-optimization/"> | ||
| Learn More | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default IndexFlowSection; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some repetitive code for now but this would make it easier to clean up in the future whether we release the variant or keep things as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeating code will make it so that if we introduce unrelated changes, we'll have to remember to update both (and may lead to something not getting included). I think ideally we should avoid that. Are there large changes coming in the accordion changes that will make these very different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for accordion we're just gonna change how it looks but nothing with functionality.

i thought it'd be cleaner this way but i can revert back to a combined view