diff --git a/src/Common/dataAccess/getIndexTransformationProgress.ts b/src/Common/dataAccess/getIndexTransformationProgress.ts new file mode 100644 index 000000000..1c08fe847 --- /dev/null +++ b/src/Common/dataAccess/getIndexTransformationProgress.ts @@ -0,0 +1,28 @@ +import { client } from "../CosmosClient"; +import { handleError } from "../ErrorHandlingUtils"; +import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils"; +import * as Constants from "../Constants"; +import { AuthType } from "../../AuthType"; + +export async function getIndexTransformationProgress(databaseId: string, collectionId: string): Promise { + if (window.authType !== AuthType.AAD) { + return undefined; + } + let indexTransformationPercentage: number; + const clearMessage = logConsoleProgress(`Reading container ${collectionId}`); + try { + const response = await client() + .database(databaseId) + .container(collectionId) + .read({ populateQuotaInfo: true }); + + indexTransformationPercentage = parseInt( + response.headers[Constants.HttpHeaders.collectionIndexTransformationProgress] as string + ); + } catch (error) { + handleError(error, `Error while reading container ${collectionId}`, "ReadMongoDBCollection"); + throw error; + } + clearMessage(); + return indexTransformationPercentage; +} diff --git a/src/Common/dataAccess/readMongoDBCollection.tsx b/src/Common/dataAccess/readMongoDBCollection.tsx index 9d7123bda..80013cf94 100644 --- a/src/Common/dataAccess/readMongoDBCollection.tsx +++ b/src/Common/dataAccess/readMongoDBCollection.tsx @@ -2,8 +2,6 @@ import { userContext } from "../../UserContext"; import { getMongoDBCollection } from "../../Utils/arm/generatedClients/2020-04-01/mongoDBResources"; import { MongoDBCollectionResource } from "../../Utils/arm/generatedClients/2020-04-01/types"; import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils"; -import * as Constants from "../Constants"; -import { client } from "../CosmosClient"; import { handleError } from "../ErrorHandlingUtils"; import { AuthType } from "../../AuthType"; @@ -30,29 +28,3 @@ export async function readMongoDBCollectionThroughRP( clearMessage(); return collection; } - -export async function getMongoDBCollectionIndexTransformationProgress( - databaseId: string, - collectionId: string -): Promise { - if (window.authType !== AuthType.AAD) { - return undefined; - } - let indexTransformationPercentage: number; - const clearMessage = logConsoleProgress(`Reading container ${collectionId}`); - try { - const response = await client() - .database(databaseId) - .container(collectionId) - .read({ populateQuotaInfo: true }); - - indexTransformationPercentage = parseInt( - response.headers[Constants.HttpHeaders.collectionIndexTransformationProgress] as string - ); - } catch (error) { - handleError(error, `Error while reading container ${collectionId}`, "ReadMongoDBCollection"); - throw error; - } - clearMessage(); - return indexTransformationPercentage; -} diff --git a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx index 9d862864c..d4a3b1ec1 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx @@ -8,8 +8,8 @@ import * as DataModels from "../../../Contracts/DataModels"; import ko from "knockout"; import { TtlType, isDirty } from "./SettingsUtils"; import Explorer from "../../Explorer"; -jest.mock("../../../Common/dataAccess/readMongoDBCollection", () => ({ - getMongoDBCollectionIndexTransformationProgress: jest.fn().mockReturnValue(undefined) +jest.mock("../../../Common/dataAccess/getIndexTransformationProgress", () => ({ + getIndexTransformationProgress: jest.fn().mockReturnValue(undefined) })); import { updateCollection, updateMongoDBCollectionThroughRP } from "../../../Common/dataAccess/updateCollection"; jest.mock("../../../Common/dataAccess/updateCollection", () => ({ diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index 2966e1cf8..878804b22 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -46,10 +46,8 @@ import { Pivot, PivotItem, IPivotProps, IPivotItemProps } from "office-ui-fabric import "./SettingsComponent.less"; import { IndexingPolicyComponent, IndexingPolicyComponentProps } from "./SettingsSubComponents/IndexingPolicyComponent"; import { MongoDBCollectionResource, MongoIndex } from "../../../Utils/arm/generatedClients/2020-04-01/types"; -import { - getMongoDBCollectionIndexTransformationProgress, - readMongoDBCollectionThroughRP -} from "../../../Common/dataAccess/readMongoDBCollection"; +import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readMongoDBCollection"; +import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress"; import { getErrorMessage } from "../../../Common/ErrorHandlingUtils"; interface SettingsV2TabInfo { @@ -212,6 +210,7 @@ export class SettingsComponent extends React.Component => { - const currentProgress = await getMongoDBCollectionIndexTransformationProgress( - this.collection.databaseId, - this.collection.id() - ); + const currentProgress = await getIndexTransformationProgress(this.collection.databaseId, this.collection.id()); this.setState({ indexTransformationProgress: currentProgress }); }; @@ -352,6 +346,7 @@ export class SettingsComponent extends React.Component ); -export const indexingPolicyTTLWarningMessage: JSX.Element = ( +export const indexingPolicynUnsavedWarningMessage: JSX.Element = ( - Changing the Indexing Policy impacts query results while the index transformation occurs. When a change is made and - the indexing mode is set to consistent or lazy, queries return eventual results until the operation completes. For - more information see,{" "} - - Modifying Indexing Policies - - . + You have not saved the latest changes made to your indexing policy. Please click save to confirm the changes. ); @@ -410,8 +404,8 @@ export const mongoIndexingPolicyAADError: JSX.Element = ( export const mongoIndexTransformationRefreshingMessage: JSX.Element = ( - Refreshing index transformation progress - + Refreshing index transformation progress + ); @@ -421,14 +415,14 @@ export const renderMongoIndexTransformationRefreshMessage = ( ): JSX.Element => { if (progress === 0) { return ( - + {"You can make more indexing changes once the current index transformation is complete. "} {"Refresh to check if it has completed."} ); } else { return ( - + {`You can make more indexing changes once the current index transformation has completed. It is ${progress}% complete. `} {"Refresh to check the progress."} diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.test.tsx index 38d192f6c..a232c6ee4 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.test.tsx @@ -25,7 +25,9 @@ describe("IndexingPolicyComponent", () => { }, onIndexingPolicyDirtyChange: () => { return; - } + }, + indexTransformationProgress: undefined, + refreshIndexTransformationProgress: () => new Promise(jest.fn()) }; it("renders", () => { diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.tsx index f1dede13a..992a92b47 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyComponent.tsx @@ -1,9 +1,10 @@ import * as React from "react"; import * as DataModels from "../../../../Contracts/DataModels"; import * as monaco from "monaco-editor"; -import { isDirty } from "../SettingsUtils"; +import { isDirty, isIndexTransforming } from "../SettingsUtils"; import { MessageBar, MessageBarType, Stack } from "office-ui-fabric-react"; -import { indexingPolicyTTLWarningMessage, titleAndInputStackProps } from "../SettingsRenderUtils"; +import { indexingPolicynUnsavedWarningMessage, titleAndInputStackProps } from "../SettingsRenderUtils"; +import { IndexingPolicyRefreshComponent } from "./IndexingPolicyRefresh/IndexingPolicyRefreshComponent"; export interface IndexingPolicyComponentProps { shouldDiscardIndexingPolicy: boolean; @@ -12,6 +13,8 @@ export interface IndexingPolicyComponentProps { indexingPolicyContentBaseline: DataModels.IndexingPolicy; onIndexingPolicyContentChange: (newIndexingPolicy: DataModels.IndexingPolicy) => void; logIndexingPolicySuccessMessage: () => void; + indexTransformationProgress: number; + refreshIndexTransformationProgress: () => Promise; onIndexingPolicyDirtyChange: (isIndexingPolicyDirty: boolean) => void; } @@ -51,6 +54,9 @@ export class IndexingPolicyComponent extends React.Component< if (!this.indexingPolicyEditor) { this.createIndexingPolicyEditor(); } else { + this.indexingPolicyEditor.updateOptions({ + readOnly: isIndexTransforming(this.props.indexTransformationProgress) + }); const indexingPolicyEditorModel = this.indexingPolicyEditor.getModel(); const value: string = JSON.stringify(this.props.indexingPolicyContent, undefined, 4); indexingPolicyEditorModel.setValue(value); @@ -84,7 +90,7 @@ export class IndexingPolicyComponent extends React.Component< this.indexingPolicyEditor = monaco.editor.create(this.indexingPolicyDiv.current, { value: value, language: "json", - readOnly: false, + readOnly: isIndexTransforming(this.props.indexTransformationProgress), ariaLabel: "Indexing Policy" }); if (this.indexingPolicyEditor) { @@ -108,8 +114,12 @@ export class IndexingPolicyComponent extends React.Component< public render(): JSX.Element { return ( + {isDirty(this.props.indexingPolicyContent, this.props.indexingPolicyContentBaseline) && ( - {indexingPolicyTTLWarningMessage} + {indexingPolicynUnsavedWarningMessage} )}
diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/IndexingPolicyRefreshComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/IndexingPolicyRefreshComponent.test.tsx new file mode 100644 index 000000000..2e0da86de --- /dev/null +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/IndexingPolicyRefreshComponent.test.tsx @@ -0,0 +1,15 @@ +import { shallow } from "enzyme"; +import React from "react"; +import { IndexingPolicyRefreshComponentProps, IndexingPolicyRefreshComponent } from "./IndexingPolicyRefreshComponent"; + +describe("IndexingPolicyRefreshComponent", () => { + it("renders", () => { + const props: IndexingPolicyRefreshComponentProps = { + indexTransformationProgress: 90, + refreshIndexTransformationProgress: () => new Promise(jest.fn()) + }; + + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/IndexingPolicyRefreshComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/IndexingPolicyRefreshComponent.tsx new file mode 100644 index 000000000..0f497fc22 --- /dev/null +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/IndexingPolicyRefreshComponent.tsx @@ -0,0 +1,62 @@ +import * as React from "react"; +import { MessageBar, MessageBarType } from "office-ui-fabric-react"; +import { + mongoIndexTransformationRefreshingMessage, + renderMongoIndexTransformationRefreshMessage +} from "../../SettingsRenderUtils"; +import { handleError } from "../../../../../Common/ErrorHandlingUtils"; +import { isIndexTransforming } from "../../SettingsUtils"; + +export interface IndexingPolicyRefreshComponentProps { + indexTransformationProgress: number; + refreshIndexTransformationProgress: () => Promise; +} + +interface IndexingPolicyRefreshComponentState { + isRefreshing: boolean; +} + +export class IndexingPolicyRefreshComponent extends React.Component< + IndexingPolicyRefreshComponentProps, + IndexingPolicyRefreshComponentState +> { + constructor(props: IndexingPolicyRefreshComponentProps) { + super(props); + this.state = { + isRefreshing: false + }; + } + + private onClickRefreshIndexingTransformationLink = async () => await this.refreshIndexTransformationProgress(); + + private renderIndexTransformationWarning = (): JSX.Element => { + if (this.state.isRefreshing) { + return mongoIndexTransformationRefreshingMessage; + } else if (isIndexTransforming(this.props.indexTransformationProgress)) { + return renderMongoIndexTransformationRefreshMessage( + this.props.indexTransformationProgress, + this.onClickRefreshIndexingTransformationLink + ); + } + return undefined; + }; + + private refreshIndexTransformationProgress = async () => { + this.setState({ isRefreshing: true }); + try { + await this.props.refreshIndexTransformationProgress(); + } catch (error) { + handleError(error, "Refreshing index transformation progress failed.", "RefreshIndexTransformationProgress"); + } finally { + this.setState({ isRefreshing: false }); + } + }; + + public render(): JSX.Element { + return this.renderIndexTransformationWarning() ? ( + {this.renderIndexTransformationWarning()} + ) : ( + <> + ); + } +} diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/__snapshots__/IndexingPolicyRefreshComponent.test.tsx.snap b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/__snapshots__/IndexingPolicyRefreshComponent.test.tsx.snap new file mode 100644 index 000000000..1c44dd435 --- /dev/null +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/IndexingPolicyRefresh/__snapshots__/IndexingPolicyRefreshComponent.test.tsx.snap @@ -0,0 +1,24 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`IndexingPolicyRefreshComponent renders 1`] = ` + + + You can make more indexing changes once the current index transformation has completed. It is 90% complete. + + Refresh to check the progress. + + + +`; diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.test.tsx index 246bc8186..95ca5eef1 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.test.tsx @@ -2,6 +2,7 @@ import { shallow } from "enzyme"; import React from "react"; import { MongoIndexTypes, MongoNotificationMessage, MongoNotificationType } from "../../SettingsUtils"; import { MongoIndexingPolicyComponent, MongoIndexingPolicyComponentProps } from "./MongoIndexingPolicyComponent"; +import { renderToString } from "react-dom/server"; describe("MongoIndexingPolicyComponent", () => { const baseProps: MongoIndexingPolicyComponentProps = { @@ -21,10 +22,7 @@ describe("MongoIndexingPolicyComponent", () => { return; }, indexTransformationProgress: undefined, - refreshIndexTransformationProgress: () => - new Promise(() => { - return; - }), + refreshIndexTransformationProgress: () => new Promise(jest.fn()), onMongoIndexingPolicySaveableChange: () => { return; }, @@ -38,16 +36,6 @@ describe("MongoIndexingPolicyComponent", () => { expect(wrapper).toMatchSnapshot(); }); - it("isIndexingTransforming", () => { - const wrapper = shallow(); - const mongoIndexingPolicyComponent = wrapper.instance() as MongoIndexingPolicyComponent; - expect(mongoIndexingPolicyComponent.isIndexingTransforming()).toEqual(false); - wrapper.setProps({ indexTransformationProgress: 50 }); - expect(mongoIndexingPolicyComponent.isIndexingTransforming()).toEqual(true); - wrapper.setProps({ indexTransformationProgress: 100 }); - expect(mongoIndexingPolicyComponent.isIndexingTransforming()).toEqual(false); - }); - describe("AddMongoIndexProps test", () => { const wrapper = shallow(); const mongoIndexingPolicyComponent = wrapper.instance() as MongoIndexingPolicyComponent; @@ -55,7 +43,7 @@ describe("MongoIndexingPolicyComponent", () => { it("defaults", () => { expect(mongoIndexingPolicyComponent.isMongoIndexingPolicySaveable()).toEqual(false); expect(mongoIndexingPolicyComponent.isMongoIndexingPolicyDiscardable()).toEqual(false); - expect(mongoIndexingPolicyComponent.getMongoWarningNotificationMessage()).toEqual(undefined); + expect(mongoIndexingPolicyComponent.getMongoWarningNotificationMessage()).toBeUndefined(); }); const sampleWarning = "sampleWarning"; @@ -113,9 +101,12 @@ describe("MongoIndexingPolicyComponent", () => { expect(mongoIndexingPolicyComponent.isMongoIndexingPolicyDiscardable()).toEqual( isMongoIndexingPolicyDiscardable ); - expect(mongoIndexingPolicyComponent.getMongoWarningNotificationMessage()).toEqual( - mongoWarningNotificationMessage - ); + if (mongoWarningNotificationMessage) { + const elementAsString = renderToString(mongoIndexingPolicyComponent.getMongoWarningNotificationMessage()); + expect(elementAsString).toContain(mongoWarningNotificationMessage); + } else { + expect(mongoIndexingPolicyComponent.getMongoWarningNotificationMessage()).toBeUndefined(); + } } ); }); diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.tsx index cc9c25794..435cec265 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent.tsx @@ -25,8 +25,8 @@ import { createAndAddMongoIndexStackProps, separatorStyles, mongoIndexingPolicyAADError, - mongoIndexTransformationRefreshingMessage, - renderMongoIndexTransformationRefreshMessage + indexingPolicynUnsavedWarningMessage, + infoAndToolTipTextStyle } from "../../SettingsRenderUtils"; import { MongoIndex } from "../../../../../Utils/arm/generatedClients/2020-04-01/types"; import { @@ -35,12 +35,13 @@ import { MongoIndexIdField, MongoNotificationType, getMongoIndexType, - getMongoIndexTypeText + getMongoIndexTypeText, + isIndexTransforming } from "../../SettingsUtils"; import { AddMongoIndexComponent } from "./AddMongoIndexComponent"; import { CollapsibleSectionComponent } from "../../../CollapsiblePanel/CollapsibleSectionComponent"; -import { handleError } from "../../../../../Common/ErrorHandlingUtils"; import { AuthType } from "../../../../../AuthType"; +import { IndexingPolicyRefreshComponent } from "../IndexingPolicyRefresh/IndexingPolicyRefreshComponent"; export interface MongoIndexingPolicyComponentProps { mongoIndexes: MongoIndex[]; @@ -56,20 +57,13 @@ export interface MongoIndexingPolicyComponentProps { onMongoIndexingPolicyDiscardableChange: (isMongoIndexingPolicyDiscardable: boolean) => void; } -interface MongoIndexingPolicyComponentState { - isRefreshingIndexTransformationProgress: boolean; -} - interface MongoIndexDisplayProps { definition: JSX.Element; type: JSX.Element; actionButton: JSX.Element; } -export class MongoIndexingPolicyComponent extends React.Component< - MongoIndexingPolicyComponentProps, - MongoIndexingPolicyComponentState -> { +export class MongoIndexingPolicyComponent extends React.Component { private shouldCheckComponentIsDirty = true; private addMongoIndexComponentRefs: React.RefObject[] = []; private initialIndexesColumns: IColumn[] = [ @@ -98,13 +92,6 @@ export class MongoIndexingPolicyComponent extends React.Component< } ]; - constructor(props: MongoIndexingPolicyComponentProps) { - super(props); - this.state = { - isRefreshingIndexTransformationProgress: false - }; - } - componentDidUpdate(prevProps: MongoIndexingPolicyComponentProps): void { if (this.props.indexesToAdd.length > prevProps.indexesToAdd.length) { this.addMongoIndexComponentRefs[prevProps.indexesToAdd.length]?.current?.focus(); @@ -144,10 +131,15 @@ export class MongoIndexingPolicyComponent extends React.Component< return this.props.indexesToAdd.length > 0 || this.props.indexesToDrop.length > 0; }; - public getMongoWarningNotificationMessage = (): string => { - return this.props.indexesToAdd.find( + public getMongoWarningNotificationMessage = (): JSX.Element => { + const warningMessage = this.props.indexesToAdd.find( addMongoIndexProps => addMongoIndexProps.notification?.type === MongoNotificationType.Warning )?.notification.message; + + if (warningMessage) { + return {warningMessage}; + } + return undefined; }; private onRenderRow = (props: IDetailsRowProps): JSX.Element => { @@ -159,7 +151,7 @@ export class MongoIndexingPolicyComponent extends React.Component< { this.props.onIndexDrop(arrayPosition); }} @@ -230,7 +222,7 @@ export class MongoIndexingPolicyComponent extends React.Component< { - this.setState({ isRefreshingIndexTransformationProgress: true }); - try { - await this.props.refreshIndexTransformationProgress(); - } catch (error) { - handleError(error, "Refreshing index transformation progress failed.", "RefreshIndexTransformationProgress"); - } finally { - this.setState({ isRefreshingIndexTransformationProgress: false }); - } - }; - - public isIndexingTransforming = (): boolean => - // index transformation progress can be 0 - this.props.indexTransformationProgress !== undefined && this.props.indexTransformationProgress !== 100; - - private onClickRefreshIndexingTransformationLink = async () => await this.refreshIndexTransformationProgress(); - - private renderIndexTransformationWarning = (): JSX.Element => { - if (this.state.isRefreshingIndexTransformationProgress) { - return mongoIndexTransformationRefreshingMessage; - } else if (this.isIndexingTransforming()) { - return renderMongoIndexTransformationRefreshMessage( - this.props.indexTransformationProgress, - this.onClickRefreshIndexingTransformationLink - ); - } - return undefined; - }; - private renderWarningMessage = (): JSX.Element => { - let warningMessage: string; + let warningMessage: JSX.Element; if (this.getMongoWarningNotificationMessage()) { warningMessage = this.getMongoWarningNotificationMessage(); } else if (this.isMongoIndexingPolicySaveable()) { - warningMessage = - "You have not saved the latest changes made to your indexing policy. Please click save to confirm the changes."; + warningMessage = indexingPolicynUnsavedWarningMessage; } return ( <> - {this.renderIndexTransformationWarning() && ( - {this.renderIndexTransformationWarning()} - )} - - {warningMessage && ( - - {warningMessage} - - )} + + {warningMessage && {warningMessage}} ); }; diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/__snapshots__/MongoIndexingPolicyComponent.test.tsx.snap b/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/__snapshots__/MongoIndexingPolicyComponent.test.tsx.snap index ab19cbb45..577fa2862 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/__snapshots__/MongoIndexingPolicyComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/MongoIndexingPolicy/__snapshots__/MongoIndexingPolicyComponent.test.tsx.snap @@ -8,6 +8,9 @@ exports[`MongoIndexingPolicyComponent renders 1`] = ` } } > + For queries that filter on multiple properties, create multiple single field indexes instead of a compound index. +
{ expect(notification.type).toEqual(MongoNotificationType.Error); }); }); + +it("isIndexingTransforming", () => { + expect(isIndexTransforming(undefined)).toBeFalsy(); + expect(isIndexTransforming(0)).toBeTruthy(); + expect(isIndexTransforming(90)).toBeTruthy(); + expect(isIndexTransforming(100)).toBeFalsy(); +}); diff --git a/src/Explorer/Controls/Settings/SettingsUtils.tsx b/src/Explorer/Controls/Settings/SettingsUtils.tsx index 556df274f..9e29b73fe 100644 --- a/src/Explorer/Controls/Settings/SettingsUtils.tsx +++ b/src/Explorer/Controls/Settings/SettingsUtils.tsx @@ -250,3 +250,7 @@ export const getMongoIndexTypeText = (index: MongoIndexTypes): string => { } return WildcardText; }; + +export const isIndexTransforming = (indexTransformationProgress: number): boolean => + // index transformation progress can be 0 + indexTransformationProgress !== undefined && indexTransformationProgress !== 100; diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index 1a0a9747b..db28fa5a8 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -5189,6 +5189,7 @@ exports[`SettingsComponent renders 1`] = ` logIndexingPolicySuccessMessage={[Function]} onIndexingPolicyContentChange={[Function]} onIndexingPolicyDirtyChange={[Function]} + refreshIndexTransformationProgress={[Function]} resetShouldDiscardIndexingPolicy={[Function]} shouldDiscardIndexingPolicy={false} /> diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsRenderUtils.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsRenderUtils.test.tsx.snap index 77b4fc444..90e5c8af8 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsRenderUtils.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsRenderUtils.test.tsx.snap @@ -166,15 +166,7 @@ exports[`SettingsUtils functions render 1`] = ` } } > - Changing the Indexing Policy impacts query results while the index transformation occurs. When a change is made and the indexing mode is set to consistent or lazy, queries return eventual results until the operation completes. For more information see, - - - Modifying Indexing Policies - - . + You have not saved the latest changes made to your indexing policy. Please click save to confirm the changes. - + Refreshing index transformation progress - + You can make more indexing changes once the current index transformation is complete. - + You can make more indexing changes once the current index transformation has completed. It is 90% complete.