Skip to content

Commit

Permalink
feat: dont show negotiate button for own connector endpoints (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
kulgg committed Jan 17, 2024
1 parent 0b85d1c commit 42c01d2
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ MDS feature release for Connector UI and Broker UI

- Asset descriptions now support Markdown
- Asset metadata is now editable
- Negotiate button is no longer shown for own connector endpoints
- Broker: Catalog now supports list view
- Broker: Connectors page now shows organization names and connector IDs

Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@angular/router": "^14.3.0",
"@ng-apimock/core": "^3.11.0",
"@ngxs/store": "^3.8.1",
"@sovity.de/broker-server-client": "0.20240116.140046-main-787cf146",
"@sovity.de/edc-client": "0.20240109.181620-main-78f67a69",
"@sovity.de/broker-server-client": "0.20240117.145014-main-d0484d54",
"@sovity.de/edc-client": "0.20240117.123601-main-45d15241",
"clean-deep": "^3.4.0",
"date-fns": "^2.30.0",
"dotenv": "^16.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,44 +94,55 @@
<!-- Contract Offers -->
<contract-offer-mini-list
*ngIf="data.type === 'data-offer'"
[contractOffers]="data.dataOffer!.contractOffers"
[data]="data.dataOffer!"
(negotiateClick)="onNegotiateClick($event)">
</contract-offer-mini-list>
</div>

<mat-dialog-actions>
<div class="w-full flex flex-row justify-end">
<div>
<div class="flex gap-1 items-center">
<button mat-button [mat-dialog-close]="null" [disabled]="loading">
Close
</button>

<button
<ng-container
*ngIf="
data.type === 'data-offer' &&
data.dataOffer?.contractOffers?.length === 1
"
mat-raised-button
color="primary"
[disabled]="
contractNegotiationService.negotiationState(
data.dataOffer!.contractOffers[0]
) != 'ready'
"
[ngSwitch]="
contractNegotiationService.negotiationState(
data.dataOffer!.contractOffers[0]
)
"
(click)="onNegotiateClick(data.dataOffer!.contractOffers[0])">
<ng-container *ngSwitchCase="'ready'">Negotiate</ng-container>
<ng-container *ngSwitchCase="'negotiating'">
Negotiating...
</ng-container>
<ng-container *ngSwitchCase="'negotiated'">
Successfully Negotiated
</ng-container>
</button>
data.dataOffer!.contractOffers.length === 1
">
<button
*ngIf="data.asset.isOwnConnector"
disabled
mat-raised-button
matTooltip="Cannot negotiate contracts with your own connector.">
Negotiate
</button>

<button
*ngIf="!data.asset.isOwnConnector"
mat-raised-button
color="primary"
[disabled]="
contractNegotiationService.negotiationState(
data.dataOffer!.contractOffers[0]
) != 'ready'
"
[ngSwitch]="
contractNegotiationService.negotiationState(
data.dataOffer!.contractOffers[0]
)
"
(click)="onNegotiateClick(data.dataOffer!.contractOffers[0])">
<ng-container *ngSwitchCase="'ready'">Negotiate</ng-container>
<ng-container *ngSwitchCase="'negotiating'">
Negotiating...
</ng-container>
<ng-container *ngSwitchCase="'negotiated'">
Successfully Negotiated
</ng-container>
</button>
</ng-container>

<button
*ngIf="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<ng-container *ngIf="!contractOffers?.length">
<ng-container *ngIf="!data.contractOffers.length">
<div class="flex flex-row flex-wrap property-grid-group-title">
Contract Offers
</div>
<i>No contract offers available.</i>
</ng-container>

<ng-container *ngFor="let contractOffer of contractOffers; let i = index">
<ng-container *ngFor="let contractOffer of data.contractOffers; let i = index">
<div
class="flex flex-row items-center space-x-[5px] property-grid-group-title">
<span> Contract Offer {{ contractOffers.length >= 2 ? i + 1 : '' }} </span>
<span>
Contract Offer {{ data.contractOffers.length >= 2 ? i + 1 : '' }}
</span>

<mat-progress-spinner
*ngIf="contractNegotiationService.isBusy(contractOffer)"
Expand All @@ -24,13 +26,15 @@
[props]="contractOffer.properties"></property-grid>

<div
*ngIf="contractOffers.length > 1"
*ngIf="data.contractOffers.length > 1"
class="flex flex-row justify-end mt-[15px]">
<button
*ngIf="!data.asset.isOwnConnector"
mat-raised-button
color="primary"
[disabled]="
contractNegotiationService.negotiationState(contractOffer) != 'ready'
this.contractNegotiationService.negotiationState(contractOffer) !=
'ready'
"
[ngSwitch]="contractNegotiationService.negotiationState(contractOffer)"
(click)="negotiateClick.emit(contractOffer)">
Expand All @@ -42,5 +46,12 @@
Successfully Negotiated
</ng-container>
</button>
<button
*ngIf="data.asset.isOwnConnector"
disabled
mat-raised-button
matTooltip="Cannot negotiate contracts with your own connector.">
Negotiate
</button>
</div>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Input,
Output,
} from '@angular/core';
import {DataOffer} from 'src/app/core/services/models/data-offer';
import {ContractNegotiationService} from '../../../core/services/contract-negotiation.service';
import {ContractOffer} from '../../../core/services/models/contract-offer';

