-
Notifications
You must be signed in to change notification settings - Fork 239
feat(compass-collection): finish contents of mock data generator confirmation screen CLOUDP-333852 #7299
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
feat(compass-collection): finish contents of mock data generator confirmation screen CLOUDP-333852 #7299
Changes from 3 commits
3cf163e
b4d1784
7fbb335
2dfa720
0518349
be20bc1
7873b6e
780c398
3ce421a
adf4eac
05aa795
5c8e35c
cf25bab
c13f44b
833fd37
78e3f5a
ef9dfc8
f0d817a
65b9a9e
e411dd9
df6c2a6
2b2cc7d
3634213
d178f00
90ef737
a74d752
e0181f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import React from 'react'; | ||
|
|
||
| // TODO: More to come from CLOUDP-333853, CLOUDP-333854 | ||
| const FakerSchemaEditor = () => { | ||
| const FakerSchemaEditorScreen = () => { | ||
| return ( | ||
| <div data-testid="faker-schema-editor"> | ||
| Schema Editor Content Placeholder | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default FakerSchemaEditor; | ||
| export default FakerSchemaEditorScreen; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import React from 'react'; | ||
| import { connect } from 'react-redux'; | ||
|
|
||
| import { | ||
| css, | ||
| palette, | ||
| spacing, | ||
| Banner, | ||
| BannerVariant, | ||
| Code, | ||
| Body, | ||
| } from '@mongodb-js/compass-components'; | ||
|
|
||
| import { usePreference } from 'compass-preferences-model/provider'; | ||
| import toSimplifiedFieldInfo from './to-simplified-field-info'; | ||
| import type { CollectionState } from '../../modules/collection-tab'; | ||
| import type { SchemaAnalysisState } from '../../schema-analysis-types'; | ||
| import type { MockDataGeneratorState } from './types'; | ||
|
|
||
| interface RawSchemaConfirmationScreenProps { | ||
| schemaAnalysis: SchemaAnalysisState; | ||
| namespace: string; | ||
| fakerSchemaGenerationStatus: MockDataGeneratorState['status']; | ||
| } | ||
|
|
||
| const namespaceStyles = css({ | ||
| marginTop: spacing[100], | ||
| marginBottom: spacing[500], | ||
| }); | ||
|
|
||
| const headingStyles = css({ | ||
| marginBottom: spacing[100], | ||
| }); | ||
|
|
||
| const descriptionStyles = css({ | ||
| marginBottom: spacing[300], | ||
| }); | ||
|
|
||
| const codeStyles = css({ | ||
| maxHeight: '30vh', | ||
| }); | ||
|
|
||
| const errorBannerStyles = css({ | ||
| marginTop: spacing[400], | ||
| }); | ||
|
|
||
| const errorBannerTextStyles = css({ | ||
| color: palette.red.dark2, | ||
| }); | ||
|
|
||
| const RawSchemaConfirmationScreen = ({ | ||
| schemaAnalysis, | ||
| namespace, | ||
| fakerSchemaGenerationStatus, | ||
| }: RawSchemaConfirmationScreenProps) => { | ||
| const enableSampleDocumentPassing = usePreference( | ||
| 'enableGenAISampleDocumentPassing' | ||
| ); | ||
|
|
||
| const subtitleText = enableSampleDocumentPassing | ||
| ? 'Sample Documents Collected' | ||
| : 'Document Schema Identified'; | ||
|
|
||
| const descriptionText = enableSampleDocumentPassing | ||
| ? 'A sample of document values from your collection will be sent to an LLM for processing.' | ||
| : 'We have identified the following schema from your documents. This schema will be sent to an LLM for processing.'; | ||
|
|
||
| // todo: should establish if unfinished schema analysis edge case should be handled within the modal or | ||
|
||
| // from the button opening the modal | ||
| const schemaAnalysisIncompletePlaceholder = ( | ||
| <Body>Schema analysis has yet to complete successfully.</Body> | ||
kpamaran marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| return ( | ||
| <div data-testid="raw-schema-confirmation"> | ||
| {schemaAnalysis.status === 'complete' ? ( | ||
| <> | ||
| <Body className={namespaceStyles}>{namespace}</Body> | ||
|
||
| <Body | ||
| as="h2" | ||
| className={headingStyles} | ||
| baseFontSize={16} | ||
| weight="medium" | ||
| > | ||
| {subtitleText} | ||
| </Body> | ||
| <Body className={descriptionStyles}>{descriptionText}</Body> | ||
| <Code language="javascript" copyable={false} className={codeStyles}> | ||
| {enableSampleDocumentPassing | ||
| ? JSON.stringify(schemaAnalysis.sampleDocument, null, 4) | ||
|
||
| : JSON.stringify( | ||
| toSimplifiedFieldInfo(schemaAnalysis.processedSchema), | ||
| null, | ||
| 4 | ||
| )} | ||
| </Code> | ||
| {fakerSchemaGenerationStatus === 'error' && ( | ||
| <Banner | ||
| variant={BannerVariant.Danger} | ||
| className={errorBannerStyles} | ||
| > | ||
| <Body className={errorBannerTextStyles}> | ||
| LLM Request failed. Please confirm again. | ||
| </Body> | ||
| </Banner> | ||
| )} | ||
| </> | ||
| ) : ( | ||
| schemaAnalysisIncompletePlaceholder | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const mapStateToProps = (state: CollectionState) => { | ||
| const schemaAnalysis = state.schemaAnalysis; | ||
| const fakerSchemaGenerationStatus = state.fakerSchemaGeneration.status; | ||
|
|
||
| return { | ||
| schemaAnalysis, | ||
| namespace: state.namespace, | ||
| fakerSchemaGenerationStatus, | ||
| }; | ||
| }; | ||
|
|
||
| const ConnectedRawSchemaConfirmationScreen = connect( | ||
| mapStateToProps, | ||
| {} | ||
| )(RawSchemaConfirmationScreen); | ||
|
|
||
| export default ConnectedRawSchemaConfirmationScreen; | ||
This file was deleted.
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.
I realize this is from Figma, but just going to say, the wording here seems odd, "document value" is somewhat clear but it's definitely not standard terminology. Can this be
?
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.
Certainly