mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 09:51:11 +00:00
Remove explorer.is preferred api graph (#655)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import AddCollectionPane from "./AddCollectionPane";
|
||||
import Explorer from "../Explorer";
|
||||
import { DatabaseAccount } from "../../Contracts/DataModels";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
import Explorer from "../Explorer";
|
||||
import AddCollectionPane from "./AddCollectionPane";
|
||||
|
||||
describe("Add Collection Pane", () => {
|
||||
describe("isValid()", () => {
|
||||
@@ -50,7 +51,14 @@ describe("Add Collection Pane", () => {
|
||||
});
|
||||
|
||||
it("should be false if graph API and partition key is /id or /label", () => {
|
||||
explorer.defaultExperience(Constants.DefaultAccountExperience.Graph.toLowerCase());
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
properties: {
|
||||
capabilities: [{ name: "EnableGremlin" }],
|
||||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
|
||||
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
||||
addCollectionPane.partitionKey("/id");
|
||||
expect(addCollectionPane.isValid()).toBe(false);
|
||||
@@ -60,7 +68,13 @@ describe("Add Collection Pane", () => {
|
||||
});
|
||||
|
||||
it("should be true for any non-graph API with /id or /label partition key", () => {
|
||||
explorer.defaultExperience(Constants.DefaultAccountExperience.DocumentDB.toLowerCase());
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
properties: {
|
||||
capabilities: [{ name: "EnableCassandra" }],
|
||||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
||||
|
||||
addCollectionPane.partitionKey("/id");
|
||||
|
||||
@@ -127,13 +127,13 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
});
|
||||
this.partitionKey.extend({ rateLimit: 100 });
|
||||
this.partitionKeyPattern = ko.pureComputed(() => {
|
||||
if (this.container && this.container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "Gremlin") {
|
||||
return "^/[^/]*";
|
||||
}
|
||||
return ".*";
|
||||
});
|
||||
this.partitionKeyTitle = ko.pureComputed(() => {
|
||||
if (this.container && this.container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "Gremlin") {
|
||||
return "May not use composite partition key";
|
||||
}
|
||||
return "";
|
||||
@@ -331,7 +331,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
|
||||
if (currentCollections >= maxCollections) {
|
||||
let typeOfContainer = "collection";
|
||||
if (this.container.isPreferredApiGraph() || this.container.isPreferredApiTable()) {
|
||||
if (userContext.apiType === "Gremlin" || this.container.isPreferredApiTable()) {
|
||||
typeOfContainer = "container";
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
return "e.g., address.zipCode";
|
||||
}
|
||||
|
||||
if (this.container && !!this.container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "Gremlin") {
|
||||
return "e.g., /address";
|
||||
}
|
||||
|
||||
@@ -384,17 +384,11 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
});
|
||||
|
||||
this.uniqueKeysVisible = ko.pureComputed<boolean>(() => {
|
||||
if (
|
||||
this.container == null ||
|
||||
!!this.container.isPreferredApiMongoDB() ||
|
||||
!!this.container.isPreferredApiTable() ||
|
||||
userContext.apiType === "Cassandra" ||
|
||||
!!this.container.isPreferredApiGraph()
|
||||
) {
|
||||
return false;
|
||||
if (userContext.apiType === "SQL") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
this.partitionKeyVisible = ko.computed<boolean>(() => {
|
||||
@@ -1011,7 +1005,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.container.isPreferredApiGraph() && (this.partitionKey() === "/id" || this.partitionKey() === "/label")) {
|
||||
if (userContext.apiType === "Gremlin" && (this.partitionKey() === "/id" || this.partitionKey() === "/label")) {
|
||||
this.formErrors("/id and /label as partition keys are not allowed for graph.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -623,7 +623,6 @@ exports[`Settings Pane should render Default properly 1`] = `
|
||||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
@@ -1509,7 +1508,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = `
|
||||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
|
||||
@@ -623,7 +623,6 @@ exports[`Upload Items Pane should render Default properly 1`] = `
|
||||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
|
||||
@@ -626,7 +626,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
||||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
|
||||
Reference in New Issue
Block a user