mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Fix create database for serverless accounts (#228)
This commit is contained in:
parent
290ca4aba5
commit
2e747a1a07
@ -30,7 +30,7 @@ export const readDatabaseOffer = async (
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
offerId = await getDatabaseOfferIdWithSDK(params.databaseResourceId, params.isServerless);
|
offerId = await getDatabaseOfferIdWithSDK(params.databaseResourceId);
|
||||||
if (!offerId) {
|
if (!offerId) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -80,8 +80,8 @@ const getDatabaseOfferIdWithARM = async (databaseId: string): Promise<string> =>
|
|||||||
return rpResponse?.name;
|
return rpResponse?.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDatabaseOfferIdWithSDK = async (databaseResourceId: string, isServerless: boolean): Promise<string> => {
|
const getDatabaseOfferIdWithSDK = async (databaseResourceId: string): Promise<string> => {
|
||||||
const offers = await readOffers(isServerless);
|
const offers = await readOffers();
|
||||||
const offer = offers.find(offer => offer.resource === databaseResourceId);
|
const offer = offers.find(offer => offer.resource === databaseResourceId);
|
||||||
return offer?.id;
|
return offer?.id;
|
||||||
};
|
};
|
||||||
|
@ -6,11 +6,7 @@ import { client } from "../CosmosClient";
|
|||||||
import { sendCachedDataMessage } from "../MessageHandler";
|
import { sendCachedDataMessage } from "../MessageHandler";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
export const readOffers = async (isServerless?: boolean): Promise<Offer[]> => {
|
export const readOffers = async (): Promise<Offer[]> => {
|
||||||
if (isServerless) {
|
|
||||||
return []; // Reading offers is not supported for serverless accounts
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (configContext.platform === Platform.Portal) {
|
if (configContext.platform === Platform.Portal) {
|
||||||
return sendCachedDataMessage<Offer[]>(MessageTypes.AllOffers, [
|
return sendCachedDataMessage<Offer[]>(MessageTypes.AllOffers, [
|
||||||
|
@ -292,7 +292,6 @@ export interface CreateCollectionParams {
|
|||||||
export interface ReadDatabaseOfferParams {
|
export interface ReadDatabaseOfferParams {
|
||||||
databaseId: string;
|
databaseId: string;
|
||||||
databaseResourceId?: string;
|
databaseResourceId?: string;
|
||||||
isServerless?: boolean;
|
|
||||||
offerId?: string;
|
offerId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
const subscriptionType: ViewModels.SubscriptionType =
|
const subscriptionType: ViewModels.SubscriptionType =
|
||||||
this.container.subscriptionType && this.container.subscriptionType();
|
this.container.subscriptionType && this.container.subscriptionType();
|
||||||
|
|
||||||
if (subscriptionType === ViewModels.SubscriptionType.EA) {
|
if (subscriptionType === ViewModels.SubscriptionType.EA || this.container.isServerlessEnabled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
const subscriptionType: ViewModels.SubscriptionType =
|
const subscriptionType: ViewModels.SubscriptionType =
|
||||||
this.container.subscriptionType && this.container.subscriptionType();
|
this.container.subscriptionType && this.container.subscriptionType();
|
||||||
|
|
||||||
if (subscriptionType === ViewModels.SubscriptionType.EA) {
|
if (subscriptionType === ViewModels.SubscriptionType.EA || this.container.isServerlessEnabled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +200,10 @@ export default class Database implements ViewModels.Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async loadOffer(): Promise<void> {
|
public async loadOffer(): Promise<void> {
|
||||||
if (!this.offer()) {
|
if (!this.container.isServerlessEnabled() && !this.offer()) {
|
||||||
const params: DataModels.ReadDatabaseOfferParams = {
|
const params: DataModels.ReadDatabaseOfferParams = {
|
||||||
databaseId: this.id(),
|
databaseId: this.id(),
|
||||||
databaseResourceId: this.self,
|
databaseResourceId: this.self
|
||||||
isServerless: this.container.isServerlessEnabled()
|
|
||||||
};
|
};
|
||||||
this.offer(await readDatabaseOffer(params));
|
this.offer(await readDatabaseOffer(params));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user