-
Notifications
You must be signed in to change notification settings - Fork 234
feat(compass-collection): Preview Screen for Mock Data Generator CLOUDP-333857 #7433
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
jcobis
wants to merge
13
commits into
main
Choose a base branch
from
mock-data-generator-preview-screen-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+404
−2
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7db2f1c
WIP
jcobis 1be3845
WIP
jcobis 553d8dc
fix(compass-collection): Fix field name mismatch in Mock Data Generat…
jcobis 3b307d4
Revert comment
jcobis 618105c
fix(compass-collection): Fix field name mismatch in Mock Data Generat…
jcobis 8eb00a2
Revert comment
jcobis 50969d8
Merge branch 'CLOUDP-350280-clean' into mock-data-generator-preview-s…
jcobis 236e40f
For of instead of foreach
jcobis b62de6e
Remove undefined check
jcobis d662069
Refactor for readability
jcobis 69a4693
EJSON
jcobis 665d29a
Merge branch 'mock-data-generator-preview-screen-2' of github.com:mon…
jcobis ae408c8
Merge branch 'main' into mock-data-generator-preview-screen-2
jcobis 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
43 changes: 43 additions & 0 deletions
43
packages/compass-collection/src/components/mock-data-generator-modal/preview-screen.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,43 @@ | ||
import React, { useMemo } from 'react'; | ||
import { css, spacing, Body, Code } from '@mongodb-js/compass-components'; | ||
import { EJSON } from 'bson'; | ||
import type { FakerSchema } from './types'; | ||
import { generateDocument } from './script-generation-utils'; | ||
|
||
const descriptionStyles = css({ | ||
marginBottom: spacing[200], | ||
}); | ||
|
||
interface PreviewScreenProps { | ||
confirmedFakerSchema: FakerSchema; | ||
} | ||
|
||
const NUM_SAMPLE_DOCUMENTS = 3; | ||
|
||
function PreviewScreen({ confirmedFakerSchema }: PreviewScreenProps) { | ||
const sampleDocuments = useMemo(() => { | ||
const documents = []; | ||
for (let i = 0; i < NUM_SAMPLE_DOCUMENTS; i++) { | ||
documents.push(generateDocument(confirmedFakerSchema)); | ||
} | ||
|
||
return documents; | ||
}, [confirmedFakerSchema]); | ||
|
||
return ( | ||
<div data-testid="preview-screen"> | ||
<Body as="h2" baseFontSize={16} weight="medium"> | ||
Preview Mock Data | ||
</Body> | ||
<Body className={descriptionStyles}> | ||
Below is a sample of documents that will be generated based on your | ||
script | ||
</Body> | ||
<Code language="javascript" copyable={false}> | ||
{EJSON.stringify(sampleDocuments, undefined, 2)} | ||
</Code> | ||
</div> | ||
); | ||
} | ||
|
||
export default PreviewScreen; |
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.
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.