Added message to indicate compound indexes are not supported in Mongo Index editor (#395)
* mongo message * Added test and bug fix in Main.tsx * format changes * added new formatting * added null check
This commit is contained in:
parent
1ecc467f60
commit
a298fd8389
|
@ -441,6 +441,13 @@ export const mongoIndexingPolicyDisclaimer: JSX.Element = (
|
|||
</Text>
|
||||
);
|
||||
|
||||
export const mongoCompoundIndexNotSupportedMessage: JSX.Element = (
|
||||
<Text>
|
||||
Collections with compound indexes are not yet supported in the indexing editor. To modify indexing policy for this
|
||||
collection, use the Mongo Shell.
|
||||
</Text>
|
||||
);
|
||||
|
||||
export const mongoIndexingPolicyAADError: JSX.Element = (
|
||||
<MessageBar messageBarType={MessageBarType.error}>
|
||||
<Text>
|
||||
|
|
|
@ -36,6 +36,14 @@ describe("MongoIndexingPolicyComponent", () => {
|
|||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("error shown for collection with compound indexes", () => {
|
||||
const props = { ...baseProps, mongoIndexes: [{ key: { keys: ["prop1", "prop2"] } }] };
|
||||
const wrapper = shallow(<MongoIndexingPolicyComponent {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
const mongoIndexingPolicyComponent = wrapper.instance() as MongoIndexingPolicyComponent;
|
||||
expect(mongoIndexingPolicyComponent.hasCompoundIndex()).toBeTruthy();
|
||||
});
|
||||
|
||||
describe("AddMongoIndexProps test", () => {
|
||||
const wrapper = shallow(<MongoIndexingPolicyComponent {...baseProps} />);
|
||||
const mongoIndexingPolicyComponent = wrapper.instance() as MongoIndexingPolicyComponent;
|
||||
|
|
|
@ -24,6 +24,7 @@ import {
|
|||
indexingPolicynUnsavedWarningMessage,
|
||||
infoAndToolTipTextStyle,
|
||||
onRenderRow,
|
||||
mongoCompoundIndexNotSupportedMessage,
|
||||
} from "../../SettingsRenderUtils";
|
||||
import { MongoIndex } from "../../../../../Utils/arm/generatedClients/2020-04-01/types";
|
||||
import {
|
||||
|
@ -282,6 +283,15 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
|
|||
);
|
||||
};
|
||||
|
||||
public hasCompoundIndex = (): boolean => {
|
||||
for (let index = 0; index < this.props.mongoIndexes.length; index++) {
|
||||
if (this.props.mongoIndexes[index].key?.keys?.length > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
private renderWarningMessage = (): JSX.Element => {
|
||||
let warningMessage: JSX.Element;
|
||||
if (this.getMongoWarningNotificationMessage()) {
|
||||
|
@ -303,6 +313,9 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
|
|||
|
||||
public render(): JSX.Element {
|
||||
if (this.props.mongoIndexes) {
|
||||
if (this.hasCompoundIndex()) {
|
||||
return mongoCompoundIndexNotSupportedMessage;
|
||||
}
|
||||
return (
|
||||
<Stack {...subComponentStackProps}>
|
||||
{this.renderWarningMessage()}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`MongoIndexingPolicyComponent error shown for collection with compound indexes 1`] = `
|
||||
<Text>
|
||||
Collections with compound indexes are not yet supported in the indexing editor. To modify indexing policy for this collection, use the Mongo Shell.
|
||||
</Text>
|
||||
`;
|
||||
|
||||
exports[`MongoIndexingPolicyComponent renders 1`] = `
|
||||
<Stack
|
||||
tokens={
|
||||
|
|
|
@ -242,6 +242,7 @@ const App: React.FunctionComponent = () => {
|
|||
explorer.databaseAccount(emulatorAccount);
|
||||
explorer.isAccountReady(true);
|
||||
} else if (config.platform === Platform.Portal) {
|
||||
window.authType = AuthType.AAD;
|
||||
explorer = new Explorer();
|
||||
|
||||
// In development mode, try to load the iframe message from session storage.
|
||||
|
|
Loading…
Reference in New Issue