mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
add collection panel improvements (#630)
Co-authored-by: Jordi Bunster <jbunster@microsoft.com>
This commit is contained in:
30
src/Utils/APITypeUtils.ts
Normal file
30
src/Utils/APITypeUtils.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export const getCollectionName = (isPlural?: boolean): string => {
|
||||
let collectionName: string;
|
||||
let unknownApiType: never;
|
||||
switch (userContext.apiType) {
|
||||
case "SQL":
|
||||
collectionName = "Container";
|
||||
break;
|
||||
case "Mongo":
|
||||
collectionName = "Collection";
|
||||
break;
|
||||
case "Cassandra":
|
||||
case "Tables":
|
||||
collectionName = "Table";
|
||||
break;
|
||||
case "Gremlin":
|
||||
collectionName = "Graph";
|
||||
break;
|
||||
default:
|
||||
unknownApiType = userContext.apiType;
|
||||
throw new Error(`Unknown API type: ${unknownApiType}`);
|
||||
}
|
||||
|
||||
if (isPlural) {
|
||||
collectionName += "s";
|
||||
}
|
||||
|
||||
return collectionName;
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Constants from "../Shared/Constants";
|
||||
import { getCollectionName } from "../Utils/APITypeUtils";
|
||||
import * as AutoPilotUtils from "../Utils/AutoPilotUtils";
|
||||
|
||||
interface ComputeRUUsagePriceHourlyArgs {
|
||||
@@ -10,7 +11,7 @@ interface ComputeRUUsagePriceHourlyArgs {
|
||||
}
|
||||
|
||||
export const estimatedCostDisclaimer =
|
||||
"*This cost is an estimate and may vary based on the regions where your account is deployed and potential discounts applied to your account";
|
||||
"This cost is an estimate and may vary based on the regions where your account is deployed and potential discounts applied to your account";
|
||||
|
||||
/**
|
||||
* Anything that is not a number should return 0
|
||||
@@ -161,7 +162,7 @@ export function getAutoPilotV3SpendHtml(maxAutoPilotThroughputSet: number, isDat
|
||||
return "";
|
||||
}
|
||||
|
||||
const resource: string = isDatabaseThroughput ? "database" : "container";
|
||||
const resource: string = isDatabaseThroughput ? "database" : getCollectionName().toLocaleLowerCase();
|
||||
return `Your ${resource} throughput will automatically scale from <b>${AutoPilotUtils.getMinRUsBasedOnUserInput(
|
||||
maxAutoPilotThroughputSet
|
||||
)} RU/s (10% of max RU/s) - ${maxAutoPilotThroughputSet} RU/s</b> based on usage. <br /><br />After the first ${AutoPilotUtils.getStorageBasedOnUserInput(
|
||||
@@ -227,7 +228,7 @@ export function getEstimatedSpendHtml(
|
||||
`${currencySign}${calculateEstimateNumber(monthlyPrice)} monthly </b> ` +
|
||||
`(${regions} ${regions === 1 ? "region" : "regions"}, ${throughput}RU/s, ${currencySign}${pricePerRu}/RU)` +
|
||||
`<p style='padding: 10px 0px 0px 0px;'>` +
|
||||
`<em>${estimatedCostDisclaimer}</em></p>`
|
||||
`<em>*${estimatedCostDisclaimer}</em></p>`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -261,11 +262,10 @@ export function getUpsellMessage(
|
||||
serverId = "default",
|
||||
isFreeTier = false,
|
||||
isFirstResourceCreated = false,
|
||||
defaultExperience: string,
|
||||
isCollection: boolean
|
||||
): string {
|
||||
if (isFreeTier) {
|
||||
const collectionName = getCollectionName(defaultExperience);
|
||||
const collectionName = getCollectionName().toLocaleLowerCase();
|
||||
const resourceType = isCollection ? collectionName : "database";
|
||||
return isFirstResourceCreated
|
||||
? `The free tier discount of 400 RU/s has already been applied to a database or ${collectionName} in this account. Billing will apply to this ${resourceType} after it is created.`
|
||||
@@ -277,22 +277,8 @@ export function getUpsellMessage(
|
||||
price = Constants.OfferPricing.MonthlyPricing.mooncake.Standard.StartingPrice;
|
||||
}
|
||||
|
||||
return `Start at ${getCurrencySign(serverId)}${price}/mo per database, multiple containers included`;
|
||||
}
|
||||
}
|
||||
|
||||
export function getCollectionName(defaultExperience: string): string {
|
||||
switch (defaultExperience) {
|
||||
case "SQL":
|
||||
return "container";
|
||||
case "Mongo":
|
||||
return "collection";
|
||||
case "Tables":
|
||||
case "Cassandra":
|
||||
return "table";
|
||||
case "Gremlin":
|
||||
return "graph";
|
||||
default:
|
||||
throw Error("unknown API type");
|
||||
return `Start at ${getCurrencySign(serverId)}${price}/mo per database, multiple ${getCollectionName(
|
||||
true
|
||||
).toLocaleLowerCase()} included`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user