Remove explorer.is preferred api graph (#655)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
parent
02ea26da71
commit
d74da34742
|
@ -55,7 +55,7 @@ export class ResourceTreeContextMenuButtonFactory {
|
|||
selectedCollection: ViewModels.Collection
|
||||
): TreeNodeMenuItem[] {
|
||||
const items: TreeNodeMenuItem[] = [];
|
||||
if (userContext.apiType === "SQL" || container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "SQL" || userContext.apiType === "Gremlin") {
|
||||
items.push({
|
||||
iconSrc: AddSqlQueryIcon,
|
||||
onClick: () => selectedCollection && selectedCollection.onNewQueryClick(selectedCollection, null),
|
||||
|
@ -80,7 +80,7 @@ export class ResourceTreeContextMenuButtonFactory {
|
|||
});
|
||||
}
|
||||
|
||||
if (userContext.apiType === "SQL" || container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "SQL" || userContext.apiType === "Gremlin") {
|
||||
items.push({
|
||||
iconSrc: AddStoredProcedureIcon,
|
||||
onClick: () => {
|
||||
|
|
|
@ -647,7 +647,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
|
@ -1410,7 +1409,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
|
@ -2186,7 +2184,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [Function],
|
||||
|
@ -2949,7 +2946,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||
"isMongoIndexingEnabled": [Function],
|
||||
"isNotebookEnabled": [Function],
|
||||
"isNotebooksEnabledForAccount": [Function],
|
||||
"isPreferredApiGraph": [Function],
|
||||
"isPreferredApiMongoDB": [Function],
|
||||
"isPreferredApiTable": [Function],
|
||||
"isPublishNotebookPaneEnabled": [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.isPreferredApiGraph = ko.computed<boolean>(() => false);
|
||||
explorerStub.isPreferredApiMongoDB = ko.computed<boolean>(() => false);
|
||||
explorerStub.isPreferredApiTable = ko.computed<boolean>(() => false);
|
||||
explorerStub.canExceedMaximumValue = ko.computed<boolean>(() => false);
|
||||
|
@ -115,7 +114,13 @@ describe("ContainerSampleGenerator", () => {
|
|||
collection.databaseId = database.id();
|
||||
|
||||
const explorerStub = createExplorerStub(database);
|
||||
explorerStub.isPreferredApiGraph = ko.computed<boolean>(() => true);
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
properties: {
|
||||
capabilities: [{ name: "EnableGremlin" }],
|
||||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
|
||||
const generator = await ContainerSampleGenerator.createSampleGeneratorAsync(explorerStub);
|
||||
generator.setData(sampleData);
|
||||
|
|
|
@ -73,7 +73,7 @@ export class ContainerSampleGenerator {
|
|||
}
|
||||
const promises: Q.Promise<any>[] = [];
|
||||
|
||||
if (this.container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "Gremlin") {
|
||||
// For Gremlin, all queries are executed sequentially, because some queries might be dependent on other queries
|
||||
// (e.g. adding edge requires vertices to be present)
|
||||
const queries: string[] = this.sampleDataFile.data;
|
||||
|
|
|
@ -57,6 +57,6 @@ export class DataSamplesUtil {
|
|||
}
|
||||
|
||||
public isSampleContainerCreationSupported(): boolean {
|
||||
return userContext.apiType === "SQL" || this.container.isPreferredApiGraph();
|
||||
return userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,11 +121,7 @@ export default class Explorer {
|
|||
* Compare a string with userContext.apiType instead: userContext.apiType === "Mongo"
|
||||
* */
|
||||
public isPreferredApiMongoDB: ko.Computed<boolean>;
|
||||
/**
|
||||
* @deprecated
|
||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Gremlin"
|
||||
* */
|
||||
public isPreferredApiGraph: ko.Computed<boolean>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Tables"
|
||||
|
@ -409,11 +405,6 @@ export default class Explorer {
|
|||
});
|
||||
});
|
||||
|
||||
this.isPreferredApiGraph = ko.computed(() => {
|
||||
const defaultExperience = (this.defaultExperience && this.defaultExperience()) || "";
|
||||
return defaultExperience.toLowerCase() === Constants.DefaultAccountExperience.Graph.toLowerCase();
|
||||
});
|
||||
|
||||
this.isPreferredApiTable = ko.computed(() => {
|
||||
const defaultExperience = (this.defaultExperience && this.defaultExperience()) || "";
|
||||
return defaultExperience.toLowerCase() === Constants.DefaultAccountExperience.Table.toLowerCase();
|
||||
|
@ -477,7 +468,9 @@ export default class Explorer {
|
|||
|
||||
this.isHostedDataExplorerEnabled = ko.computed<boolean>(
|
||||
() =>
|
||||
configContext.platform === Platform.Portal && !this.isRunningOnNationalCloud() && !this.isPreferredApiGraph()
|
||||
configContext.platform === Platform.Portal &&
|
||||
!this.isRunningOnNationalCloud() &&
|
||||
userContext.apiType !== "Gremlin"
|
||||
);
|
||||
this.isRightPanelV2Enabled = ko.computed<boolean>(() => userContext.features.enableRightPanelV2);
|
||||
this.selectedDatabaseId = ko.computed<string>(() => {
|
||||
|
|
|
@ -31,7 +31,6 @@ export class CommandBarComponentAdapter implements ReactAdapter {
|
|||
const toWatch = [
|
||||
container.isPreferredApiTable,
|
||||
container.isPreferredApiMongoDB,
|
||||
container.isPreferredApiGraph,
|
||||
container.deleteCollectionText,
|
||||
container.deleteDatabaseText,
|
||||
container.addCollectionText,
|
||||
|
|
|
@ -90,15 +90,15 @@ export function createStaticCommandBarButtons(container: Explorer): CommandButto
|
|||
buttons.push(createDivider());
|
||||
}
|
||||
|
||||
const isSqlQuerySupported = userContext.apiType === "SQL" || container.isPreferredApiGraph();
|
||||
const isSqlQuerySupported = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||
if (isSqlQuerySupported) {
|
||||
const newSqlQueryBtn = createNewSQLQueryButton(container);
|
||||
buttons.push(newSqlQueryBtn);
|
||||
}
|
||||
|
||||
const isSupportedOpenQueryApi =
|
||||
userContext.apiType === "SQL" || container.isPreferredApiMongoDB() || container.isPreferredApiGraph();
|
||||
const isSupportedOpenQueryFromDiskApi = userContext.apiType === "SQL" || container.isPreferredApiGraph();
|
||||
userContext.apiType === "SQL" || container.isPreferredApiMongoDB() || userContext.apiType === "Gremlin";
|
||||
const isSupportedOpenQueryFromDiskApi = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||
if (isSupportedOpenQueryApi && container.selectedNode() && container.findSelectedCollection()) {
|
||||
const openQueryBtn = createOpenQueryButton(container);
|
||||
openQueryBtn.children = [createOpenQueryButton(container), createOpenQueryFromDiskButton(container)];
|
||||
|
@ -107,7 +107,7 @@ export function createStaticCommandBarButtons(container: Explorer): CommandButto
|
|||
buttons.push(createOpenQueryFromDiskButton(container));
|
||||
}
|
||||
|
||||
if (areScriptsSupported(container)) {
|
||||
if (areScriptsSupported()) {
|
||||
const label = "New Stored Procedure";
|
||||
const newStoredProcedureBtn: CommandButtonComponentProps = {
|
||||
iconSrc: AddStoredProcedureIcon,
|
||||
|
@ -216,8 +216,8 @@ export function createDivider(): CommandButtonComponentProps {
|
|||
};
|
||||
}
|
||||
|
||||
function areScriptsSupported(container: Explorer): boolean {
|
||||
return userContext.apiType === "SQL" || container.isPreferredApiGraph();
|
||||
function areScriptsSupported(): boolean {
|
||||
return userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||
}
|
||||
|
||||
function createNewCollectionGroup(container: Explorer): CommandButtonComponentProps {
|
||||
|
@ -325,8 +325,7 @@ function createNewSQLQueryButton(container: Explorer): CommandButtonComponentPro
|
|||
export function createScriptCommandButtons(container: Explorer): CommandButtonComponentProps[] {
|
||||
const buttons: CommandButtonComponentProps[] = [];
|
||||
|
||||
const shouldEnableScriptsCommands: boolean =
|
||||
!container.isDatabaseNodeOrNoneSelected() && areScriptsSupported(container);
|
||||
const shouldEnableScriptsCommands: boolean = !container.isDatabaseNodeOrNoneSelected() && areScriptsSupported();
|
||||
|
||||
if (shouldEnableScriptsCommands) {
|
||||
const label = "New Stored Procedure";
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -227,7 +227,7 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||
}
|
||||
|
||||
if (!this.container.isDatabaseNodeOrNoneSelected()) {
|
||||
if (userContext.apiType === "SQL" || this.container.isPreferredApiGraph()) {
|
||||
if (userContext.apiType === "SQL" || userContext.apiType === "Gremlin") {
|
||||
items.push({
|
||||
iconSrc: NewQueryIcon,
|
||||
onClick: () => {
|
||||
|
|
|
@ -1087,7 +1087,7 @@ export default class Collection implements ViewModels.Collection {
|
|||
} else if (userContext.apiType === "Cassandra") {
|
||||
this.onTableEntitiesClick();
|
||||
return;
|
||||
} else if (this.container.isPreferredApiGraph()) {
|
||||
} else if (userContext.apiType === "Gremlin") {
|
||||
this.onGraphDocumentsClick();
|
||||
return;
|
||||
} else if (this.container.isPreferredApiMongoDB()) {
|
||||
|
@ -1106,7 +1106,7 @@ export default class Collection implements ViewModels.Collection {
|
|||
return "Entities";
|
||||
} else if (userContext.apiType === "Cassandra") {
|
||||
return "Rows";
|
||||
} else if (this.container.isPreferredApiGraph()) {
|
||||
} else if (userContext.apiType === "Gremlin") {
|
||||
return "Graph";
|
||||
} else if (this.container.isPreferredApiMongoDB()) {
|
||||
return "Documents";
|
||||
|
|
|
@ -253,7 +253,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||
* @param container
|
||||
*/
|
||||
private static showScriptNodes(container: Explorer): boolean {
|
||||
return userContext.apiType === "SQL" || container.isPreferredApiGraph();
|
||||
return userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||
}
|
||||
|
||||
private buildCollectionNode(database: ViewModels.Database, collection: ViewModels.Collection): TreeNode {
|
||||
|
|
|
@ -158,10 +158,7 @@ export class TabRouteHandler {
|
|||
databaseId,
|
||||
collectionId
|
||||
);
|
||||
collection &&
|
||||
collection.container &&
|
||||
collection.container.isPreferredApiGraph() &&
|
||||
collection.onGraphDocumentsClick();
|
||||
userContext.apiType === "Gremlin" && collection.onGraphDocumentsClick();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue