Skip to content

Commit 55fda3c

Browse files
committed
fix
1 parent 638f3bd commit 55fda3c

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

packages/compass-components/src/components/error-warning-summary.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const BannerWithSummary: React.FunctionComponent<
7777
variant: BannerVariant;
7878
['data-testid']?: string;
7979
className?: string;
80+
dismissible?: boolean;
8081
} & (
8182
| { actionText: string; onAction(): void }
8283
| { actionText?: never; onAction?: never }
@@ -88,6 +89,7 @@ const BannerWithSummary: React.FunctionComponent<
8889
actionText,
8990
variant,
9091
className,
92+
dismissible,
9193
}) => {
9294
const _messages = useMemo(() => {
9395
return !Array.isArray(messages) ? [messages] : messages;
@@ -98,6 +100,7 @@ const BannerWithSummary: React.FunctionComponent<
98100
data-testid={dataTestId}
99101
variant={variant}
100102
className={cx(bannerStyle, className)}
103+
dismissible={dismissible}
101104
>
102105
<div className={summaryStyles}>
103106
<Summary messages={_messages}></Summary>

packages/compass-schema/src/components/schema-toolbar/schema-toolbar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ const SchemaToolbar: React.FunctionComponent<SchemaToolbarProps> = ({
133133
<ErrorSummary
134134
data-testid="schema-toolbar-error-message"
135135
errors={[`${ERROR_WARNING}: ${error.errorMessage}`]}
136+
dismissible={true}
136137
/>
137138
)}
138139
{error?.errorType === 'TIMEOUT' && (
139-
<WarningSummary warnings={[INCREASE_MAX_TIME_MS_HINT_MESSAGE]} />
140+
<WarningSummary
141+
warnings={[INCREASE_MAX_TIME_MS_HINT_MESSAGE]}
142+
dismissible={true}
143+
/>
140144
)}
141145
{error?.errorType === 'HIGH_COMPLEXITY' && (
142146
<Banner

packages/compass-schema/src/modules/schema-analysis.spec.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createNoopLogger } from '@mongodb-js/compass-logging/provider';
77
import { isInternalFieldPath } from 'hadron-document';
88

99
import { analyzeSchema, calculateSchemaMetadata } from './schema-analysis';
10+
import {
11+
createSandboxFromDefaultPreferences,
12+
type PreferencesAccess,
13+
} from 'compass-preferences-model';
1014

1115
const testDocs = [
1216
{
@@ -64,8 +68,13 @@ const testDocs = [
6468
];
6569

6670
const dummyLogger = createNoopLogger('TEST');
71+
let preferences: PreferencesAccess;
6772

6873
describe('schema-analysis', function () {
74+
beforeEach(async function () {
75+
preferences = await createSandboxFromDefaultPreferences();
76+
});
77+
6978
afterEach(function () {
7079
sinon.restore();
7180
});
@@ -89,7 +98,8 @@ describe('schema-analysis', function () {
8998
'db.coll',
9099
{},
91100
{},
92-
dummyLogger
101+
dummyLogger,
102+
preferences
93103
);
94104

95105
const expectedSchema = {
@@ -182,7 +192,8 @@ describe('schema-analysis', function () {
182192
'db.coll',
183193
{},
184194
{},
185-
dummyLogger
195+
dummyLogger,
196+
preferences
186197
);
187198

188199
expect(sampleSpy).to.have.been.calledWith(
@@ -207,7 +218,8 @@ describe('schema-analysis', function () {
207218
'db.coll',
208219
{},
209220
{},
210-
dummyLogger
221+
dummyLogger,
222+
preferences
211223
);
212224

213225
expect(result).to.equal(undefined);
@@ -235,7 +247,8 @@ describe('schema-analysis', function () {
235247
'db.coll',
236248
{},
237249
{},
238-
dummyLogger
250+
dummyLogger,
251+
preferences
239252
);
240253
} catch (err: any) {
241254
expect(err.message).to.equal('should have been thrown');

packages/compass-schema/src/modules/schema-analysis.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
} from 'mongodb-schema';
1313
import type { DataService } from '../stores/store';
1414
import type { Logger } from '@mongodb-js/compass-logging';
15-
import { usePreference } from 'compass-preferences-model/provider';
15+
import type { PreferencesAccess } from 'compass-preferences-model';
1616

1717
// hack for driver 3.6 not promoting error codes and
1818
// attributes from ejson when promoteValue is false.
@@ -40,7 +40,8 @@ export const analyzeSchema = async (
4040
}
4141
| undefined,
4242
aggregateOptions: AggregateOptions,
43-
{ log, mongoLogId, debug }: Logger
43+
{ log, mongoLogId, debug }: Logger,
44+
preferences: PreferencesAccess
4445
): Promise<SchemaAccessor | undefined> => {
4546
try {
4647
log.info(mongoLogId(1001000089), 'Schema', 'Starting schema analysis', {
@@ -59,7 +60,7 @@ export const analyzeSchema = async (
5960
fallbackReadPreference: 'secondaryPreferred',
6061
}
6162
);
62-
const enableExportSchema = usePreference('enableExportSchema');
63+
const { enableExportSchema } = preferences.getPreferences();
6364
const schemaParseOptions: SchemaParseOptions = enableExportSchema
6465
? {
6566
signal: abortSignal,

packages/compass-schema/src/stores/schema-analysis-reducer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ export const startAnalysis = (): SchemaThunkAction<
304304
namespace,
305305
samplingOptions,
306306
driverOptions,
307-
logger
307+
logger,
308+
preferences
308309
);
309310
if (abortSignal?.aborted) {
310311
throw new Error(abortSignal?.reason || new Error('Operation aborted'));

0 commit comments

Comments
 (0)