Skip to content

Commit 549d838

Browse files
committed
rename request status enum
1 parent 47c1f3b commit 549d838

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

packages/compass-collection/src/components/mock-data-generator-modal/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ export enum MockDataGeneratorStep {
99
GENERATE_DATA = 'GENERATE_DATA',
1010
}
1111

12-
export const MOCK_DATA_GENERATOR_STATE_IDLE = 'idle';
13-
export const MOCK_DATA_GENERATOR_STATE_GENERATING = 'generating';
14-
export const MOCK_DATA_GENERATOR_STATE_COMPLETED = 'completed';
15-
export const MOCK_DATA_GENERATOR_STATE_ERROR = 'error';
12+
export const MOCK_DATA_GENERATOR_REQUEST_IDLE = 'idle';
13+
export const MOCK_DATA_GENERATOR_REQUEST_GENERATING = 'generating';
14+
export const MOCK_DATA_GENERATOR_REQUEST_COMPLETED = 'completed';
15+
export const MOCK_DATA_GENERATOR_REQUEST_ERROR = 'error';
1616

1717
type MockDataGeneratorIdleState = {
18-
status: typeof MOCK_DATA_GENERATOR_STATE_IDLE;
18+
status: typeof MOCK_DATA_GENERATOR_REQUEST_IDLE;
1919
};
2020

2121
type MockDataGeneratorGeneratingState = {
22-
status: typeof MOCK_DATA_GENERATOR_STATE_GENERATING;
22+
status: typeof MOCK_DATA_GENERATOR_REQUEST_GENERATING;
2323
requestId: string;
2424
};
2525

2626
type MockDataGeneratorCompletedState = {
27-
status: typeof MOCK_DATA_GENERATOR_STATE_COMPLETED;
27+
status: typeof MOCK_DATA_GENERATOR_REQUEST_COMPLETED;
2828
fakerSchema: MockDataSchemaResponse;
2929
requestId: string;
3030
};
3131

3232
type MockDataGeneratorErrorState = {
33-
status: typeof MOCK_DATA_GENERATOR_STATE_ERROR;
33+
status: typeof MOCK_DATA_GENERATOR_REQUEST_ERROR;
3434
error: unknown;
3535
requestId: string;
3636
};

packages/compass-collection/src/modules/collection-tab.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import { processSchema } from '../transform-schema-to-field-info';
3232
import type { Document, MongoError } from 'mongodb';
3333
import {
3434
MockDataGeneratorStep,
35-
MOCK_DATA_GENERATOR_STATE_IDLE,
36-
MOCK_DATA_GENERATOR_STATE_GENERATING,
37-
MOCK_DATA_GENERATOR_STATE_COMPLETED,
38-
MOCK_DATA_GENERATOR_STATE_ERROR,
35+
MOCK_DATA_GENERATOR_REQUEST_IDLE,
36+
MOCK_DATA_GENERATOR_REQUEST_GENERATING,
37+
MOCK_DATA_GENERATOR_REQUEST_COMPLETED,
38+
MOCK_DATA_GENERATOR_REQUEST_ERROR,
3939
} from '../components/mock-data-generator-modal/types';
4040
import type { MockDataGeneratorState } from '../components/mock-data-generator-modal/types';
4141

