@@ -147,7 +147,9 @@ export class OrgQuotaEditor extends BtrixElement {
147
147
width : "1fr" ,
148
148
renderCell : ( { item : { key, initialValue } } ) =>
149
149
html `< span class ="text-xs text-neutral-600 "
150
- > ${ this . format ( initialValue , LABELS [ key ] . type , true ) } </ span
150
+ > ${ this . format ( initialValue , LABELS [ key ] . type , {
151
+ asNumber : true ,
152
+ } ) } </ span
151
153
> ` ,
152
154
} ,
153
155
{
@@ -202,7 +204,9 @@ export class OrgQuotaEditor extends BtrixElement {
202
204
width : "1fr" ,
203
205
renderCell : ( { item : { key, currentValue : current } } ) =>
204
206
html `< span class ="cursor-not-allowed "
205
- > ${ this . format ( current , LABELS [ key ] . type , true ) } </ span
207
+ > ${ this . format ( current , LABELS [ key ] . type , {
208
+ asNumber : true ,
209
+ } ) } </ span
206
210
> ` ,
207
211
renderEditCell : ( { item, value : _value } ) => {
208
212
const key = item . key ;
@@ -251,6 +255,11 @@ export class OrgQuotaEditor extends BtrixElement {
251
255
maxPagesPerCrawl : org_quotas . maxPagesPerCrawl ,
252
256
storageQuota : org_quotas . storageQuota ,
253
257
} ;
258
+ const mismatchesCurrentPlan =
259
+ isCurrentSubscription &&
260
+ ( Object . entries ( presets ) as Entries < typeof presets > ) . some (
261
+ ( [ k , v ] ) => v !== quotas [ k ] ,
262
+ ) ;
254
263
return html `< btrix-popover placement ="top ">
255
264
< sl-button
256
265
@click =${ ( ) => {
@@ -271,6 +280,13 @@ export class OrgQuotaEditor extends BtrixElement {
271
280
slot ="prefix "
272
281
> </ sl-icon > `
273
282
: null }
283
+ ${ mismatchesCurrentPlan
284
+ ? html `< sl-icon
285
+ name ="exclamation-triangle "
286
+ slot ="suffix "
287
+ class ="text-warning-600 "
288
+ > </ sl-icon > `
289
+ : null }
274
290
</ sl-button >
275
291
< div slot ="content ">
276
292
< header class ="mb-2 font-medium ">
@@ -289,18 +305,38 @@ export class OrgQuotaEditor extends BtrixElement {
289
305
< tbody >
290
306
${ (
291
307
Object . entries ( presets ) as Entries < typeof presets >
292
- ) . map (
293
- ( [ key , value ] ) => html `
308
+ ) . map ( ( [ key , value ] ) => {
309
+ const currentValue = this . format (
310
+ quotas [ key ] ,
311
+ LABELS [ key ] . type ,
312
+ { plain : true } ,
313
+ ) ;
314
+ return html `
294
315
< tr >
295
316
< td class ="pr-2 "> ${ LABELS [ key ] . label } </ td >
296
317
< td class ="pr-2 ">
297
318
${ this . format ( value , LABELS [ key ] . type ) }
319
+ ${ mismatchesCurrentPlan &&
320
+ value !== quotas [ key ]
321
+ ? html `< span class ="text-warning-600 "
322
+ > (${ msg (
323
+ html `currently ${ currentValue } ` ,
324
+ ) } )</ span
325
+ > `
326
+ : null }
298
327
</ td >
299
328
</ tr >
300
- ` ,
301
- ) }
329
+ ` ;
330
+ } ) }
302
331
</ tbody >
303
332
</ table >
333
+ ${ mismatchesCurrentPlan
334
+ ? html `< p class ="mt-2 font-semibold text-warning-600 ">
335
+ ${ msg (
336
+ "Quotas for this org do not match its current plan." ,
337
+ ) }
338
+ </ p > `
339
+ : null }
304
340
</ div >
305
341
</ btrix-popover > ` ;
306
342
} ) ,
@@ -353,12 +389,23 @@ export class OrgQuotaEditor extends BtrixElement {
353
389
</ btrix-dialog > ` ;
354
390
}
355
391
356
- private format ( v : number , type : "bytes" | "number" , isInitialValue = true ) {
357
- if ( v <= 0 )
358
- return isInitialValue
359
- ? html `< span class ="text-xs text-neutral-600 "> ${ msg ( "Unset" ) } </ span > `
360
- : html `< span class ="text-xs text-neutral-400 "> ${ msg ( "0" ) } </ span > ` ;
392
+ private format (
393
+ v : number ,
394
+ type : "bytes" | "number" ,
395
+ options : { plain ?: boolean ; asNumber ?: boolean } = { } ,
396
+ ) {
397
+ const { plain, asNumber } = options ;
361
398
const fn = type === "bytes" ? this . localize . bytes : this . localize . number ;
399
+ if ( plain ) {
400
+ if ( v <= 0 ) {
401
+ return asNumber ? fn ( 0 ) : msg ( "Unset" ) ;
402
+ }
403
+ return fn ( v ) ;
404
+ }
405
+ if ( v <= 0 )
406
+ return asNumber
407
+ ? html `< span class ="text-xs text-neutral-400 "> ${ fn ( 0 ) } </ span > `
408
+ : html `< span class ="text-xs text-neutral-600 "> ${ msg ( "Unset" ) } </ span > ` ;
362
409
return fn ( v ) ;
363
410
}
364
411
0 commit comments