@@ -7,6 +7,10 @@ import {
7
7
ContainerPolicyComponent ,
8
8
ContainerPolicyComponentProps ,
9
9
} from "Explorer/Controls/Settings/SettingsSubComponents/ContainerPolicyComponent" ;
10
+ import {
11
+ ThroughputBucketsComponent ,
12
+ ThroughputBucketsComponentProps ,
13
+ } from "Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputBucketsComponent" ;
10
14
import { useDatabases } from "Explorer/useDatabases" ;
11
15
import { isFullTextSearchEnabled , isVectorSearchEnabled } from "Utils/CapabilityUtils" ;
12
16
import { isRunningOnPublicCloud } from "Utils/CloudUtils" ;
@@ -86,6 +90,8 @@ export interface SettingsComponentState {
86
90
wasAutopilotOriginallySet : boolean ;
87
91
isScaleSaveable : boolean ;
88
92
isScaleDiscardable : boolean ;
93
+ throughputBuckets : DataModels . ThroughputBucket [ ] ;
94
+ throughputBucketsBaseline : DataModels . ThroughputBucket [ ] ;
89
95
throughputError : string ;
90
96
91
97
timeToLive : TtlType ;
@@ -104,6 +110,7 @@ export interface SettingsComponentState {
104
110
changeFeedPolicyBaseline : ChangeFeedPolicyState ;
105
111
isSubSettingsSaveable : boolean ;
106
112
isSubSettingsDiscardable : boolean ;
113
+ isThroughputBucketsSaveable : boolean ;
107
114
108
115
vectorEmbeddingPolicy : DataModels . VectorEmbeddingPolicy ;
109
116
vectorEmbeddingPolicyBaseline : DataModels . VectorEmbeddingPolicy ;
@@ -158,6 +165,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
158
165
private isVectorSearchEnabled : boolean ;
159
166
private isFullTextSearchEnabled : boolean ;
160
167
private totalThroughputUsed : number ;
168
+ private throughputBucketsEnabled : boolean ;
161
169
public mongoDBCollectionResource : MongoDBCollectionResource ;
162
170
163
171
constructor ( props : SettingsComponentProps ) {
@@ -175,6 +183,10 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
175
183
this . isFullTextSearchEnabled = isFullTextSearchEnabled ( ) && ! hasDatabaseSharedThroughput ( this . collection ) ;
176
184
177
185
this . changeFeedPolicyVisible = userContext . features . enableChangeFeedPolicy ;
186
+ this . throughputBucketsEnabled =
187
+ userContext . apiType === "SQL" &&
188
+ userContext . features . enableThroughputBuckets &&
189
+ userContext . authType === AuthType . AAD ;
178
190
179
191
// Mongo container with system partition key still treat as "Fixed"
180
192
this . isFixedContainer =
@@ -193,6 +205,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
193
205
wasAutopilotOriginallySet : false ,
194
206
isScaleSaveable : false ,
195
207
isScaleDiscardable : false ,
208
+ throughputBuckets : undefined ,
209
+ throughputBucketsBaseline : undefined ,
196
210
throughputError : undefined ,
197
211
198
212
timeToLive : undefined ,
@@ -211,6 +225,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
211
225
changeFeedPolicyBaseline : undefined ,
212
226
isSubSettingsSaveable : false ,
213
227
isSubSettingsDiscardable : false ,
228
+ isThroughputBucketsSaveable : false ,
214
229
215
230
vectorEmbeddingPolicy : undefined ,
216
231
vectorEmbeddingPolicyBaseline : undefined ,
@@ -327,7 +342,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
327
342
this . state . isIndexingPolicyDirty ||
328
343
this . state . isConflictResolutionDirty ||
329
344
this . state . isComputedPropertiesDirty ||
330
- ( ! ! this . state . currentMongoIndexes && this . state . isMongoIndexingPolicySaveable )
345
+ ( ! ! this . state . currentMongoIndexes && this . state . isMongoIndexingPolicySaveable ) ||
346
+ this . state . isThroughputBucketsSaveable
331
347
) ;
332
348
} ;
333
349
@@ -339,7 +355,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
339
355
this . state . isIndexingPolicyDirty ||
340
356
this . state . isConflictResolutionDirty ||
341
357
this . state . isComputedPropertiesDirty ||
342
- ( ! ! this . state . currentMongoIndexes && this . state . isMongoIndexingPolicyDiscardable )
358
+ ( ! ! this . state . currentMongoIndexes && this . state . isMongoIndexingPolicyDiscardable ) ||
359
+ this . state . isThroughputBucketsSaveable
343
360
) ;
344
361
} ;
345
362
@@ -419,6 +436,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
419
436
420
437
this . setState ( {
421
438
throughput : this . state . throughputBaseline ,
439
+ throughputBuckets : this . state . throughputBucketsBaseline ,
440
+ throughputBucketsBaseline : this . state . throughputBucketsBaseline ,
422
441
timeToLive : this . state . timeToLiveBaseline ,
423
442
timeToLiveSeconds : this . state . timeToLiveSecondsBaseline ,
424
443
displayedTtlSeconds : this . state . displayedTtlSecondsBaseline ,
@@ -441,6 +460,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
441
460
isScaleSaveable : false ,
442
461
isScaleDiscardable : false ,
443
462
isSubSettingsSaveable : false ,
463
+ isThroughputBucketsSaveable : false ,
444
464
isSubSettingsDiscardable : false ,
445
465
isContainerPolicyDirty : false ,
446
466
isIndexingPolicyDirty : false ,
@@ -479,6 +499,10 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
479
499
private onIndexingPolicyContentChange = ( newIndexingPolicy : DataModels . IndexingPolicy ) : void =>
480
500
this . setState ( { indexingPolicyContent : newIndexingPolicy } ) ;
481
501
502
+ private onThroughputBucketsSaveableChange = ( isSaveable : boolean ) : void => {
503
+ this . setState ( { isThroughputBucketsSaveable : isSaveable } ) ;
504
+ } ;
505
+
482
506
private resetShouldDiscardContainerPolicies = ( ) : void => this . setState ( { shouldDiscardContainerPolicies : false } ) ;
483
507
484
508
private resetShouldDiscardIndexingPolicy = ( ) : void => this . setState ( { shouldDiscardIndexingPolicy : false } ) ;
@@ -749,9 +773,13 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
749
773
] as DataModels . ComputedProperties ;
750
774
}
751
775
776
+ const throughputBuckets = this . offer ?. throughputBuckets ;
777
+
752
778
return {
753
779
throughput : offerThroughput ,
754
780
throughputBaseline : offerThroughput ,
781
+ throughputBuckets,
782
+ throughputBucketsBaseline : throughputBuckets ,
755
783
changeFeedPolicy : changeFeedPolicy ,
756
784
changeFeedPolicyBaseline : changeFeedPolicy ,
757
785
timeToLive : timeToLive ,
@@ -839,6 +867,10 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
839
867
this . setState ( { throughput : newThroughput , throughputError } ) ;
840
868
} ;
841
869
870
+ private onThroughputBucketChange = ( throughputBuckets : DataModels . ThroughputBucket [ ] ) : void => {
871
+ this . setState ( { throughputBuckets } ) ;
872
+ } ;
873
+
842
874
private onAutoPilotSelected = ( isAutoPilotSelected : boolean ) : void =>
843
875
this . setState ( { isAutoPilotSelected : isAutoPilotSelected } ) ;
844
876
@@ -1029,6 +1061,24 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
1029
1061
}
1030
1062
}
1031
1063
1064
+ if ( this . throughputBucketsEnabled && this . state . isThroughputBucketsSaveable ) {
1065
+ const updatedOffer : DataModels . Offer = await updateOffer ( {
1066
+ databaseId : this . collection . databaseId ,
1067
+ collectionId : this . collection . id ( ) ,
1068
+ currentOffer : this . collection . offer ( ) ,
1069
+ autopilotThroughput : this . collection . offer ( ) . autoscaleMaxThroughput
1070
+ ? this . collection . offer ( ) . autoscaleMaxThroughput
1071
+ : undefined ,
1072
+ manualThroughput : this . collection . offer ( ) . manualThroughput
1073
+ ? this . collection . offer ( ) . manualThroughput
1074
+ : undefined ,
1075
+ throughputBuckets : this . state . throughputBuckets ,
1076
+ } ) ;
1077
+ this . collection . offer ( updatedOffer ) ;
1078
+ this . offer = updatedOffer ;
1079
+ this . setState ( { isThroughputBucketsSaveable : false } ) ;
1080
+ }
1081
+
1032
1082
if ( this . state . isScaleSaveable ) {
1033
1083
const updateOfferParams : DataModels . UpdateOfferParams = {
1034
1084
databaseId : this . collection . databaseId ,
@@ -1209,6 +1259,13 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
1209
1259
onConflictResolutionDirtyChange : this . onConflictResolutionDirtyChange ,
1210
1260
} ;
1211
1261
1262
+ const throughputBucketsComponentProps : ThroughputBucketsComponentProps = {
1263
+ currentBuckets : this . state . throughputBuckets ,
1264
+ throughputBucketsBaseline : this . state . throughputBucketsBaseline ,
1265
+ onBucketsChange : this . onThroughputBucketChange ,
1266
+ onSaveableChange : this . onThroughputBucketsSaveableChange ,
1267
+ } ;
1268
+
1212
1269
const partitionKeyComponentProps : PartitionKeyComponentProps = {
1213
1270
database : useDatabases . getState ( ) . findDatabaseWithId ( this . collection . databaseId ) ,
1214
1271
collection : this . collection ,
@@ -1271,6 +1328,13 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
1271
1328
} ) ;
1272
1329
}
1273
1330
1331
+ if ( this . throughputBucketsEnabled ) {
1332
+ tabs . push ( {
1333
+ tab : SettingsV2TabTypes . ThroughputBucketsTab ,
1334
+ content : < ThroughputBucketsComponent { ...throughputBucketsComponentProps } /> ,
1335
+ } ) ;
1336
+ }
1337
+
1274
1338
const pivotProps : IPivotProps = {
1275
1339
onLinkClick : this . onPivotChange ,
1276
1340
selectedKey : SettingsV2TabTypes [ this . state . selectedTab ] ,
0 commit comments