@@ -186,7 +186,7 @@ const reducer: Reducer<CollectionState, Action> = (
186186
currentStep: MockDataGeneratorStep.AI_DISCLAIMER,
187187
},
188188
fakerSchemaGeneration: {
189-
status: MOCK_DATA_GENERATOR_STATE_IDLE,
189+
status: MOCK_DATA_GENERATOR_REQUEST_IDLE,
190190
},
191191
},
192192
action
@@ -379,7 +379,7 @@ const reducer: Reducer<CollectionState, Action> = (
379379
return {
380380
...state,
381381
fakerSchemaGeneration: {
382-
status: MOCK_DATA_GENERATOR_STATE_GENERATING,
382+
status: MOCK_DATA_GENERATOR_REQUEST_GENERATING,
383383
requestId: action.requestId,
384384
},
385385
};
@@ -394,7 +394,7 @@ const reducer: Reducer<CollectionState, Action> = (
394394
return {
395395
...state,
396396
fakerSchemaGeneration: {
397-
status: MOCK_DATA_GENERATOR_STATE_COMPLETED,
397+
status: MOCK_DATA_GENERATOR_REQUEST_COMPLETED,
398398
fakerSchema: action.fakerSchema,
399399
requestId: action.requestId,
400400
},
@@ -410,7 +410,7 @@ const reducer: Reducer<CollectionState, Action> = (
410410
return {
411411
...state,
412412
fakerSchemaGeneration: {
413-
status: MOCK_DATA_GENERATOR_STATE_ERROR,
413+
status: MOCK_DATA_GENERATOR_REQUEST_ERROR,
414414
error: action.error,
415415
requestId: action.requestId,
416416
},
@@ -557,7 +557,9 @@ export const generateFakerMappings = (
557557
return;
558558
}
559559

560-
if (fakerSchemaGeneration.status === MOCK_DATA_GENERATOR_STATE_GENERATING) {
560+
if (
561+
fakerSchemaGeneration.status === MOCK_DATA_GENERATOR_REQUEST_GENERATING
562+
) {
561563
logger.debug(
562564
'Faker mapping generation is already in progress, skipping new generation.'
563565
);

packages/compass-collection/src/stores/collection-tab.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818
SCHEMA_ANALYSIS_STATE_INITIAL,
1919
} from '../schema-analysis-types';
2020
import {
21-
MOCK_DATA_GENERATOR_STATE_GENERATING,
22-
MOCK_DATA_GENERATOR_STATE_IDLE,
21+
MOCK_DATA_GENERATOR_REQUEST_GENERATING,
22+
MOCK_DATA_GENERATOR_REQUEST_IDLE,
2323
} from '../components/mock-data-generator-modal/types';
2424
import { CollectionActions } from '../modules/collection-tab';
2525
import { type MockDataSchemaResponse } from '@mongodb-js/compass-generative-ai';
@@ -316,7 +316,7 @@ describe('Collection Tab Content store', function () {
316316
validationRules: null,
317317
},
318318
},
319-
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_STATE_IDLE },
319+
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_REQUEST_IDLE },
320320
});
321321
const logger = {
322322
log: { error: sandbox.spy() },
@@ -390,7 +390,7 @@ describe('Collection Tab Content store', function () {
390390
status: SCHEMA_ANALYSIS_STATE_COMPLETE,
391391
processedSchema: undefined,
392392
},
393-
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_STATE_IDLE },
393+
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_REQUEST_IDLE },
394394
});
395395
const logger = {
396396
log: { error: sandbox.spy() },
@@ -431,7 +431,7 @@ describe('Collection Tab Content store', function () {
431431
const dispatch = sandbox.spy();
432432
const getState = sandbox.stub().returns({
433433
schemaAnalysis: { status: SCHEMA_ANALYSIS_STATE_INITIAL },
434-
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_STATE_IDLE },
434+
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_REQUEST_IDLE },
435435
});
436436
const logger = {
437437
log: { error: sandbox.spy() },
@@ -455,7 +455,9 @@ describe('Collection Tab Content store', function () {
455455
const dispatch = sandbox.spy();
456456
const getState = sandbox.stub().returns({
457457
schemaAnalysis: { status: SCHEMA_ANALYSIS_STATE_COMPLETE },
458-
fakerSchemaGeneration: { status: MOCK_DATA_GENERATOR_STATE_GENERATING },
458+
fakerSchemaGeneration: {
459+
status: MOCK_DATA_GENERATOR_REQUEST_GENERATING,
460+
},
459461
});
460462
const logger = {
461463
log: { error: sandbox.spy() },

packages/compass-collection/src/stores/collection-tab.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import reducer, {
99
analyzeCollectionSchema,
1010
} from '../modules/collection-tab';
1111
import { MockDataGeneratorStep } from '../components/mock-data-generator-modal/types';
12-
import { MOCK_DATA_GENERATOR_STATE_IDLE } from '../components/mock-data-generator-modal/types';
12+
import { MOCK_DATA_GENERATOR_REQUEST_IDLE } from '../components/mock-data-generator-modal/types';
1313

1414
import type { Collection } from '@mongodb-js/compass-app-stores/provider';
1515
import type { ActivateHelpers } from '@mongodb-js/compass-app-registry';
@@ -94,7 +94,7 @@ export function activatePlugin(
9494
currentStep: MockDataGeneratorStep.AI_DISCLAIMER,
9595
},
9696
fakerSchemaGeneration: {
97-
status: MOCK_DATA_GENERATOR_STATE_IDLE,
97+
status: MOCK_DATA_GENERATOR_REQUEST_IDLE,
9898
},
9999
},
100100
applyMiddleware(

0 commit comments

Comments
 (0)