Skip to content

Commit 1c945e9

Browse files
fix: limits check should also support unlimited agreements (#806)
1 parent 9ab4084 commit 1c945e9

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

src/app/component-library/catalog/asset-detail-dialog/asset-detail-dialog-data.service.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export class AssetDetailDialogDataService {
4848
};
4949
}
5050

51-
dataOfferDetails(dataOffer: DataOffer): AssetDetailDialogData {
51+
dataOfferDetails(
52+
dataOffer: DataOffer,
53+
consumingLimitsExceeded: boolean,
54+
): AssetDetailDialogData {
5255
const asset = dataOffer.asset;
5356
const propertyGridGroups = [
5457
this.assetPropertyGridGroupBuilder.buildAssetPropertiesGroup(asset, null),
@@ -66,6 +69,7 @@ export class AssetDetailDialogDataService {
6669
asset: asset,
6770
dataOffer,
6871
propertyGridGroups,
72+
consumingLimitsExceeded,
6973
};
7074
}
7175

src/app/component-library/catalog/asset-detail-dialog/asset-detail-dialog-data.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface AssetDetailDialogData {
88
propertyGridGroups: PropertyGridGroup[];
99
asset: UiAssetMapped;
1010
dataOffer?: DataOffer;
11+
consumingLimitsExceeded?: boolean;
1112
contractAgreement?: ContractAgreementCardMapped;
1213
showDeleteButton?: boolean;
1314
showEditButton?: boolean;

src/app/component-library/catalog/asset-detail-dialog/asset-detail-dialog.component.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,9 @@ export class AssetDetailDialogComponent implements OnDestroy {
101101

102102
setData(data: AssetDetailDialogData) {
103103
this.data = data;
104+
this.limitsExceeded = data.consumingLimitsExceeded ?? null;
104105
this.asset = this.data.asset;
105106
this.propGroups = this.data.propertyGridGroups;
106-
107-
if (this.limitsExceeded == null && this.data.type === 'data-offer') {
108-
this.connectorLimitsService
109-
.isConsumingAgreementLimitExceeded()
110-
.subscribe((limitsExceeded) => {
111-
this.limitsExceeded = limitsExceeded;
112-
});
113-
}
114107
}
115108

116109
onContactClick() {

src/app/core/services/connector-limits.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ export class ConnectorLimitsService {
2626
const max = limits.maxActiveConsumingContractAgreements;
2727
const current = limits.numActiveConsumingContractAgreements;
2828

29-
return max != null && current >= max;
29+
return max != null && max >= 0 && current >= max;
3030
};
3131
}

src/app/routes/connector-ui/catalog-browser-page/catalog-browser-page/catalog-browser-page.component.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import {
77
Subject,
88
distinctUntilChanged,
99
sampleTime,
10+
switchMap,
1011
} from 'rxjs';
1112
import {filter, map} from 'rxjs/operators';
1213
import {AssetDetailDialogDataService} from '../../../../component-library/catalog/asset-detail-dialog/asset-detail-dialog-data.service';
1314
import {AssetDetailDialogService} from '../../../../component-library/catalog/asset-detail-dialog/asset-detail-dialog.service';
15+
import {ConnectorLimitsService} from '../../../../core/services/connector-limits.service';
1416
import {DataOffer} from '../../../../core/services/models/data-offer';
1517
import {value$} from '../../../../core/utils/form-group-utils';
1618
import {CatalogBrowserFetchDetailDialogComponent} from '../catalog-browser-fetch-detail-dialog/catalog-browser-fetch-detail-dialog.component';
@@ -38,6 +40,7 @@ export class CatalogBrowserPageComponent implements OnInit, OnDestroy {
3840
private catalogBrowserPageService: CatalogBrowserPageService,
3941
private catalogApiUrlService: CatalogApiUrlService,
4042
private matDialog: MatDialog,
43+
private connectorLimitsService: ConnectorLimitsService,
4144
) {}
4245

4346
ngOnInit(): void {
@@ -54,10 +57,18 @@ export class CatalogBrowserPageComponent implements OnInit, OnDestroy {
5457
}
5558

5659
onDataOfferClick(dataOffer: DataOffer) {
57-
const data = this.assetDetailDialogDataService.dataOfferDetails(dataOffer);
58-
this.assetDetailDialogService
59-
.open(data, this.ngOnDestroy$)
60-
.pipe(filter((it) => !!it?.refreshList))
60+
this.connectorLimitsService
61+
.isConsumingAgreementLimitExceeded()
62+
.pipe(
63+
switchMap((isConsumingLimitsExceeded) => {
64+
const data = this.assetDetailDialogDataService.dataOfferDetails(
65+
dataOffer,
66+
isConsumingLimitsExceeded,
67+
);
68+
return this.assetDetailDialogService.open(data, this.ngOnDestroy$);
69+
}),
70+
filter((it) => !!it?.refreshList),
71+
)
6172
.subscribe(() => this.fetch$.next(null));
6273
}
6374

0 commit comments

Comments
 (0)