Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3cf163e
implement raw schema confirmation screen
kpamaran Sep 8, 2025
b4d1784
Merge branch 'main' into mock-data-generator-raw-schema-confirmation-…
kpamaran Sep 8, 2025
7fbb335
shorthand schema render logic in confirmation step
kpamaran Sep 9, 2025
2dfa720
nit
kpamaran Sep 9, 2025
0518349
move tests
kpamaran Sep 9, 2025
be20bc1
revert
kpamaran Sep 9, 2025
7873b6e
nit
kpamaran Sep 9, 2025
780c398
Merge branch 'main' into mock-data-generator-raw-schema-confirmation-…
kpamaran Sep 9, 2025
3ce421a
nit
kpamaran Sep 9, 2025
adf4eac
nit
kpamaran Sep 9, 2025
05aa795
address smaller feedback
kpamaran Sep 10, 2025
5c8e35c
nit
kpamaran Sep 10, 2025
cf25bab
rename
kpamaran Sep 10, 2025
c13f44b
define and handle unsupported state
kpamaran Sep 10, 2025
833fd37
nit
kpamaran Sep 10, 2025
78e3f5a
downgrade log severity
kpamaran Sep 10, 2025
ef9dfc8
add compass-crud as a dep to compass-collection
kpamaran Sep 10, 2025
f0d817a
Merge branch 'main' into mock-data-generator-raw-schema-confirmation-…
kpamaran Sep 10, 2025
65b9a9e
remove validation
kpamaran Sep 10, 2025
e411dd9
avoid cyclical dep
kpamaran Sep 11, 2025
df6c2a6
increase readability given multipel tooltip messages
kpamaran Sep 11, 2025
2b2cc7d
Merge branch 'main' into mock-data-generator-raw-schema-confirmation-…
kpamaran Sep 11, 2025
3634213
add className prop to HadronDocument
kpamaran Sep 12, 2025
d178f00
fix grammar
kpamaran Sep 12, 2025
90ef737
Remove error handling branch
kpamaran Sep 15, 2025
a74d752
Merge branch 'main' into mock-data-generator-raw-schema-confirmation-…
kpamaran Sep 15, 2025
e0181f0
fix sentence
kpamaran Sep 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -20,10 +20,12 @@ describe('MockDataGeneratorModal', () => {
async function renderModal({
isOpen = true,
currentStep = MockDataGeneratorStep.SCHEMA_CONFIRMATION,
enableGenAISampleDocumentPassing = false,
mockServices = createMockServices(),
connectionInfo,
}: {
isOpen?: boolean;
enableGenAISampleDocumentPassing?: boolean;
currentStep?: MockDataGeneratorStep;
mockServices?: any;
connectionInfo?: ConnectionInfo;
Expand Down Expand Up @@ -63,7 +65,12 @@ describe('MockDataGeneratorModal', () => {
<Provider store={store}>
<MockDataGeneratorModal />
</Provider>,
connectionInfo
connectionInfo,
{
preferences: {
enableGenAISampleDocumentPassing,
},
}
);
}

Expand Down Expand Up @@ -109,6 +116,34 @@ describe('MockDataGeneratorModal', () => {
expect(screen.queryByTestId('generate-mock-data-modal')).to.not.exist;
});

it('uses the appropriate copy when Generative AI sample document passing is enabled', async () => {
await renderModal({ enableGenAISampleDocumentPassing: true });
expect(screen.queryByText('Sample Documents Collected')).to.exist;
expect(
screen.queryByText(
'A sample of document values from your collection will be sent to an LLM for processing.'
)
).to.exist;
// fragment from { "name": "John" }
expect(screen.queryByText('"John"')).to.exist;
expect(screen.queryByText('"String"')).to.not.exist;
});

it('uses the appropriate copy when Generative AI sample document passing is disabled', async () => {
await renderModal();
expect(screen.queryByText('Document Schema Identified')).to.exist;
expect(
screen.queryByText(
'We have identified the following schema from your documents. This schema will be sent to an LLM for processing.'
)
).to.exist;
// fragment from { "name": "String" }
expect(screen.queryByText('"String"')).to.exist;
expect(screen.queryByText('"John"')).to.not.exist;

screen.debug();
});

it('closes the modal when the close button is clicked', async () => {
await renderModal();

Expand Down Expand Up @@ -230,7 +265,8 @@ describe('MockDataGeneratorModal', () => {
expect(screen.queryByTestId('faker-schema-editor')).to.not.exist;
});

// todo: assert a user-friendly error is displayed (CLOUDP-333852)
expect(screen.getByText('LLM Request failed. Please confirm again.')).to
.exist;
});

// todo: assert that closing then re-opening the modal after an LLM err removes the err message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
generateFakerMappings,
mockDataGeneratorPreviousButtonClicked,
} from '../../modules/collection-tab';
import { default as SchemaConfirmationScreen } from './raw-schema-confirmation';
import FakerSchemaEditor from './faker-schema-editor';
import RawSchemaConfirmationScreen from './raw-schema-confirmation-screen';
import FakerSchemaEditorScreen from './faker-schema-editor-screen';
import ScriptScreen from './script-screen';

const footerStyles = css`
Expand Down Expand Up @@ -56,9 +56,9 @@ const MockDataGeneratorModal = ({
const modalBodyContent = useMemo(() => {
switch (currentStep) {
case MockDataGeneratorStep.SCHEMA_CONFIRMATION:
return <SchemaConfirmationScreen />;
return <RawSchemaConfirmationScreen />;
case MockDataGeneratorStep.SCHEMA_EDITOR:
return <FakerSchemaEditor />;
return <FakerSchemaEditorScreen />;
case MockDataGeneratorStep.DOCUMENT_COUNT:
return <></>; // TODO: CLOUDP-333856
case MockDataGeneratorStep.PREVIEW_DATA:
Expand Down
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.'
Copy link
Collaborator

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

Suggested change
? 'A sample of document values from your collection will be sent to an LLM for processing.'
? 'A sample of documens from your collection will be sent to an LLM for processing.'

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Certainly

: '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
Copy link
Collaborator

@jcobis jcobis Sep 9, 2025

Choose a reason for hiding this comment

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

Alternatively, we could just disabled button

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I lean towards disabling the button plus updating the hover tooltip. It would be awkward to have a modal open and the user isn't able to act on anything but wait

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to go ahead and do so. We can make the tooltip copy "Schema analysis in progress" for now

Copy link
Collaborator Author

@kpamaran kpamaran Sep 9, 2025

Choose a reason for hiding this comment

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

Net diffs is high in this PR. I think I can weave the tooltip into CLOUDP-333853 which is already small in scope

// from the button opening the modal
const schemaAnalysisIncompletePlaceholder = (
<Body>Schema analysis has yet to complete successfully.</Body>
);

return (
<div data-testid="raw-schema-confirmation">
{schemaAnalysis.status === 'complete' ? (
<>
<Body className={namespaceStyles}>{namespace}</Body>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we want to show the namespace on all screens according to Figma. This should probably go in mock-data-generator-modal.tsx so it's shared between all the screens.

<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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens with types that are not representible in JSON?

The Figma designs seem to be aiming for something like our DocumentListView component rather than JSON

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to the Document component. I don't think there should be any more representation issues on the schema-only or sample-doc variants

: 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.

Loading
Loading