feat(notifications): redirect admin notifications to the manager ui
If an admin clicks on an notification then the redirect is pointing to the main ui to directly approve an API
Closes:
MODIFY
src/app/components/notifications/notifications.component.html
src/app/components/notifications/notifications.component.html
{{ 'NOTIFICATION.COLUMN_TITLE.MESSAGE' | translate }}
</th>
<td mat-cell *matCellDef="let notification">
- <span
- class="notifications-message"
- (click)="redirectToClient(notification)"
- >{{ mapNotificationMessage(notification) }}</span
- >
+ <span class="notifications-message" (click)="redirect(notification)">{{
+ mapNotificationMessage(notification)
+ }}</span>
</td>
</ng-container>
<ng-container matColumnDef="date">

MODIFY
src/app/components/notifications/notifications.component.ts
src/app/components/notifications/notifications.component.ts
@@ -152,9 +152,19 @@ export class NotificationsComponent implements OnInit {
});
}
- public redirectToClient(notification: INotificationsDto): void {
- let routerFragment = '';
+ public redirect(notification: INotificationsDto): void {
+ switch (notification.reason) {
+ case 'apiman.client.contract.approval.request':
+ this.redirectAdminApprovalRequest(notification);
+ break;
+ default:
+ this.redirectToMyClientsPage(notification);
+ break;
+ }
+ }
+ private redirectToMyClientsPage(notification: INotificationsDto): void {
+ let routerFragment = '';
if (notification.payload.clientId && notification.payload.clientVersion) {
routerFragment = `${notification.payload.clientId}-${notification.payload.clientVersion}`;
}
@@ -163,15 +173,27 @@ export class NotificationsComponent implements OnInit {
notification.payload.apiId &&
notification.payload.apiVersion
) {
- routerFragment =
- routerFragment +
- `-${notification.payload.apiId}-${notification.payload.apiVersion}`;
+ routerFragment += `-${notification.payload.apiId}-${notification.payload.apiVersion}`;
}
void this.router.navigate(['applications'], {
fragment: routerFragment
});
}
+ private redirectAdminApprovalRequest(notification: INotificationsDto): void {
+ if (
+ notification.payload &&
+ notification.payload.apiOrgId &&
+ notification.payload.apiId &&
+ notification.payload.apiVersion
+ ) {
+ // TODO (fvolk): get endpoint from Manger REST API or from the notification
+ // prettier-ignore
+ const url = `${this.configService.getManagerUiEndpoint()}/orgs/${notification.payload.apiOrgId}/apis/${notification.payload.apiId}/${notification.payload.apiVersion}/contracts`;
+ window.open(url, '_blank');
+ }
+ }
+
public convertTimestamp(timestamp: string): string {
return DateTime.fromISO(timestamp).toRelative({
locale: this.configService.getLanguage()

MODIFY
src/app/interfaces/IConfig.ts
src/app/interfaces/IConfig.ts
@@ -19,6 +19,7 @@ export interface IConfig {
supportedLanguages: string[];
theme: string;
endpoint: string;
+ managerUiEndpoint?: string; // TODO (fvolk)
backendRoles: string[];
hero: IHero;
navigation: INavigation;

MODIFY
src/app/services/config/config.service.ts
src/app/services/config/config.service.ts
@@ -78,6 +78,13 @@ export class ConfigService {
return this.config.endpoint;
}
+ // TODO (fvolk)
+ getManagerUiEndpoint(): string {
+ return this.config.managerUiEndpoint
+ ? this.config.managerUiEndpoint
+ : `${this.config.endpoint}ui/api-manager`;
+ }
+
getBackendRoles(): string[] {
return this.config.backendRoles;
}

feat(notifications): redirect admin notifications to the manager ui

If an admin clicks on an notification then the redirect is pointing to the main ui to directly approve an API

Closes: #131