Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { css, cx, Modal, spacing } from '@mongodb-js/compass-components';
import React, { useState } from 'react';
import type { Dispatch, SetStateAction } from 'react';
import type { ConnectionFormProps } from './connection-form';
import ConnectionForm from './connection-form';
import type { ConnectionFormProps } from '@mongodb-js/connection-form';
import ConnectionForm from '@mongodb-js/connection-form';

const modalStyles = css({
'& > div': {
Expand Down
1 change: 1 addition & 0 deletions packages/compass-connections/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from './stores/store-context';
export { default as SingleConnectionForm } from './components/legacy-connections';
export { LegacyConnectionsModal } from './components/legacy-connections-modal';
export { default as ConnectionFormModal } from './components/connection-form-modal';
export { useConnectionFormPreferences } from './hooks/use-connection-form-preferences';
import type { connect as devtoolsConnect } from 'mongodb-data-service';
import type { ExtraConnectionData as ExtraConnectionDataForTelemetry } from '@mongodb-js/compass-telemetry';
Expand Down
1 change: 0 additions & 1 deletion packages/compass-sidebar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@mongodb-js/compass-maybe-protect-connection-string": "^0.28.0",
"@mongodb-js/compass-telemetry": "^1.2.3",
"@mongodb-js/compass-workspaces": "^0.28.0",
"@mongodb-js/connection-form": "^1.44.0",
"@mongodb-js/connection-info": "^0.9.3",
"compass-preferences-model": "^2.30.0",
"hadron-app-registry": "^9.2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
useConnections,
useConnectionsWithStatus,
} from '@mongodb-js/compass-connections/provider';
import { useConnectionFormPreferences } from '@mongodb-js/compass-connections';
import {
useConnectionFormPreferences,
ConnectionFormModal,
} from '@mongodb-js/compass-connections';
import { type ConnectionInfo } from '@mongodb-js/connection-info';
import {
ResizableSidebar,
Expand All @@ -15,7 +18,6 @@ import {
HorizontalRule,
} from '@mongodb-js/compass-components';
import { SidebarHeader } from './header/sidebar-header';
import { ConnectionFormModal } from '@mongodb-js/connection-form';
import { type RootState, type SidebarThunkAction } from '../../modules';
import { Navigation } from './navigation/navigation';
import ConnectionInfoModal from '../connection-info-modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ import { render, screen, userEvent } from '@mongodb-js/testing-library-compass';
import { expect } from 'chai';
import sinon from 'sinon';

import { ConnectionFormModalActions } from './connection-form-modal-actions';
import { ConnectionFormActions } from './connection-form-actions';

describe('<ConnectionFormModalActions />', function () {
describe('<ConnectionFormActions />', function () {
it('should show warnings', function () {
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[{ message: 'Warning!' }]}
onSave={() => undefined}
onSaveAndConnect={() => undefined}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
expect(screen.getByText('Warning!')).to.be.visible;
});

it('should show errors', function () {
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[{ message: 'Error!' }]}
warnings={[]}
onSave={() => undefined}
onSaveAndConnect={() => undefined}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
expect(screen.getByText('Error!')).to.be.visible;
});
Expand All @@ -34,12 +34,12 @@ describe('<ConnectionFormModalActions />', function () {
it('should call onSaveAndConnect function', function () {
const onSaveAndConnectSpy = sinon.spy();
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[]}
onSave={() => undefined}
onSaveAndConnect={onSaveAndConnectSpy}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
const connectButton = screen.getByRole('button', {
name: 'Save & Connect',
Expand All @@ -51,10 +51,10 @@ describe('<ConnectionFormModalActions />', function () {

it('should hide "connect" button if there is no callback', function () {
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[]}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
expect(screen.queryByRole('button', { name: 'Save & Connect' })).to.not
.exist;
Expand All @@ -65,12 +65,12 @@ describe('<ConnectionFormModalActions />', function () {
it('should call onSave function', function () {
const onSaveSpy = sinon.spy();
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[]}
onSave={onSaveSpy}
onSaveAndConnect={() => undefined}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
const saveButton = screen.getByRole('button', { name: 'Save' });
userEvent.click(saveButton);
Expand All @@ -79,11 +79,11 @@ describe('<ConnectionFormModalActions />', function () {

it('should hide "save" button if there is no callback', function () {
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[]}
onSaveAndConnect={() => undefined}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
expect(screen.queryByRole('button', { name: 'Save' })).to.not.exist;
});
Expand All @@ -93,13 +93,13 @@ describe('<ConnectionFormModalActions />', function () {
it('should call onCancel function', function () {
const onCancelSpy = sinon.spy();
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[]}
onSave={() => undefined}
onSaveAndConnect={() => undefined}
onCancel={onCancelSpy}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
const cancelButton = screen.getByRole('button', { name: 'Cancel' });
userEvent.click(cancelButton);
Expand All @@ -109,12 +109,12 @@ describe('<ConnectionFormModalActions />', function () {

it('should hide onCancel button if there is no callback', function () {
render(
<ConnectionFormModalActions
<ConnectionFormActions
errors={[]}
warnings={[]}
onSave={() => undefined}
onSaveAndConnect={() => undefined}
></ConnectionFormModalActions>
></ConnectionFormActions>
);
expect(screen.queryByRole('button', { name: 'Cancel' })).to.not.exist;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const saveAndConnectStyles = css({
justifyContent: 'flex-end',
});

export type ConnectionFormModalActionsProps = {
export type ConnectionFormActionsProps = {
errors: ConnectionFormError[];
warnings: ConnectionFormWarning[];

Expand All @@ -48,14 +48,14 @@ export type ConnectionFormModalActionsProps = {
onConnect?(): void;
};

export function ConnectionFormModalActions({
export function ConnectionFormActions({
errors,
warnings,
onCancel,
onSave,
onSaveAndConnect,
onConnect,
}: ConnectionFormModalActionsProps): React.ReactElement {
}: ConnectionFormActionsProps): React.ReactElement {
const saveAndConnectLabel = useConnectionFormSetting('saveAndConnectLabel');
return (
<div className={cx(formActionStyles)}>
Expand Down
4 changes: 2 additions & 2 deletions packages/connection-form/src/components/connection-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { cloneDeep } from 'lodash';
import ConnectionStringInput from './connection-string-input';
import AdvancedConnectionOptions from './advanced-connection-options';
import { ConnectionFormModalActions } from './connection-form-modal-actions';
import { ConnectionFormActions } from './connection-form-actions';
import {
useConnectForm,
type ConnectionPersonalizationOptions,
Expand Down Expand Up @@ -622,7 +622,7 @@ function ConnectionForm({
: formFooterBorderLightModeStyles
)}
>
<ConnectionFormModalActions
<ConnectionFormActions
Copy link
Contributor Author

@lerouxb lerouxb Nov 14, 2024

Choose a reason for hiding this comment

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

☝️ See this is the actions for connection-form, not really for connection-form-modal specifically.

errors={connectionStringInvalidError ? [] : errors}
warnings={connectionStringInvalidError ? [] : warnings}
onCancel={onCancel}
Expand Down
10 changes: 4 additions & 6 deletions packages/connection-form/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import ConnectionForm, { ColorCircleGlyph } from './components/connection-form';
import ConnectionFormModal from './components/connection-form-modal';
import type { ConnectionFormProps } from './components/connection-form';
import { adjustConnectionOptionsBeforeConnect } from './hooks/use-connect-form';

export {
adjustConnectionOptionsBeforeConnect,
ConnectionFormModal,
ColorCircleGlyph,
};
export { adjustConnectionOptionsBeforeConnect, ColorCircleGlyph };

export type { ConnectionFormProps };

export {
useConnectionColor,
Expand Down
Loading