Remove Explorer.isPreferredAPIMongo (#557)
Co-authored-by: hardiknai-techm <HN00734461@TechMahindra.com>
This commit is contained in:
parent
8f3cb7282b
commit
5a019eb431
|
@ -5,16 +5,16 @@ import * as ViewModels from "../Contracts/ViewModels";
|
|||
import Explorer from "../Explorer/Explorer";
|
||||
import DocumentsTab from "../Explorer/Tabs/DocumentsTab";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import { userContext } from "../UserContext";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import * as QueryUtils from "../Utils/QueryUtils";
|
||||
import { BackendDefaults, HttpStatusCodes, SavedQueries } from "./Constants";
|
||||
import { userContext } from "../UserContext";
|
||||
import { queryDocumentsPage } from "./dataAccess/queryDocumentsPage";
|
||||
import { createCollection } from "./dataAccess/createCollection";
|
||||
import { handleError } from "./ErrorHandlingUtils";
|
||||
import { createDocument } from "./dataAccess/createDocument";
|
||||
import { deleteDocument } from "./dataAccess/deleteDocument";
|
||||
import { queryDocuments } from "./dataAccess/queryDocuments";
|
||||
import { queryDocumentsPage } from "./dataAccess/queryDocumentsPage";
|
||||
import { handleError } from "./ErrorHandlingUtils";
|
||||
|
||||
export class QueriesClient {
|
||||
private static readonly PartitionKey: DataModels.PartitionKey = {
|
||||
|
@ -211,7 +211,7 @@ export class QueriesClient {
|
|||
}
|
||||
|
||||
private fetchQueriesQuery(): string {
|
||||
if (this.container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
return QueriesClient.FetchMongoQuery;
|
||||
}
|
||||
return QueriesClient.FetchQuery;
|
||||
|
|
|
@ -63,7 +63,7 @@ export class ResourceTreeContextMenuButtonFactory {
|
|||
});
|
||||
}
|
||||
|
||||
if (container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
items.push({
|
||||
iconSrc: AddSqlQueryIcon,
|
||||
onClick: () => selectedCollection && selectedCollection.onNewMongoQueryClick(selectedCollection, null),
|
||||
|
|
|
@ -136,15 +136,13 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||
this.container = this.collection?.container;
|
||||
this.offer = this.collection?.offer();
|
||||
this.isAnalyticalStorageEnabled = !!this.collection?.analyticalStorageTtl();
|
||||
this.shouldShowIndexingPolicyEditor =
|
||||
this.container && userContext.apiType !== "Cassandra" && !this.container.isPreferredApiMongoDB();
|
||||
this.shouldShowIndexingPolicyEditor = userContext.apiType !== "Cassandra" && userContext.apiType !== "Mongo";
|
||||
|
||||
this.changeFeedPolicyVisible = userContext.features.enableChangeFeedPolicy;
|
||||
|
||||
// Mongo container with system partition key still treat as "Fixed"
|
||||
this.isFixedContainer =
|
||||
this.container.isPreferredApiMongoDB() &&
|
||||
(!this.collection?.partitionKey || this.collection?.partitionKey.systemKey);
|
||||
userContext.apiType === "Mongo" && (!this.collection?.partitionKey || this.collection?.partitionKey.systemKey);
|
||||
} else {
|
||||
this.database = this.props.settingsTab.database;
|
||||
this.container = this.database?.container;
|
||||
|
@ -236,7 +234,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||
|
||||
public loadMongoIndexes = async (): Promise<void> => {
|
||||
if (
|
||||
this.container.isPreferredApiMongoDB() &&
|
||||
userContext.apiType === "Mongo" &&
|
||||
this.container.isEnableMongoCapabilityPresent() &&
|
||||
this.container.databaseAccount()
|
||||
) {
|
||||
|
@ -1002,7 +1000,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||
tab: SettingsV2TabTypes.IndexingPolicyTab,
|
||||
content: <IndexingPolicyComponent {...indexingPolicyComponentProps} />,
|
||||
});
|
||||
} else if (this.container.isPreferredApiMongoDB()) {
|
||||
} else if (userContext.apiType === "Mongo") {
|
||||
const mongoIndexTabContext = this.getMongoIndexTabContent(mongoIndexingPolicyComponentProps);
|
||||
if (mongoIndexTabContext) {
|
||||
tabs.push({
|
||||
|
|
|
@ -323,7 +323,7 @@ export class SubSettingsComponent extends React.Component<SubSettingsComponentPr
|
|||
userContext.apiType === "Cassandra" ||
|
||||
userContext.apiType === "Tables" ||
|
||||
!this.props.collection.partitionKeyProperty ||
|
||||
(this.props.container.isPreferredApiMongoDB() && this.props.collection.partitionKey.systemKey)
|
||||
(userContext.apiType === "Mongo" && this.props.collection.partitionKey.systemKey)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -458,7 +458,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
@ -974,7 +973,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
@ -1503,7 +1501,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
@ -2019,7 +2016,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
|
|
@ -14,7 +14,6 @@ describe("ContainerSampleGenerator", () => {
|
|||
const createExplorerStub = (database: ViewModels.Database): Explorer => {
|
||||
const explorerStub = {} as Explorer;
|
||||
explorerStub.databases = ko.observableArray<ViewModels.Database>([database]);
|
||||
explorerStub.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
explorerStub.canExceedMaximumValue = ko.computed<boolean>(() => false);
|
||||
explorerStub.findDatabaseWithId = () => database;
|
||||
explorerStub.refreshAllDatabases = () => Q.resolve();
|
||||
|
|
|
@ -118,11 +118,6 @@ export default class Explorer {
|
|||
* Use userContext.apiType instead
|
||||
* */
|
||||
public defaultExperience: ko.Observable<string>;
|
||||
/**
|
||||
* @deprecated
|
||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Mongo"
|
||||
* */
|
||||
public isPreferredApiMongoDB: ko.Computed<boolean>;
|
||||
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
||||
/**
|
||||
* @deprecated
|
||||
|
@ -409,27 +404,6 @@ export default class Explorer {
|
|||
) !== undefined
|
||||
);
|
||||
|
||||
this.isPreferredApiMongoDB = ko.computed(() => {
|
||||
const defaultExperience = (this.defaultExperience && this.defaultExperience()) || "";
|
||||
if (defaultExperience.toLowerCase() === Constants.DefaultAccountExperience.MongoDB.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (defaultExperience.toLowerCase() === Constants.DefaultAccountExperience.ApiForMongoDB.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
this.databaseAccount &&
|
||||
this.databaseAccount() &&
|
||||
this.databaseAccount().kind.toLowerCase() === Constants.AccountKind.MongoDB
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this.isEnableMongoCapabilityPresent = ko.computed(() => {
|
||||
const capabilities = this.databaseAccount && this.databaseAccount()?.properties?.capabilities;
|
||||
if (!capabilities) {
|
||||
|
|
|
@ -29,7 +29,6 @@ export class CommandBarComponentAdapter implements ReactAdapter {
|
|||
|
||||
// These are the parameters watched by the react binding that will trigger a renderComponent() if one of the ko mutates
|
||||
const toWatch = [
|
||||
container.isPreferredApiMongoDB,
|
||||
container.deleteCollectionText,
|
||||
container.deleteDatabaseText,
|
||||
container.addCollectionText,
|
||||
|
|
|
@ -23,7 +23,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
mockExplorer.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
mockExplorer.isSparkEnabled = ko.observable(true);
|
||||
mockExplorer.isSynapseLinkUpdating = ko.observable(false);
|
||||
|
||||
|
@ -67,7 +66,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
mockExplorer.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
mockExplorer.isSynapseLinkUpdating = ko.observable(false);
|
||||
mockExplorer.isSparkEnabled = ko.observable(true);
|
||||
mockExplorer.isSynapseLinkUpdating = ko.observable(false);
|
||||
|
@ -128,6 +126,7 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||
|
||||
beforeAll(() => {
|
||||
mockExplorer = {} as Explorer;
|
||||
mockExplorer.addDatabaseText = ko.observable("mockText");
|
||||
mockExplorer.addCollectionText = ko.observable("mockText");
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
|
@ -143,16 +142,25 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||
mockExplorer.isServerlessEnabled = ko.computed<boolean>(() => false);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
updateUserContext({
|
||||
apiType: "SQL",
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
mockExplorer.isPreferredApiMongoDB = ko.computed<boolean>(() => true);
|
||||
updateUserContext({
|
||||
apiType: "Mongo",
|
||||
});
|
||||
mockExplorer.isNotebookEnabled = ko.observable(false);
|
||||
mockExplorer.isNotebooksEnabledForAccount = ko.observable(false);
|
||||
mockExplorer.isRunningOnNationalCloud = ko.observable(false);
|
||||
});
|
||||
|
||||
it("Mongo Api not available - button should be hidden", () => {
|
||||
mockExplorer.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
|
||||
updateUserContext({
|
||||
apiType: "SQL",
|
||||
});
|
||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer);
|
||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
||||
expect(openMongoShellBtn).toBeUndefined();
|
||||
|
@ -222,7 +230,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
mockExplorer.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
mockExplorer.isSynapseLinkUpdating = ko.observable(false);
|
||||
mockExplorer.isSparkEnabled = ko.observable(true);
|
||||
|
||||
|
@ -321,7 +328,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
mockExplorer.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
|
||||
mockExplorer.isSynapseLinkUpdating = ko.observable(false);
|
||||
mockExplorer.isSparkEnabled = ko.observable(true);
|
||||
|
|
|
@ -70,7 +70,7 @@ export function createStaticCommandBarButtons(container: Explorer): CommandButto
|
|||
buttons.push(createEnableNotebooksButton(container));
|
||||
}
|
||||
|
||||
if (container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
buttons.push(createOpenMongoTerminalButton(container));
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ export function createStaticCommandBarButtons(container: Explorer): CommandButto
|
|||
}
|
||||
|
||||
const isSupportedOpenQueryApi =
|
||||
userContext.apiType === "SQL" || container.isPreferredApiMongoDB() || userContext.apiType === "Gremlin";
|
||||
userContext.apiType === "SQL" || userContext.apiType === "Mongo" || userContext.apiType === "Gremlin";
|
||||
const isSupportedOpenQueryFromDiskApi = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||
if (isSupportedOpenQueryApi && container.selectedNode() && container.findSelectedCollection()) {
|
||||
const openQueryBtn = createOpenQueryButton(container);
|
||||
|
@ -133,7 +133,7 @@ export function createStaticCommandBarButtons(container: Explorer): CommandButto
|
|||
export function createContextCommandBarButtons(container: Explorer): CommandButtonComponentProps[] {
|
||||
const buttons: CommandButtonComponentProps[] = [];
|
||||
|
||||
if (!container.isDatabaseNodeOrNoneSelected() && container.isPreferredApiMongoDB()) {
|
||||
if (!container.isDatabaseNodeOrNoneSelected() && userContext.apiType === "Mongo") {
|
||||
const label = "New Shell";
|
||||
const newMongoShellBtn: CommandButtonComponentProps = {
|
||||
iconSrc: HostedTerminalIcon,
|
||||
|
@ -145,7 +145,7 @@ export function createContextCommandBarButtons(container: Explorer): CommandButt
|
|||
commandButtonLabel: label,
|
||||
ariaLabel: label,
|
||||
hasPopup: true,
|
||||
disabled: container.isDatabaseNodeOrNoneSelected() && container.isPreferredApiMongoDB(),
|
||||
disabled: container.isDatabaseNodeOrNoneSelected() && userContext.apiType === "Mongo",
|
||||
};
|
||||
buttons.push(newMongoShellBtn);
|
||||
}
|
||||
|
|
|
@ -251,10 +251,7 @@
|
|||
</div>
|
||||
|
||||
<!-- Indexing For Shared Throughput - start -->
|
||||
<div
|
||||
class="seconddivpadding"
|
||||
data-bind="visible: showIndexingOptionsForSharedThroughput() && !container.isPreferredApiMongoDB()"
|
||||
>
|
||||
<div class="seconddivpadding" data-bind="visible: showIndexingOptionsForSharedThroughput() && !isMongo()">
|
||||
<div
|
||||
class="useIndexingForSharedThroughput createNewDatabaseOrUseExisting"
|
||||
aria-label="Indexing For Shared Throughput"
|
||||
|
@ -297,7 +294,7 @@
|
|||
|
||||
<p
|
||||
class="seconddivpadding"
|
||||
data-bind="visible: container.isPreferredApiMongoDB() && !databaseHasSharedOffer() || container.isFixedCollectionWithSharedThroughputSupported"
|
||||
data-bind="visible: isMongo() && !databaseHasSharedOffer() || container.isFixedCollectionWithSharedThroughputSupported"
|
||||
>
|
||||
<span class="mandatoryStar">*</span>
|
||||
<span class="addCollectionLabel">Storage capacity</span>
|
||||
|
@ -312,7 +309,7 @@
|
|||
<div class="tabs">
|
||||
<div
|
||||
tabindex="0"
|
||||
data-bind="event: { keydown: onStorageOptionsKeyDown }, visible: container.isPreferredApiMongoDB() && !databaseHasSharedOffer() || container.isFixedCollectionWithSharedThroughputSupported"
|
||||
data-bind="event: { keydown: onStorageOptionsKeyDown }, visible: isMongo() && !databaseHasSharedOffer() || container.isFixedCollectionWithSharedThroughputSupported"
|
||||
aria-label="Storage capacity"
|
||||
>
|
||||
<!-- Fixed option button - Start -->
|
||||
|
|
|
@ -119,7 +119,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
this.isPreferredApiTable = options.isPreferredApiTable;
|
||||
this.partitionKey = ko.observable<string>();
|
||||
this.partitionKey.subscribe((newPartitionKey: string) => {
|
||||
if (this.container.isPreferredApiMongoDB() || !newPartitionKey || newPartitionKey[0] === "/") {
|
||||
if (userContext.apiType === "Mongo" || !newPartitionKey || newPartitionKey[0] === "/") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
|
||||
// TODO: Create derived classes for Tables and Mongo to replace the If statements below
|
||||
this.partitionKeyName = ko.computed<string>(() => {
|
||||
if (this.container && !!this.container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
return "Shard key";
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
this.lowerCasePartitionKeyName = ko.computed<string>(() => this.partitionKeyName().toLowerCase());
|
||||
|
||||
this.partitionKeyPlaceholder = ko.computed<string>(() => {
|
||||
if (this.container && !!this.container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
return "e.g., address.zipCode";
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
});
|
||||
|
||||
this.uniqueKeysPlaceholder = ko.pureComputed<string>(() => {
|
||||
if (this.container && !!this.container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
return "Comma separated paths e.g. firstName,address.zipCode";
|
||||
}
|
||||
|
||||
|
@ -396,11 +396,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
this.container.isPreferredApiMongoDB() &&
|
||||
!this.isUnlimitedStorageSelected() &&
|
||||
this.databaseHasSharedOffer()
|
||||
) {
|
||||
if (userContext.apiType === "Mongo" && !this.isUnlimitedStorageSelected() && this.databaseHasSharedOffer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -589,7 +585,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (this.container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -728,6 +724,10 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
}
|
||||
}
|
||||
|
||||
private isMongo(): boolean {
|
||||
return userContext.apiType === "Mongo";
|
||||
}
|
||||
|
||||
private _onDatabasesChange(newDatabaseIds: ViewModels.Database[]) {
|
||||
this.databaseIds(newDatabaseIds?.map((database: ViewModels.Database) => database.id()));
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
let indexingPolicy: DataModels.IndexingPolicy;
|
||||
let createMongoWildcardIndex: boolean;
|
||||
// todo - remove mongo indexing policy ticket # 616274
|
||||
if (this.container.isPreferredApiMongoDB() && this.container.isEnableMongoCapabilityPresent()) {
|
||||
if (userContext.apiType === "Mongo" && this.container.isEnableMongoCapabilityPresent()) {
|
||||
createMongoWildcardIndex = this.shouldCreateMongoWildcardIndex();
|
||||
} else if (this.showIndexingOptionsForSharedThroughput()) {
|
||||
if (this.useIndexingForSharedThroughput()) {
|
||||
|
@ -1145,7 +1145,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
let transform = (value: string) => {
|
||||
return value;
|
||||
};
|
||||
if (this.container.isPreferredApiMongoDB()) {
|
||||
if (userContext.apiType === "Mongo") {
|
||||
transform = (value: string) => {
|
||||
return this._convertShardKeyToPartitionKey(value);
|
||||
};
|
||||
|
|
|
@ -434,7 +434,6 @@ exports[`Settings Pane should render Default properly 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
@ -1073,7 +1072,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
|
|
@ -437,7 +437,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
@ -952,7 +951,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
|
|
@ -434,7 +434,6 @@ exports[`Upload Items Pane should render Default properly 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
|
|
@ -437,7 +437,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
"isResourceTokenCollectionNodeSelected": [Function],
|
||||
"isRightPanelV2Enabled": [Function],
|
||||
|
|
|
@ -237,7 +237,7 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||
title: "New SQL Query",
|
||||
description: null,
|
||||
});
|
||||
} else if (this.container.isPreferredApiMongoDB()) {
|
||||
} else if (userContext.apiType === "Mongo") {
|
||||
items.push({
|
||||
iconSrc: NewQueryIcon,
|
||||
onClick: () => {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import * as ko from "knockout";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import DocumentsTab from "./DocumentsTab";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import Explorer from "../Explorer";
|
||||
import DocumentId from "../Tree/DocumentId";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import DocumentsTab from "./DocumentsTab";
|
||||
|
||||
describe("Documents tab", () => {
|
||||
describe("buildQuery", () => {
|
||||
|
@ -25,7 +26,6 @@ describe("Documents tab", () => {
|
|||
|
||||
describe("showPartitionKey", () => {
|
||||
const explorer = new Explorer();
|
||||
|
||||
const mongoExplorer = new Explorer();
|
||||
mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB);
|
||||
|
||||
|
@ -124,6 +124,9 @@ describe("Documents tab", () => {
|
|||
});
|
||||
|
||||
it("should be false for Mongo accounts with system partitionKey", () => {
|
||||
updateUserContext({
|
||||
apiType: "Mongo",
|
||||
});
|
||||
const documentsTab = new DocumentsTab({
|
||||
collection: mongoCollectionWithSystemPartitionKey,
|
||||
partitionKey: null,
|
||||
|
|
|
@ -21,6 +21,7 @@ import * as DataModels from "../../Contracts/DataModels";
|
|||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { logConsoleError } from "../../Utils/NotificationConsoleUtils";
|
||||
import * as QueryUtils from "../../Utils/QueryUtils";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
|
@ -71,9 +72,7 @@ export default class DocumentsTab extends TabsBase {
|
|||
|
||||
constructor(options: ViewModels.DocumentsTabOptions) {
|
||||
super(options);
|
||||
this.isPreferredApiMongoDB = !!this.collection
|
||||
? this.collection.container.isPreferredApiMongoDB()
|
||||
: options.isPreferredApiMongoDB;
|
||||
this.isPreferredApiMongoDB = userContext.apiType === "Mongo" || options.isPreferredApiMongoDB;
|
||||
|
||||
this.idHeader = this.isPreferredApiMongoDB ? "_id" : "id";
|
||||
|
||||
|
|
|
@ -31,9 +31,6 @@ describe("Collection", () => {
|
|||
|
||||
function generateMockCollectionWithDataModel(data: DataModels.Collection): Collection {
|
||||
const mockContainer = {} as Explorer;
|
||||
mockContainer.isPreferredApiMongoDB = ko.computed(() => {
|
||||
return false;
|
||||
});
|
||||
|
||||
mockContainer.isDatabaseNodeOrNoneSelected = () => {
|
||||
return false;
|
||||
|
|
|
@ -127,16 +127,12 @@ export default class Collection implements ViewModels.Collection {
|
|||
this.partitionKey.paths[0]) ||
|
||||
null;
|
||||
|
||||
if (!!container.isPreferredApiMongoDB() && this.partitionKeyProperty && ~this.partitionKeyProperty.indexOf(`"`)) {
|
||||
if (userContext.apiType === "Mongo" && this.partitionKeyProperty && ~this.partitionKeyProperty.indexOf(`"`)) {
|
||||
this.partitionKeyProperty = this.partitionKeyProperty.replace(/["]+/g, "");
|
||||
}
|
||||
|
||||
// TODO #10738269 : Add this logic in a derived class for Mongo
|
||||
if (
|
||||
!!container.isPreferredApiMongoDB() &&
|
||||
this.partitionKeyProperty &&
|
||||
this.partitionKeyProperty.indexOf("$v") > -1
|
||||
) {
|
||||
if (userContext.apiType === "Mongo" && this.partitionKeyProperty && this.partitionKeyProperty.indexOf("$v") > -1) {
|
||||
// From $v.shard.$v.key.$v > shard.key
|
||||
this.partitionKeyProperty = this.partitionKeyProperty.replace(/.\$v/g, "").replace(/\$v./g, "");
|
||||
this.partitionKeyPropertyHeader = "/" + this.partitionKeyProperty;
|
||||
|
@ -1123,7 +1119,7 @@ export default class Collection implements ViewModels.Collection {
|
|||
} else if (userContext.apiType === "Gremlin") {
|
||||
this.onGraphDocumentsClick();
|
||||
return;
|
||||
} else if (this.container.isPreferredApiMongoDB()) {
|
||||
} else if (userContext.apiType === "Mongo") {
|
||||
this.onMongoDBDocumentsClick();
|
||||
return;
|
||||
}
|
||||
|
@ -1141,7 +1137,7 @@ export default class Collection implements ViewModels.Collection {
|
|||
return "Rows";
|
||||
} else if (userContext.apiType === "Gremlin") {
|
||||
return "Graph";
|
||||
} else if (this.container.isPreferredApiMongoDB()) {
|
||||
} else if (userContext.apiType === "Mongo") {
|
||||
return "Documents";
|
||||
}
|
||||
|
||||
|
|
|
@ -175,10 +175,7 @@ export class TabRouteHandler {
|
|||
databaseId,
|
||||
collectionId
|
||||
);
|
||||
collection &&
|
||||
collection.container &&
|
||||
collection.container.isPreferredApiMongoDB() &&
|
||||
collection.onMongoDBDocumentsClick();
|
||||
userContext.apiType === "Mongo" && collection.onMongoDBDocumentsClick();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -188,10 +185,7 @@ export class TabRouteHandler {
|
|||
databaseId,
|
||||
collectionId
|
||||
);
|
||||
collection &&
|
||||
collection.container &&
|
||||
collection.container.isPreferredApiMongoDB() &&
|
||||
collection.onSchemaAnalyzerClick();
|
||||
collection && userContext.apiType === "Mongo" && collection.onSchemaAnalyzerClick();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -228,10 +222,7 @@ export class TabRouteHandler {
|
|||
if (!!matchingTab) {
|
||||
matchingTab.onTabClick();
|
||||
} else {
|
||||
collection &&
|
||||
collection.container &&
|
||||
collection.container.isPreferredApiMongoDB() &&
|
||||
collection.onNewMongoQueryClick(collection, null);
|
||||
userContext.apiType === "Mongo" && collection.onNewMongoQueryClick(collection, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -250,10 +241,7 @@ export class TabRouteHandler {
|
|||
if (!!matchingTab) {
|
||||
matchingTab.onTabClick();
|
||||
} else {
|
||||
collection &&
|
||||
collection.container &&
|
||||
collection.container.isPreferredApiMongoDB() &&
|
||||
collection.onNewMongoShellClick();
|
||||
userContext.apiType === "Mongo" && collection.onNewMongoShellClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ interface UserContext {
|
|||
readonly quotaId?: string;
|
||||
// API Type is not yet provided by ARM. You need to manually inspect all the capabilities+kind so we abstract that logic in userContext
|
||||
// This is coming in a future Cosmos ARM API version as a prperty on databaseAccount
|
||||
readonly apiType?: ApiType;
|
||||
apiType?: ApiType;
|
||||
readonly isTryCosmosDBSubscription?: boolean;
|
||||
readonly portalEnv?: PortalEnv;
|
||||
readonly features: Features;
|
||||
|
@ -47,8 +47,10 @@ const userContext: UserContext = {
|
|||
};
|
||||
|
||||
function updateUserContext(newContext: Partial<UserContext>): void {
|
||||
if (newContext.databaseAccount) {
|
||||
newContext.apiType = apiType(newContext.databaseAccount);
|
||||
}
|
||||
Object.assign(userContext, newContext);
|
||||
Object.assign(userContext, { apiType: apiType(userContext.databaseAccount) });
|
||||
}
|
||||
|
||||
function apiType(account: DatabaseAccount | undefined): ApiType {
|
||||
|
|
Loading…
Reference in New Issue