-
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 12 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
59 changes: 59 additions & 0 deletions
59
packages/compass-indexes/src/components/create-index-form/index-flow-section.spec.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,59 @@ | ||
| import React from 'react'; | ||
| import { render, screen } from '@mongodb-js/testing-library-compass'; | ||
| import IndexFlowSection from './index-flow-section'; | ||
| import { expect } from 'chai'; | ||
|
|
||
| describe('IndexFlowSection', () => { | ||
| const renderComponent = (createIndexFieldsComponent?: JSX.Element) => { | ||
| render( | ||
| <IndexFlowSection | ||
| createIndexFieldsComponent={createIndexFieldsComponent ?? null} | ||
| /> | ||
| ); | ||
| }; | ||
| it('renders the Input Index header', () => { | ||
| renderComponent(); | ||
| expect(screen.getByText('Input Index')).to.be.visible; | ||
| }); | ||
|
|
||
| it('renders the Code Equivalent toggle', () => { | ||
| renderComponent(); | ||
| expect(screen.getByLabelText('Toggle Code Equivalent')).to.be.visible; | ||
| }); | ||
|
|
||
| it('renders the Show me covered queries button', () => { | ||
| renderComponent(); | ||
| expect(screen.getByText('Show me covered queries')).to.be.visible; | ||
| }); | ||
|
|
||
| it('renders the Covered Queries header', () => { | ||
| renderComponent(); | ||
| expect(screen.getByText('Covered Queries')).to.be.visible; | ||
| }); | ||
|
|
||
| it('renders the provided createIndexFieldsComponent', () => { | ||
| const mockComponent = ( | ||
| <div data-testid="mock-component">Mock Component</div> | ||
| ); | ||
| renderComponent(mockComponent); | ||
| expect(screen.getByTestId('mock-component')).to.be.visible; | ||
| }); | ||
|
|
||
| it('renders the covered queries examples', () => { | ||
| renderComponent(); | ||
| expect(screen.getByTestId('index-flow-section-covered-queries-examples')).to | ||
| .exist; | ||
| }); | ||
|
|
||
| it('renders the optimal query examples', () => { | ||
| renderComponent(); | ||
| expect(screen.getByTestId('index-flow-section-optimal-query-examples')).to | ||
| .exist; | ||
| }); | ||
|
|
||
| it('renders the Learn More link', () => { | ||
| renderComponent(); | ||
| const link = screen.getByText('Learn More'); | ||
| expect(link).to.be.visible; | ||
| }); | ||
| }); |
186 changes: 186 additions & 0 deletions
186
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,186 @@ | ||
| import { | ||
| Body, | ||
| Button, | ||
| css, | ||
| cx, | ||
| Icon, | ||
| Label, | ||
| Link, | ||
| palette, | ||
| spacing, | ||
| Toggle, | ||
| Tooltip, | ||
| fontFamilies, | ||
| } from '@mongodb-js/compass-components'; | ||
| import React from 'react'; | ||
|
|
||
| const flexContainerStyles = css({ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| }); | ||
|
|
||
| const indexFieldsHeaderContainerStyles = css({ | ||
| justifyContent: 'space-between', | ||
| marginBottom: spacing[200], | ||
| }); | ||
|
|
||
| const indexFieldsCalloutStyles = css({ | ||
| border: `1px solid ${palette.gray.light2}`, | ||
| borderRadius: '12px', | ||
| padding: spacing[600], | ||
| marginBottom: spacing[600], | ||
| }); | ||
|
|
||
| const codeEquivalentToggleLabelStyles = css({ | ||
| marginRight: spacing[100], | ||
| fontWeight: 'normal', | ||
| }); | ||
|
|
||
| const coveredQueriesHeaderContainerStyles = css({ | ||
| marginBottom: spacing[200], | ||
| }); | ||
|
|
||
| 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({ | ||
| float: 'right', | ||
| marginTop: spacing[400], | ||
| }); | ||
|
|
||
| const underlineStyles = css({ | ||
| textDecoration: 'underline', | ||
| }); | ||
|
|
||
| const codeStyles = css({ | ||
| fontFamily: fontFamilies.code, | ||
| }); | ||
|
|
||
| const infoWithCircleIconStyles = css({ | ||
| color: palette.gray.dark1, | ||
| marginLeft: spacing[200], | ||
| }); | ||
|
|
||
| export type IndexFlowSectionProps = { | ||
| createIndexFieldsComponent: JSX.Element | null; | ||
| }; | ||
|
|
||
| const IndexFlowSection = ({ | ||
| createIndexFieldsComponent, | ||
| }: IndexFlowSectionProps) => { | ||
| return ( | ||
| <div> | ||
| <div | ||
| className={cx(indexFieldsHeaderContainerStyles, flexContainerStyles)} | ||
| > | ||
| <Body baseFontSize={16} weight="medium"> | ||
| Input Index | ||
| </Body> | ||
| <div className={flexContainerStyles}> | ||
| <Label | ||
| className={codeEquivalentToggleLabelStyles} | ||
| htmlFor="code-equivalent-toggle" | ||
| > | ||
| Code Equivalent | ||
| </Label> | ||
|
|
||
| <Toggle | ||
| size="xsmall" | ||
| id="code-equivalent-toggle" | ||
| aria-label="Toggle Code Equivalent" | ||
| onChange={() => { | ||
| () => { | ||
| // TODO in CLOUDP-311784 | ||
| }; | ||
| }} | ||
| // checked={false} | ||
| /> | ||
| </div> | ||
| </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 | ||
| }} | ||
| size="small" | ||
| > | ||
| Show me covered queries | ||
| </Button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div | ||
| className={cx(coveredQueriesHeaderContainerStyles, flexContainerStyles)} | ||
| > | ||
| <Body baseFontSize={16} weight="medium"> | ||
| Covered Queries | ||
| </Body> | ||
| <Tooltip | ||
| enabled={true} | ||
| trigger={ | ||
| <span> | ||
| <Icon | ||
| glyph="InfoWithCircle" | ||
Anemy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| className={cx(infoWithCircleIconStyles, flexContainerStyles)} | ||
| data-testid="index-flow-section-covered-queries-tooltip" | ||
| /> | ||
| </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 | ||
| className={codeStyles} | ||
| data-testid="index-flow-section-covered-queries-examples" | ||
| > | ||
| {`{ awards.wins:3 }`} <br /> | ||
| {`{ awards.wins:3, imdb.rating:5 }`} <br /> | ||
| {`{ awards.wins:3, imdb.rating:5, awards.nominations:8 }`} <br /> | ||
| </Body> | ||
| <p> | ||
| <span className={underlineStyles}> | ||
| 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
|
||
| </span> | ||
| {/* Optimal queries, clean up with actual optimal queries in CLOUDP-311783 */} | ||
| <Body | ||
| className={codeStyles} | ||
| data-testid="index-flow-section-optimal-query-examples" | ||
| > | ||
| {`{ 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; | ||
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.