Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ This document was automatically generated on Wed Nov 12 2025.
| **[mongodb-connection-string-url](#2e1146256a89ebd24e3398881e03807fe363d58444e6b7952ea50bd6108707bc)** | 3.0.1 | Apache-2.0 |
| **[mongodb-connection-string-url](#1fd70d8a07ac5222eca41b7f648d7e56e854e4947d54123daeca8614d050a545)** | 3.0.2 | Apache-2.0 |
| **[mongodb-log-writer](#985aaa38a9ce4a6f192fbd3fba7f9a713cf11718348d09268e92b363cfa0067f)** | 2.4.4 | Apache-2.0 |
| **[mongodb-mql-engines](#f3c3cf99d701af28ef931ec96d633f53a8010e9a64fe99de829cd0788725e29d)** | 0.0.4 | Apache-2.0 |
| **[mongodb-ns](#1cd7eed8e558e278003bafc11ef70f899d5d7c2e4e604a3223e4fa11a0f85fa7)** | 3.0.1 | Apache-2.0 |
| **[mongodb-ns](#15cc8a3da3a5e870e2d1230562cb9b6bbacd596d19d09daf5ad4d7bdbe331fa1)** | 3.0.3 | Apache-2.0 |
| **[mongodb-query-parser](#15068a4e6d825438a4e6d365a3566f58762ef216402070179557503b775f3ff4)** | 4.3.0 | Apache-2.0 |
Expand Down Expand Up @@ -28840,12 +28839,6 @@ License files:

<a id="f3c3cf99d701af28ef931ec96d633f53a8010e9a64fe99de829cd0788725e29d"></a>

### [mongodb-mql-engines](https://www.npmjs.com/package/mongodb-mql-engines) (version 0.0.4)

License tags: Apache-2.0

<a id="1cd7eed8e558e278003bafc11ef70f899d5d7c2e4e604a3223e4fa11a0f85fa7"></a>

### [mongodb-ns](https://www.npmjs.com/package/mongodb-ns) (version 3.0.1)

License tags: Apache-2.0
Expand Down
1 change: 0 additions & 1 deletion docs/tracking-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,6 @@ a system that doesn't offer a suitable secret storage backend.

**Properties**:

- **flow** (optional): `"Start with Query" | "Start with Index" | undefined`
- **context** (required): `"Create Index Modal"`
- **is_compass_web** (optional): `true | undefined`

Expand Down
30 changes: 0 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/compass-indexes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"mongodb": "^6.19.0",
"mongodb-collection-model": "^5.36.0",
"mongodb-data-service": "^22.35.0",
"mongodb-mql-engines": "^0.0.4",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"react": "^17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { css, Banner, spacing, Button } from '@mongodb-js/compass-components';
import { connect } from 'react-redux';
import { areAllFieldsFilledIn } from '../../utils/create-index-modal-validation';
import type { Field, Tab } from '../../modules/create-index';
import type { Field } from '../../modules/create-index';
import type { RootState } from '../../modules';
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';

Expand Down Expand Up @@ -33,32 +33,16 @@ function CreateIndexActions({
onCreateIndexClick,
onCancelCreateIndexClick,
fields,
currentTab,
indexSuggestions,
}: {
error: string | null;
onErrorBannerCloseClick: () => void;
onCreateIndexClick: () => void;
onCancelCreateIndexClick: () => void;
fields: Field[];
currentTab: Tab;
indexSuggestions: Record<string, number> | null;
}) {
const track = useTelemetry();

let isCreateIndexButtonDisabled = false;
// Disable create index button if the user is in Query Flow and has no suggestions
if (currentTab === 'QueryFlow') {
if (indexSuggestions === null) {
isCreateIndexButtonDisabled = true;
}
}
// Or if they are in the Index Flow but have not completed the fields
else {
if (!areAllFieldsFilledIn(fields)) {
isCreateIndexButtonDisabled = true;
}
}
const isCreateIndexButtonDisabled = !areAllFieldsFilledIn(fields);

return (
<div className={containerStyles}>
Expand Down Expand Up @@ -102,11 +86,9 @@ function CreateIndexActions({
}

const mapState = ({ createIndex }: RootState) => {
const { fields, currentTab, indexSuggestions } = createIndex;
const { fields } = createIndex;
return {
fields,
currentTab,
indexSuggestions,
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,73 +1,54 @@
import React from 'react';
import { render, screen, fireEvent } from '@mongodb-js/testing-library-compass';
import { render, screen, userEvent } from '@mongodb-js/testing-library-compass';
import { Provider } from 'react-redux';
import { CreateIndexForm } from './create-index-form';
import type { Field } from '../../modules/create-index';
import { expect } from 'chai';
import type { SinonSpy } from 'sinon';

import { setupStore } from '../../../test/setup-store';
import sinon from 'sinon';
import { Provider } from 'react-redux';

describe('CreateIndexForm', () => {
let onTabClickSpy: SinonSpy;
const store = setupStore();

beforeEach(function () {
onTabClickSpy = sinon.spy();
});
const defaultProps = {
namespace: 'test.collection',
fields: [
{ name: 'field1', type: '1' },
{ name: 'field2', type: '-1' },
] as Field[],
serverVersion: '5.0.0',
onSelectFieldNameClick: () => {},
onSelectFieldTypeClick: () => {},
onAddFieldClick: () => {},
onRemoveFieldClick: () => {},
query: null,
};

const renderComponent = ({
showIndexesGuidanceVariant,
}: {
showIndexesGuidanceVariant?: boolean;
}) => {
render(
const renderWithStore = (props = defaultProps) => {
const store = setupStore();
return render(
<Provider store={store}>
<CreateIndexForm
namespace="testNamespace"
fields={
[
{ name: 'field1', type: 'string' },
{ name: 'field2', type: 'number' },
] as Field[]
}
serverVersion="5.0.0"
currentTab="IndexFlow"
onSelectFieldNameClick={() => {}}
onSelectFieldTypeClick={() => {}}
onAddFieldClick={() => {}}
onRemoveFieldClick={() => {}}
onTabClick={onTabClickSpy}
showIndexesGuidanceVariant={showIndexesGuidanceVariant || false}
query={null}
/>
<CreateIndexForm {...props} />
</Provider>
);
};

it('renders the create index form', () => {
renderComponent({});
renderWithStore();
expect(screen.getByTestId('create-index-form')).to.exist;
});

describe('when showIndexesGuidanceVariant is false', () => {
it('renders the RadioBoxGroup', () => {
renderComponent({});
expect(screen.queryByTestId('create-index-form-flows')).not.to.exist;
});
it('renders the index fields section', () => {
renderWithStore();
expect(screen.getByText('Index fields')).to.exist;
});

describe('when showIndexesGuidanceVariant is true', () => {
it('renders the RadioBoxGroup', () => {
renderComponent({ showIndexesGuidanceVariant: true });
expect(screen.getByTestId('create-index-form-flows')).to.exist;
});
it('calls onTabClick when a RadioBox is selected', () => {
renderComponent({ showIndexesGuidanceVariant: true });
const radioBox = screen.getByLabelText('Start with a Query');
fireEvent.click(radioBox);
expect(onTabClickSpy).to.be.calledWith('QueryFlow');
});
it('renders standard index options when accordion is expanded', () => {
renderWithStore();
expect(screen.getByTestId('create-index-modal-toggle-options')).to.exist;

// Click to expand the options accordion
const optionsButton = screen.getByText('Options');
expect(optionsButton).to.exist;
userEvent.click(optionsButton);

expect(screen.getByTestId('create-index-modal-options')).to.exist;
});
});
Loading