mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 08:51:24 +00:00
Deprecate Explorer Properties (#535)
This commit is contained in:
@@ -17,12 +17,43 @@ interface UserContext {
|
||||
useSDKOperations?: boolean;
|
||||
subscriptionType?: SubscriptionType;
|
||||
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
|
||||
apiType?: ApiType;
|
||||
}
|
||||
|
||||
const userContext: Readonly<UserContext> = {} as const;
|
||||
type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra";
|
||||
|
||||
const userContext: UserContext = {};
|
||||
|
||||
function updateUserContext(newContext: UserContext): void {
|
||||
Object.assign(userContext, newContext);
|
||||
Object.assign(userContext, { apiType: apiType(userContext.databaseAccount) });
|
||||
}
|
||||
|
||||
function apiType(account: DatabaseAccount | undefined): ApiType {
|
||||
if (!account) {
|
||||
return "SQL";
|
||||
}
|
||||
const capabilities = account.properties?.capabilities;
|
||||
if (capabilities) {
|
||||
if (capabilities.find((c) => c.name === "EnableCassandra")) {
|
||||
return "Cassandra";
|
||||
}
|
||||
if (capabilities.find((c) => c.name === "EnableGremlin")) {
|
||||
return "Gremlin";
|
||||
}
|
||||
if (capabilities.find((c) => c.name === "EnableMongo")) {
|
||||
return "Mongo";
|
||||
}
|
||||
if (capabilities.find((c) => c.name === "EnableTable")) {
|
||||
return "Tables";
|
||||
}
|
||||
}
|
||||
if (account.kind === "MongoDB" || account.kind === "Parse") {
|
||||
return "Mongo";
|
||||
}
|
||||
return "SQL";
|
||||
}
|
||||
|
||||
export { userContext, updateUserContext };
|
||||
|
||||
Reference in New Issue
Block a user