diff --git a/src/Explorer/Panes/AddCollectionPanel.tsx b/src/Explorer/Panes/AddCollectionPanel.tsx index 1837133b5..92ca20a4d 100644 --- a/src/Explorer/Panes/AddCollectionPanel.tsx +++ b/src/Explorer/Panes/AddCollectionPanel.tsx @@ -58,18 +58,16 @@ export interface AddCollectionPanelState { errorMessage: string; showErrorDetails: boolean; isExecuting: boolean; + newDatabaseThroughput: number; + isNewDatabaseAutoscale: boolean; + collectionThroughput: number; + isCollectionAutoscale: boolean; + isCostAcknowledged: boolean; } export class AddCollectionPanel extends React.Component { - private newDatabaseThroughput: number; - private isNewDatabaseAutoscale: boolean; - private collectionThroughput: number; - private isCollectionAutoscale: boolean; - private isCostAcknowledged: boolean; - constructor(props: AddCollectionPanelProps) { super(props); - this.state = { createNewDatabase: userContext.apiType !== "Tables" && !this.props.databaseId, newDatabaseId: "", @@ -88,6 +86,11 @@ export class AddCollectionPanel extends React.Component (this.newDatabaseThroughput = throughput)} - setIsAutoscale={(isAutoscale: boolean) => (this.isNewDatabaseAutoscale = isAutoscale)} - onCostAcknowledgeChange={(isAcknowledge: boolean) => (this.isCostAcknowledged = isAcknowledge)} + setThroughputValue={(throughput: number) => this.setState({ newDatabaseThroughput: throughput })} + setIsAutoscale={(isAutoscale: boolean) => this.setState({ isNewDatabaseAutoscale: isAutoscale })} + onCostAcknowledgeChange={(isAcknowledge: boolean) => + this.setState({ isCostAcknowledged: isAcknowledge }) + } /> )} @@ -444,13 +449,13 @@ export class AddCollectionPanel extends React.Component (this.collectionThroughput = throughput)} - setIsAutoscale={(isAutoscale: boolean) => (this.isCollectionAutoscale = isAutoscale)} + setThroughputValue={(throughput: number) => this.setState({ collectionThroughput: throughput })} + setIsAutoscale={(isAutoscale: boolean) => this.setState({ isCollectionAutoscale: isAutoscale })} onCostAcknowledgeChange={(isAcknowledged: boolean) => { - this.isCostAcknowledged = isAcknowledged; + this.setState({ isCostAcknowledged: isAcknowledged }); }} /> )} @@ -895,9 +900,11 @@ export class AddCollectionPanel extends React.Component CollectionCreation.DefaultCollectionRUs100K && !this.isCostAcknowledged) { - const errorMessage = this.isNewDatabaseAutoscale + const throughput = this.state.createNewDatabase + ? this.state.newDatabaseThroughput + : this.state.collectionThroughput; + if (throughput > CollectionCreation.DefaultCollectionRUs100K && !this.state.isCostAcknowledged) { + const errorMessage = this.state.isNewDatabaseAutoscale ? "Please acknowledge the estimated monthly spend." : "Please acknowledge the estimated daily spend."; this.setState({ errorMessage }); @@ -980,8 +987,8 @@ export class AddCollectionPanel extends React.Component