Skip to content

Commit

Permalink
Fix type error in switchMap responses array and update subscribed cat…
Browse files Browse the repository at this point in the history
…alogue test
  • Loading branch information
joe-crawford committed Jan 31, 2023
1 parent aae100b commit c1a9d42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import {FormControl, FormGroup, Validators} from '@angular/forms';
import {Title} from '@angular/platform-browser';
import {
SubscribedCatalogue,
SubscribedCatalogueTypeResponse,
SubscribedCatalogueResponse,
Uuid, SubscribedCatalogueAuthenticationTypeResponse
Uuid
} from '@maurodatamapper/mdm-resources';
import {MdmResourcesService} from '@mdm/modules/resources';
import {
Expand All @@ -35,6 +34,7 @@ import {EditingService} from '@mdm/services/editing.service';
import {UIRouterGlobals} from '@uirouter/core';
import {EMPTY, forkJoin, Observable, of} from 'rxjs';
import {catchError, map, switchMap} from 'rxjs/operators';
import {MdmResponse} from '../../../../../mdm-resources/src';

@Component({
selector: 'mdm-subscribed-catalogue',
Expand Down Expand Up @@ -116,19 +116,19 @@ export class SubscribedCatalogueComponent implements OnInit {
subscribedCatalogueType: this.type.value,
subscribedCatalogueAuthenticationType: this.authenticationType.value,
refreshPeriod: this.refreshPeriod.value
}
};
if (this.authenticationType.value === this.noAuthAuthenticationType) {
return baseRequest
return baseRequest;
} else if (this.authenticationType.value === this.apiKeyAuthenticationType) {
return {...baseRequest, ...{apiKey: this.apiKey.value}}
return {...baseRequest, ...{apiKey: this.apiKey.value}};
} else if (this.authenticationType.value === this.oAuthClientCredentialsAuthenticationType) {
return {
...baseRequest, ...{
tokenUrl: this.tokenUrl.value,
clientId: this.clientId.value,
clientSecret: this.clientSecret.value,
}
}
};
}
}

Expand All @@ -146,7 +146,7 @@ export class SubscribedCatalogueComponent implements OnInit {
this.resources.subscribedCatalogues.authenticationTypes()
])
.pipe(
switchMap(([typesResponse, authenticationTypesResponse]: [SubscribedCatalogueTypeResponse, SubscribedCatalogueAuthenticationTypeResponse]) => {
switchMap(([typesResponse, authenticationTypesResponse]: MdmResponse<string[]>[]) => {
this.connectionTypes = typesResponse.body;
this.authenticationTypes = this.supportedAuthenticationTypes.filter(authType => authenticationTypesResponse.body.includes(authType));

Expand Down Expand Up @@ -236,7 +236,7 @@ export class SubscribedCatalogueComponent implements OnInit {
Validators.required // eslint-disable-line @typescript-eslint/unbound-method
]),
authenticationType: new FormControl(catalogue?.subscribedCatalogueAuthenticationType, [
Validators.required
Validators.required // eslint-disable-line @typescript-eslint/unbound-method
]),
apiKey: new FormControl(catalogue?.apiKey),
tokenUrl: new FormControl(catalogue?.tokenUrl),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe('SubscribedCatalogueDetailComponent', () => {
component.subscribedCatalogue = {
url: '',
label: '',
subscribedCatalogueType: 'test'
subscribedCatalogueType: 'test',
subscribedCatalogueAuthenticationType: 'test'
};
fixture.detectChanges();
});
Expand Down

0 comments on commit c1a9d42

Please sign in to comment.