Skip to content

Commit

Permalink
Merge branch 'feature/SHIBUI-1526' into feature/SHIBUI-1528
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 22, 2019
2 parents a0304bd + 7381580 commit 866dadc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 47 deletions.
2 changes: 2 additions & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ message.restoring-this-version-will-copy=Restoring this version will copy the Ve

message.invalid-regex-pattern=Invalid Regular Expression

message.invalid-signing=Warning! If neither the Assertions or the Response are signed the service will not be able to verify a SAML response from the Identity Provider.

tooltip.entity-id=Entity ID
tooltip.service-provider-name=Service Provider Name (Dashboard Display Only)
tooltip.force-authn=Disallows use (or reuse) of authentication results and login flows that don\u0027t provide a real-time proof of user presence in the login process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ describe('Metadata Source Base class', () => {
expect(Object.keys(getValidators([]))).toEqual([
'/',
'/entityId',
'/organization/name',
'/organization/displayName',
'/organization/url'
'/relyingPartyOverrides'
]);
});
});
Expand Down
49 changes: 13 additions & 36 deletions ui/src/app/metadata/domain/model/wizards/metadata-source-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,39 +64,6 @@ export class MetadataSourceBase implements Wizard<MetadataResolver> {
}

getValidators(entityIdList: string[]): { [key: string]: any } {
const checkRequiredChild = (value, property, form) => {
if (!value) {
return {
code: 'REQUIRED',
path: `#${property.path}`,
message: `message.required`,
params: [value]
};
}
return null;
};
const checkRequiredChildren = (value, property, form) => {
let errors;
Object.keys(value).forEach((item, index, all) => {
const error = checkRequiredChild(item, { path: `${index}` }, form);
if (error) {
errors = errors || [];
errors.push(error);
}
});
return errors;
};
const checkOrg = (value, property, form) => {
const org = property.parent;
const orgValue = org.value || {};
const err = Object.keys(orgValue) && !value ? {
code: 'ORG_INCOMPLETE',
path: `#${property.path}`,
message: `message.org-incomplete`,
params: [value]
} : null;
return err;
};
const validators = {
'/': (value, property, form_current) => {
let errors;
Expand All @@ -122,9 +89,19 @@ export class MetadataSourceBase implements Wizard<MetadataResolver> {
} : null;
return err;
},
'/organization/name': checkOrg,
'/organization/displayName': checkOrg,
'/organization/url': checkOrg
'/relyingPartyOverrides': (value, property, form) => {
let errors;
if (!value.signAssertion && value.dontSignResponse) {
errors = [];
errors.push({
code: 'INVALID_SIGNING',
path: `#${property.path}`,
message: 'message.invalid-signing',
params: [value]
});
}
return errors;
}
};
return validators;
}
Expand Down
7 changes: 1 addition & 6 deletions ui/src/app/metadata/metadata.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { Store } from '@ngrx/store';

import * as fromRoot from '../app.reducer';

@Component({
selector: 'metadata-page',
Expand All @@ -10,7 +7,5 @@ import * as fromRoot from '../app.reducer';
styleUrls: []
})
export class MetadataPageComponent {
constructor(
private store: Store<fromRoot.State>
) {}
constructor() {}
}
3 changes: 3 additions & 0 deletions ui/src/app/schema-form/widget/object/object.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="">
<ng-container *ngFor="let error of customErrors$ | async">
<div class="alert alert-danger">{{error.message | translate}}</div>
</ng-container>
<div class="row">
<ng-container *ngFor="let fieldset of formProperty.schema.fieldsets; let i = index;">
<fieldset
Expand Down
29 changes: 27 additions & 2 deletions ui/src/app/schema-form/widget/object/object.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
import { Component } from '@angular/core';
import { Component, AfterViewInit } from '@angular/core';

import { ObjectWidget } from 'ngx-schema-form';
import { filter, map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { FormError } from '../array/array.component';

/* tslint:disable */
@Component({
selector: 'custom-object',
templateUrl: `./object.component.html`
})
export class CustomObjectWidget extends ObjectWidget {}
export class CustomObjectWidget extends ObjectWidget implements AfterViewInit {

customErrors$: Observable<FormError[]>;

constructor() {
super();
}

ngAfterViewInit(): void {
super.ngAfterViewInit();
if (this.formProperty) {
this.customErrors$ = this.formProperty.errorsChanges
.pipe(
map(errors => errors ? errors : []),
map(errors => {
return errors.filter(err => err.path.replace('#', '') === (this.formProperty.path));
}),
map(errors => Object.values(errors.reduce((collection, error) => ({ ...collection, [error.code]: error }), {}))),
map(errors => errors.length ? errors : null)
) as Observable<FormError[]>;
}
}
}

0 comments on commit 866dadc

Please sign in to comment.