mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-29 22:02:01 +00:00
Merge branch 'remove_explorer.defaultExperience' of https://github.com/Azure/cosmos-explorer into genericRightPaneComponent
This commit is contained in:
@@ -424,7 +424,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
@@ -1710,7 +1709,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
@@ -3009,7 +3007,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
@@ -4295,7 +4292,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
|
||||
@@ -115,11 +115,6 @@ export default class Explorer {
|
||||
* */
|
||||
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
||||
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
||||
/**
|
||||
* @deprecated
|
||||
* Use userContext.apiType instead
|
||||
* */
|
||||
public defaultExperience: ko.Observable<string>;
|
||||
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
||||
/**
|
||||
* @deprecated
|
||||
@@ -376,17 +371,6 @@ export default class Explorer {
|
||||
bounds: splitterBounds,
|
||||
direction: SplitterDirection.Vertical,
|
||||
});
|
||||
this.defaultExperience = ko.observable<string>();
|
||||
// this.databaseAccount.subscribe((databaseAccount) => {
|
||||
// const defaultExperience: string = DefaultExperienceUtility.getDefaultExperienceFromDatabaseAccount(
|
||||
// databaseAccount
|
||||
// );
|
||||
// this.defaultExperience(defaultExperience);
|
||||
// // TODO. Remove this entirely
|
||||
// updateUserContext({
|
||||
// apiType: DefaultExperienceUtility.mapDefaultExperienceStringToEnum(defaultExperience),
|
||||
// });
|
||||
// });
|
||||
|
||||
this.isFixedCollectionWithSharedThroughputSupported = ko.computed(() => {
|
||||
if (userContext.features.enableFixedCollectionWithSharedThroughput) {
|
||||
|
||||
@@ -44,7 +44,13 @@ describe("Add Collection Pane", () => {
|
||||
});
|
||||
|
||||
it("should be true if graph API and partition key is not /id nor /label", () => {
|
||||
explorer.defaultExperience(Constants.DefaultAccountExperience.Graph.toLowerCase());
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
properties: {
|
||||
capabilities: [{ name: "EnableGremlin" }],
|
||||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
||||
addCollectionPane.partitionKey("/blah");
|
||||
expect(addCollectionPane.isValid()).toBe(true);
|
||||
@@ -58,7 +64,6 @@ describe("Add Collection Pane", () => {
|
||||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
|
||||
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
||||
addCollectionPane.partitionKey("/id");
|
||||
expect(addCollectionPane.isValid()).toBe(false);
|
||||
|
||||
@@ -413,7 +413,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
|
||||
@@ -403,7 +403,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
|
||||
@@ -401,7 +401,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
||||
},
|
||||
"databaseAccount": [Function],
|
||||
"databases": [Function],
|
||||
"defaultExperience": [Function],
|
||||
"deleteCollectionText": [Function],
|
||||
"deleteDatabaseText": [Function],
|
||||
"gitHubClient": GitHubClient {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as ko from "knockout";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { DatabaseAccount } from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
@@ -27,7 +27,13 @@ describe("Documents tab", () => {
|
||||
describe("showPartitionKey", () => {
|
||||
const explorer = new Explorer();
|
||||
const mongoExplorer = new Explorer();
|
||||
mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB);
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
properties: {
|
||||
capabilities: [{ name: "EnableGremlin" }],
|
||||
},
|
||||
} as DatabaseAccount,
|
||||
});
|
||||
|
||||
const collectionWithoutPartitionKey = <ViewModels.Collection>(<unknown>{
|
||||
id: ko.observable<string>("foo"),
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { userContext } from "../../UserContext";
|
||||
import Explorer from "../Explorer";
|
||||
import { NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||
import TabsBase from "./TabsBase";
|
||||
@@ -29,7 +30,7 @@ export default class NotebookTabBase extends TabsBase {
|
||||
NotebookTabBase.clientManager = new NotebookClientV2({
|
||||
connectionInfo: this.container.notebookServerInfo(),
|
||||
databaseAccountName: this.container.databaseAccount().name,
|
||||
defaultExperience: this.container.defaultExperience(),
|
||||
defaultExperience: userContext.apiType,
|
||||
contentProvider: this.container.notebookManager?.notebookContentProvider,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import Q from "q";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
@@ -21,8 +20,7 @@ export default class AuthHeadersUtil {
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const subscriptionId: string = userContext.subscriptionId;
|
||||
const resourceGroup = userContext.resourceGroup;
|
||||
const defaultExperience: string = DefaultExperienceUtility.getDefaultExperienceFromDatabaseAccount(databaseAccount);
|
||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(defaultExperience);
|
||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(userContext.apiType);
|
||||
const accountEndpoint = (databaseAccount && databaseAccount.properties.documentEndpoint) || "";
|
||||
const sid = subscriptionId || "";
|
||||
const rg = resourceGroup || "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { userContext } from "../UserContext";
|
||||
import { DefaultExperienceUtility } from "./DefaultExperienceUtility";
|
||||
|
||||
describe("Default Experience Utility", () => {
|
||||
@@ -38,31 +38,29 @@ describe("Default Experience Utility", () => {
|
||||
});
|
||||
|
||||
describe("getApiKindFromDefaultExperience()", () => {
|
||||
function runScenario(defaultExperience: string, expectedApiKind: number): void {
|
||||
function runScenario(defaultExperience: typeof userContext.apiType, expectedApiKind: number): void {
|
||||
const resolvedApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(defaultExperience);
|
||||
expect(resolvedApiKind).toEqual(expectedApiKind);
|
||||
}
|
||||
|
||||
describe("On SQL", () => {
|
||||
it("should return SQL", () => runScenario(Constants.DefaultAccountExperience.DocumentDB, DataModels.ApiKind.SQL));
|
||||
it("should return SQL", () => runScenario("SQL", DataModels.ApiKind.SQL));
|
||||
});
|
||||
|
||||
describe("On MongoDB", () => {
|
||||
it("should return MongoDB", () =>
|
||||
runScenario(Constants.DefaultAccountExperience.MongoDB, DataModels.ApiKind.MongoDB));
|
||||
it("should return MongoDB", () => runScenario("Mongo", DataModels.ApiKind.MongoDB));
|
||||
});
|
||||
|
||||
describe("On Table", () => {
|
||||
it("should return Table", () => runScenario(Constants.DefaultAccountExperience.Table, DataModels.ApiKind.Table));
|
||||
it("should return Table", () => runScenario("Tables", DataModels.ApiKind.Table));
|
||||
});
|
||||
|
||||
describe("On Cassandra", () => {
|
||||
it("should return Cassandra", () =>
|
||||
runScenario(Constants.DefaultAccountExperience.Cassandra, DataModels.ApiKind.Cassandra));
|
||||
it("should return Cassandra", () => runScenario("Cassandra", DataModels.ApiKind.Cassandra));
|
||||
});
|
||||
|
||||
describe("On Graph", () => {
|
||||
it("should return Graph", () => runScenario(Constants.DefaultAccountExperience.Graph, DataModels.ApiKind.Graph));
|
||||
it("should return Graph", () => runScenario("Gremlin", DataModels.ApiKind.Graph));
|
||||
});
|
||||
|
||||
describe("On null", () => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as _ from "underscore";
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class DefaultExperienceUtility {
|
||||
public static getDefaultExperienceFromDatabaseAccount(databaseAccount: DataModels.DatabaseAccount): string | null {
|
||||
@@ -15,22 +16,21 @@ export class DefaultExperienceUtility {
|
||||
return DefaultExperienceUtility._getDefaultExperience(kind, capabilities);
|
||||
}
|
||||
|
||||
public static getApiKindFromDefaultExperience(defaultExperience: string): DataModels.ApiKind {
|
||||
public static getApiKindFromDefaultExperience(defaultExperience: typeof userContext.apiType): DataModels.ApiKind {
|
||||
if (!defaultExperience) {
|
||||
return DataModels.ApiKind.SQL;
|
||||
}
|
||||
|
||||
switch (defaultExperience) {
|
||||
case Constants.DefaultAccountExperience.DocumentDB:
|
||||
case "SQL":
|
||||
return DataModels.ApiKind.SQL;
|
||||
case Constants.DefaultAccountExperience.MongoDB:
|
||||
case Constants.DefaultAccountExperience.ApiForMongoDB:
|
||||
case "Mongo":
|
||||
return DataModels.ApiKind.MongoDB;
|
||||
case Constants.DefaultAccountExperience.Table:
|
||||
case "Tables":
|
||||
return DataModels.ApiKind.Table;
|
||||
case Constants.DefaultAccountExperience.Cassandra:
|
||||
case "Cassandra":
|
||||
return DataModels.ApiKind.Cassandra;
|
||||
case Constants.DefaultAccountExperience.Graph:
|
||||
case "Gremlin":
|
||||
return DataModels.ApiKind.Graph;
|
||||
default:
|
||||
return DataModels.ApiKind.SQL;
|
||||
|
||||
@@ -27,7 +27,7 @@ interface UserContext {
|
||||
readonly hasWriteAccess: boolean;
|
||||
}
|
||||
|
||||
type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra";
|
||||
export type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra";
|
||||
export type PortalEnv = "localhost" | "blackforest" | "fairfax" | "mooncake" | "prod" | "dev";
|
||||
|
||||
const features = extractFeatures();
|
||||
|
||||
@@ -99,8 +99,8 @@ export function computeDisplayUsageString(usageInKB: number): string {
|
||||
usageInGB > 0.1
|
||||
? usageInGB.toFixed(2) + " GB"
|
||||
: usageInMB > 0.1
|
||||
? usageInMB.toFixed(2) + " MB"
|
||||
: usageInKB.toFixed(2) + " KB";
|
||||
? usageInMB.toFixed(2) + " MB"
|
||||
: usageInKB.toFixed(2) + " KB";
|
||||
return displayUsageString;
|
||||
}
|
||||
|
||||
@@ -167,9 +167,8 @@ export function getAutoPilotV3SpendHtml(maxAutoPilotThroughputSet: number, isDat
|
||||
maxAutoPilotThroughputSet
|
||||
)} RU/s (10% of max RU/s) - ${maxAutoPilotThroughputSet} RU/s</b> based on usage. <br /><br />After the first ${AutoPilotUtils.getStorageBasedOnUserInput(
|
||||
maxAutoPilotThroughputSet
|
||||
)} GB of data stored, the max RU/s will be automatically upgraded based on the new storage value. <a href='${
|
||||
Constants.AutopilotDocumentation.Url
|
||||
}' target='_blank' aria-label='Learn more about autoscale throughput'>Learn more</a>.`;
|
||||
)} GB of data stored, the max RU/s will be automatically upgraded based on the new storage value. <a href='${Constants.AutopilotDocumentation.Url
|
||||
}' target='_blank' aria-label='Learn more about autoscale throughput'>Learn more</a>.`;
|
||||
}
|
||||
|
||||
export function getEstimatedAutoscaleSpendHtml(
|
||||
@@ -196,8 +195,7 @@ export function getEstimatedAutoscaleSpendHtml(
|
||||
`Estimated monthly cost (${currency}): <b>` +
|
||||
`${currencySign}${calculateEstimateNumber(monthlyPrice / 10)} - ` +
|
||||
`${currencySign}${calculateEstimateNumber(monthlyPrice)} </b> ` +
|
||||
`(${regions} ${regions === 1 ? "region" : "regions"}, ${
|
||||
throughput / 10
|
||||
`(${regions} ${regions === 1 ? "region" : "regions"}, ${throughput / 10
|
||||
} - ${throughput} RU/s, ${currencySign}${pricePerRu}/RU)`
|
||||
);
|
||||
}
|
||||
@@ -251,11 +249,11 @@ export function getEstimatedSpendAcknowledgeString(
|
||||
const currencySign: string = getCurrencySign(serverId);
|
||||
return !isAutoscale
|
||||
? `I acknowledge the estimated ${currencySign}${calculateEstimateNumber(
|
||||
dailyPrice
|
||||
)} daily cost for the throughput above.`
|
||||
dailyPrice
|
||||
)} daily cost for the throughput above.`
|
||||
: `I acknowledge the estimated ${currencySign}${calculateEstimateNumber(
|
||||
monthlyPrice / 10
|
||||
)} - ${currencySign}${calculateEstimateNumber(monthlyPrice)} monthly cost for the throughput above.`;
|
||||
monthlyPrice / 10
|
||||
)} - ${currencySign}${calculateEstimateNumber(monthlyPrice)} monthly cost for the throughput above.`;
|
||||
}
|
||||
|
||||
export function getUpsellMessage(
|
||||
|
||||
Reference in New Issue
Block a user