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
4 changes: 1 addition & 3 deletions configs/eslint-config-compass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const common = require('@mongodb-js/eslint-config-devtools/common');
const chaiFriendly = require('eslint-plugin-chai-friendly');

// TODO(COMPASS-9459): disabling a bunch of new rules to unblock automatic updates
const tempNewEslintRulesDisabled = {
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
};
const tempNewEslintRulesDisabled = {};

const extraTsRules = {
// Newly converted plugins use `any` quite a lot, we can't enable the rule,
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-aggregations/src/modules/search-indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { SearchIndex } from 'mongodb-data-service';
import { isAction } from '../utils/is-action';

// @ts-expect-error TODO(COMPASS-10124): replace enums with const kv objects
enum SearchIndexesStatuses {
export enum SearchIndexesStatuses {
INITIAL = 'INITIAL',
LOADING = 'LOADING',
READY = 'READY',
Expand Down Expand Up @@ -41,7 +41,7 @@ export type SearchIndexesAction =
type State = {
isSearchIndexesSupported: boolean;
indexes: SearchIndex[];
status: SearchIndexesStatus;
status: SearchIndexesStatuses;
};

export const INITIAL_STATE: State = {
Expand Down
13 changes: 10 additions & 3 deletions packages/compass-global-writes/src/components/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ import { expect } from 'chai';
import { screen } from '@mongodb-js/testing-library-compass';
import { GlobalWrites } from './index';
import { renderWithStore } from './../../tests/create-store';
import { ShardingStatuses } from '../store/reducer';

describe('Compass GlobalWrites Plugin', function () {
it('renders plugin in NOT_READY state', async function () {
await renderWithStore(<GlobalWrites shardingStatus={'NOT_READY'} />);
await renderWithStore(
<GlobalWrites shardingStatus={ShardingStatuses.NOT_READY} />
);
expect(screen.getByText(/loading/i)).to.exist;
});

it('renders plugin in UNSHARDED state', async function () {
await renderWithStore(<GlobalWrites shardingStatus={'UNSHARDED'} />);
await renderWithStore(
<GlobalWrites shardingStatus={ShardingStatuses.UNSHARDED} />
);
expect(screen.getByTestId('shard-collection-button')).to.exist;
});

it('renders plugin in SHARDING state', async function () {
await renderWithStore(<GlobalWrites shardingStatus={'SHARDING'} />);
await renderWithStore(
<GlobalWrites shardingStatus={ShardingStatuses.SHARDING} />
);
expect(screen.getByText(/sharding your collection/i)).to.exist;
});
});
8 changes: 4 additions & 4 deletions packages/compass-global-writes/src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SpinLoaderWithLabel,
ConfirmationModalArea,
} from '@mongodb-js/compass-components';
import type { RootState, ShardingStatus } from '../store/reducer';
import type { RootState } from '../store/reducer';
import { ShardingStatuses } from '../store/reducer';
import UnshardedState from './states/unsharded';
import ShardingState from './states/sharding';
Expand Down Expand Up @@ -36,13 +36,13 @@ const loaderStyles = css({
});

type GlobalWritesProps = {
shardingStatus: ShardingStatus;
shardingStatus: ShardingStatuses;
};

function ShardingStateView({
shardingStatus,
}: {
shardingStatus: Exclude<ShardingStatus, 'NOT_READY'>;
shardingStatus: Exclude<ShardingStatuses, 'NOT_READY'>;
}) {
if (shardingStatus === ShardingStatuses.UNSHARDED) {
return <UnshardedState />;
Expand Down Expand Up @@ -72,7 +72,7 @@ function ShardingStateView({
return <IncompleteShardingSetup />;
}

if (shardingStatus === String(ShardingStatuses.LOADING_ERROR)) {
if (shardingStatus === ShardingStatuses.LOADING_ERROR) {
return <LoadingError />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { RootState } from '../../modules';
import type { Document } from 'mongodb';
import { CompassExperimentationProvider } from '@mongodb-js/compass-telemetry';
import { ExperimentTestGroup } from '@mongodb-js/compass-telemetry/provider';
import { FetchStatuses } from '../../utils/fetch-status';

const renderIndexes = async (
options: Partial<IndexesPluginOptions> = {},
Expand Down Expand Up @@ -82,7 +83,7 @@ describe('Indexes Component', function () {
regularIndexes: {
indexes: [],
error: 'Some random error',
status: 'ERROR',
status: FetchStatuses.ERROR,
inProgressIndexes: [],
},
});
Expand Down Expand Up @@ -124,7 +125,7 @@ describe('Indexes Component', function () {
await renderIndexes(undefined, undefined, {
indexView: 'regular-indexes',
regularIndexes: {
status: 'NOT_READY',
status: FetchStatuses.NOT_READY,
inProgressIndexes: [],
indexes: [],
},
Expand Down Expand Up @@ -161,7 +162,7 @@ describe('Indexes Component', function () {
},
] as RegularIndex[],
error: undefined,
status: 'READY',
status: FetchStatuses.READY,
inProgressIndexes: [],
},
});
Expand Down Expand Up @@ -211,7 +212,7 @@ describe('Indexes Component', function () {
},
],
error: undefined,
status: 'READY',
status: FetchStatuses.READY,
},
});

Expand Down Expand Up @@ -269,7 +270,7 @@ describe('Indexes Component', function () {
},
],
error: undefined,
status: 'READY',
status: FetchStatuses.READY,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { VIEW_PIPELINE_UTILS } from '@mongodb-js/mongodb-constants';
import type { State as RegularIndexesState } from '../../modules/regular-indexes';
import type { State as SearchIndexesState } from '../../modules/search-indexes';
import { FetchStatuses } from '../../utils/fetch-status';
import type { FetchStatus } from '../../utils/fetch-status';
import type { RootState } from '../../modules';
import {
CreateSearchIndexModal,
Expand Down Expand Up @@ -174,7 +173,7 @@ type IndexesProps = {
collectionStats: CollectionStats;
};

function isRefreshingStatus(status: FetchStatus) {
function isRefreshingStatus(status: FetchStatuses) {
return (
status === FetchStatuses.FETCHING || status === FetchStatuses.REFRESHING
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const renderIndexList = (
<SearchIndexesTable
namespace="foo.bar"
indexes={indexes}
status="READY"
status={FetchStatuses.READY}
isWritable={true}
isReadonlyView={false}
onDropIndexClick={noop}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
startPollingSearchIndexes,
stopPollingSearchIndexes,
} from '../../modules/search-indexes';
import type { FetchStatus } from '../../utils/fetch-status';
import { IndexesTable } from '../indexes-table';
import SearchIndexActions from './search-index-actions';
import { ZeroGraphic } from './zero-graphic';
Expand All @@ -48,15 +47,15 @@ type SearchIndexesTableProps = {
isWritable?: boolean;
isReadonlyView: boolean;
collectionStats?: CollectionStats;
status: FetchStatus;
status: FetchStatuses;
onDropIndexClick: (name: string) => void;
onEditIndexClick: (name: string) => void;
onOpenCreateModalClick: () => void;
onSearchIndexesOpened: (tabId: string) => void;
onSearchIndexesClosed: (tabId: string) => void;
};

function isReadyStatus(status: FetchStatus) {
function isReadyStatus(status: FetchStatuses) {
return (
status === FetchStatuses.READY ||
status === FetchStatuses.REFRESHING ||
Expand Down
10 changes: 4 additions & 6 deletions packages/compass-indexes/src/modules/regular-indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {
} from '@mongodb-js/compass-components';

import { FetchStatuses, NOT_FETCHABLE_STATUSES } from '../utils/fetch-status';
import type { FetchStatus } from '../utils/fetch-status';
import { FetchReasons } from '../utils/fetch-reason';
import type { FetchReason } from '../utils/fetch-reason';
import { isAction } from '../utils/is-action';
import type { CreateIndexSpec } from './create-index';
import type { IndexesThunkAction, RootState } from '.';
Expand Down Expand Up @@ -131,7 +129,7 @@ type IndexesClosedAction = {

type FetchIndexesStartedAction = {
type: ActionTypes.FetchIndexesStarted;
reason: FetchReason;
reason: FetchReasons;
};

type FetchIndexesSucceededAction = {
Expand Down Expand Up @@ -172,7 +170,7 @@ type RollingIndexTimeoutCheckAction = {
};

export type State = {
status: FetchStatus;
status: FetchStatuses;
indexes: RegularIndex[];
inProgressIndexes: InProgressIndex[];
rollingIndexes?: RollingIndex[];
Expand Down Expand Up @@ -347,7 +345,7 @@ export default function reducer(
}

const fetchIndexesStarted = (
reason: FetchReason
reason: FetchReasons
): FetchIndexesStartedAction => ({
type: ActionTypes.FetchIndexesStarted,
reason,
Expand Down Expand Up @@ -381,7 +379,7 @@ function pickCollectionStatFields(state: RootState) {
}

const fetchIndexes = (
reason: FetchReason
reason: FetchReasons
): IndexesThunkAction<Promise<void>, FetchIndexesActions> => {
return async (
dispatch,
Expand Down
10 changes: 4 additions & 6 deletions packages/compass-indexes/src/modules/search-indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import type { SearchIndex } from 'mongodb-data-service';

import { isAction } from '../utils/is-action';
import { FetchStatuses, NOT_FETCHABLE_STATUSES } from '../utils/fetch-status';
import type { FetchStatus } from '../utils/fetch-status';

import { FetchReasons } from '../utils/fetch-reason';
import type { FetchReason } from '../utils/fetch-reason';

import type { IndexesThunkAction } from '.';
import { switchToSearchIndexes } from './index-view';
Expand Down Expand Up @@ -49,7 +47,7 @@ export enum ActionTypes {

type FetchSearchIndexesStartedAction = {
type: ActionTypes.FetchSearchIndexesStarted;
reason: FetchReason;
reason: FetchReasons;
};

type FetchSearchIndexesSucceededAction = {
Expand Down Expand Up @@ -119,7 +117,7 @@ type UpdateSearchIndexState = {
};

export type State = {
status: FetchStatus;
status: FetchStatuses;
createIndex: CreateSearchIndexState;
updateIndex: UpdateSearchIndexState;
error?: string;
Expand Down Expand Up @@ -377,7 +375,7 @@ export const updateSearchIndexClosed = (): UpdateSearchIndexClosedAction => ({
});

const fetchSearchIndexesStarted = (
reason: FetchReason
reason: FetchReasons
): FetchSearchIndexesStartedAction => ({
type: ActionTypes.FetchSearchIndexesStarted,
reason,
Expand Down Expand Up @@ -597,7 +595,7 @@ type FetchSearchIndexesActions =
| FetchSearchIndexesFailedAction;

const fetchIndexes = (
reason: FetchReason
reason: FetchReasons
): IndexesThunkAction<Promise<void>, FetchSearchIndexesActions> => {
return async (dispatch, getState, { dataService }) => {
const {
Expand Down
Loading