Expand All @@ -14,7 +15,7 @@ import {ContractOffer} from '../../../core/services/models/contract-offer';
})
export class ContractOfferMiniListComponent {
@Input()
contractOffers!: ContractOffer[];
data!: DataOffer;

@HostBinding('class.flex')
@HostBinding('class.flex-col')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const createAsset = (asset: UiAssetCreateRequest): IdResponseDto => {
...createAssetMetadata(assetId, asset),
connectorEndpoint: 'https://my-connector/api/dsp',
participantId: 'MDSL1234XX.C1234XX',
isOwnConnector: false,
creatorOrganizationName: 'My Org',
});
return {
Expand Down Expand Up @@ -63,6 +64,7 @@ function createAssetMetadata(
| 'assetId'
| 'assetJsonLd'
| 'connectorEndpoint'
| 'isOwnConnector'
| 'creatorOrganizationName'
| 'httpDatasourceHintsProxyBody'
| 'httpDatasourceHintsProxyMethod'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let dataOffers: UiDataOffer[] = [
participantId: 'MDSL1234XX.C1234XX',
contractOffers: [
{
contractOfferId: 'test-contract-offer-3',
contractOfferId: 'test-contract-offer-2',
policy: TestPolicies.failedMapping,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,34 @@ This is a short description text that should be fully rendered without being **c
connectorEndpoint: 'https://my-other-connector/api/dsp',
participantId: 'MDSL1234XX.C1234XX',
creatorOrganizationName: 'my-other-connector',
isOwnConnector: true,
};

export const short: UiAsset = {
assetId: 'data-sample-ckd-skd-demands-2023-Feb',
title: 'data-sample-ckd-skd-demands-2023-Feb',
connectorEndpoint: 'https://my-other-connector/api/dsp',
participantId: 'MDSL1234XX.C1234XX',
participantId: 'MDSL1234XX.C1235XX',
creatorOrganizationName: 'my-other-connector',
description: shortMarkdownDescription,
descriptionShortText:
'Short Description This is a short description text that should be fully rendered without being collapsed. No show more button should be visible.',
isOwnConnector: false,
};

export const full: UiAsset = {
assetId: 'ckd-skd-demands-2023-Jan',
title: 'CKD / SKD Demands January 2023',
connectorEndpoint: 'https://my-other-connector/api/dsp',
participantId: 'MDSL1234XX.C1234XX',
participantId: 'MDSL1234XX.C1236XX',
version: '2023-A-Program',
creatorOrganizationName: 'My-German-OEM',
keywords: ['automotive', 'part-demands', '2023', 'January'],
mediaType: 'application/json',
description: markdownDescription,
descriptionShortText:
'Part demands for CKD/SKD parts January 2023 Split by plant / day / model code. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.',
isOwnConnector: true,
language: 'https://w3id.org/idsa/code/EN',
publisherHomepage:
'https://teamabc.departmentxyz.my-german-oem.de/offers/ckd-skd-demands',
Expand Down Expand Up @@ -135,6 +138,7 @@ This is a short description text that should be fully rendered without being **c
participantId: entry.participantId,
connectorEndpoint: entry.connectorEndpoint,
creatorOrganizationName: entry.participantId,
isOwnConnector: entry.isOwnConnector,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const transferProcessAsset = (transferProcessId: string): UiAsset => {
title: assetId,
participantId: 'unknown',
connectorEndpoint: 'https://unknown/api/dsp',
isOwnConnector: false,
creatorOrganizationName: 'unknown',
};

Expand Down

0 comments on commit 42c01d2

Please sign in to comment.