Skip to content

Commit

Permalink
Merge branch 'master' into SHIBUI-906
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Nov 6, 2018
2 parents 0e5b35c + 3485ee5 commit c391456
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 23 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ tooltip.backing-file=Specifies where the backing file is located. If the remote
tooltip.backup-file-init-refresh-delay=Delay duration after which to schedule next HTTP refresh when initialized from the backing file.
tooltip.require-valid-metadata=Whether candidate metadata found by the resolver must be valid in order to be returned (where validity is implementation specific, but in SAML cases generally depends on a validUntil attribute.) If this flag is true, then invalid candidate metadata will not be returned.
tooltip.fail-fast-init=Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.
tooltip.use-default-predicate-reg=Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.
tooltip.use-default-predicate-reg=Flag which determines whether the default CriterionPredicateRegistry will be used if a custom one is not supplied explicitly.
tooltip.satisfy-any-predicates=Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).
tooltip.enable-provider-upon-saving=Enable Metadata Provider upon saving?

Expand Down
20 changes: 17 additions & 3 deletions ui/src/app/metadata/domain/component/unsaved-entity.dialog.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
<ng-container>
<ng-container [ngSwitch]="message">
<div aria-label="Save your information? modal" role="region" tabindex="0">
<div class="modal-header">
<h4 class="modal-title" translate="message.unsaved-dialog-title">Save your information?</h4>
</div>
<div class="modal-body">
<p translate="message.unsaved-editor">You have not saved your changes. If you exit this screen, your changes will be lost.</p>
<p *ngSwitchCase="'resolver'">
<translate-i18n key="message.unsaved-source-1">
You have not completed the wizard!
Do you wish to save this information?
You can finish the wizard later by clicking the "Edit"
</translate-i18n>
<i class="fa fa-fw fa-edit"></i>
<translate-i18n key="message.unsaved-source-2">icon on the dashboard.</translate-i18n>
</p>
<p *ngSwitchDefault [translate]="message">You have not saved your changes. If you exit this screen, your changes will be lost.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="this.close()">
<span translate="action.discard-changes" aria-label="Discard changes, go back to dashboard">Discard Changes</span>
<span *ngSwitchCase="'resolver'" translate="action.finish-later" [attr.aria-label]="'action.finish-later' | translate">
Finish Later
</span>
<span *ngSwitchDefault translate="action.discard-changes" [attr.aria-label]="'action.discard-changes' | translate">
Discard Changes
</span>
</button>
<button type="button" class="btn btn-secondary" (click)="this.dismiss()" translate="action.cancel" aria-label="Close modal and go back to editing">Cancel</button>
</div>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/metadata/domain/component/unsaved-entity.dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { Subject } from 'rxjs/Subject';
export class UnsavedEntityComponent {
readonly subject: Subject<boolean> = new Subject<boolean>();

@Input() message;

constructor(
public activeModal: NgbActiveModal
) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnDestroy } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { withLatestFrom, map, distinctUntilChanged, skipWhile } from 'rxjs/operators';
import { withLatestFrom, map, distinctUntilChanged, skipWhile, filter } from 'rxjs/operators';
import { Store } from '@ngrx/store';

import * as fromProvider from '../reducer';
Expand Down Expand Up @@ -42,7 +42,9 @@ export class ProviderWizardStepComponent implements OnDestroy {
constructor(
private store: Store<fromProvider.ProviderState>,
) {
this.schema$ = this.store.select(fromWizard.getParsedSchema);
this.schema$ = this.store.select(fromWizard.getSchema).pipe(
filter(s => s && Object.keys(s.properties).length > 0)
);
this.definition$ = this.store.select(fromWizard.getWizardDefinition);
this.changes$ = this.store.select(fromProvider.getEntityChanges);

Expand Down
9 changes: 0 additions & 9 deletions ui/src/app/metadata/provider/model/base.provider.form.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Wizard } from '../../../wizard/model';
import { BaseMetadataProvider } from '../../domain/model/providers';
import { UriValidator } from '../../../shared/validation/uri.validator';

export const BaseMetadataProviderEditor: Wizard<BaseMetadataProvider> = {
label: 'BaseMetadataProvider',
Expand Down Expand Up @@ -30,14 +29,6 @@ export const BaseMetadataProviderEditor: Wizard<BaseMetadataProvider> = {
params: [value]
} : null;
return err;
},
'/metadataURL': (value, property, form) => {
return !UriValidator.isUri(value) ? {
code: 'INVALID_URI',
path: `#${property.path}`,
message: 'message.uri-valid-format',
params: [value]
} : null;
}
};
return validators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ describe('FileBackedHttpMetadataProviderWizard', () => {
expect(Object.keys(getValidators([]))).toEqual([
'/',
'/name',
'/metadataURL',
'/xmlId'
'/xmlId',
'/metadataURL'
]);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Wizard } from '../../../wizard/model';
import { FileBackedHttpMetadataProvider } from '../../domain/model/providers/file-backed-http-metadata-provider';
import { BaseMetadataProviderEditor } from './base.provider.form';
import UriValidator from '../../../shared/validation/uri.validator';

export const FileBackedHttpMetadataProviderWizard: Wizard<FileBackedHttpMetadataProvider> = {
...BaseMetadataProviderEditor,
Expand All @@ -17,6 +18,15 @@ export const FileBackedHttpMetadataProviderWizard: Wizard<FileBackedHttpMetadata
} : null;
return err;
};
validators['/metadataURL'] = (value, property, form) => {
return !UriValidator.isUri(value) ? {
code : 'INVALID_URI',
path: `#${property.path}`,
message: 'message.uri-valid-format',
params: [value]
} : null;
};

return validators;
},
steps: [
Expand Down
10 changes: 10 additions & 0 deletions ui/src/app/metadata/provider/model/provider.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ export const MetadataProviderWizard: Wizard<MetadataProvider> = {
fields: [
'name',
'@type'
],
fieldsets: [
{
type: 'section',
class: ['col-12'],
fields: [
'name',
'@type'
]
}
]
}
] as WizardStep[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { LoadSchemaRequest } from '../../../wizard/action/wizard.action';
import { UnsavedEntityComponent } from '../../domain/component/unsaved-entity.dialog';
import { ModalService } from '../../../core/service/modal.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { UpdateChanges } from '../action/entity.action';
import { UpdateChanges, Clear } from '../action/entity.action';

@Component({
selector: 'resolver-wizard-page',
Expand Down Expand Up @@ -127,6 +127,8 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat
}
))
);

this.changes$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(c => this.changes = c);
}

next(): void {
Expand Down Expand Up @@ -170,12 +172,15 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat
currentState: RouterStateSnapshot,
nextState: RouterStateSnapshot
): Observable<boolean> {
if (nextState.url.match('wizard')) { return of(true); }
if (nextState.url.match('blank')) { return of(true); }
if (Object.keys(this.changes).length > 0) {
let modal = this.modalService.open(UnsavedEntityComponent);
modal.componentInstance.action = new UpdateChanges(this.latest);
modal.componentInstance.message = 'resolver';
modal.result.then(
() => this.router.navigate([nextState.url]),
() => {
this.store.dispatch(new Clear());
this.router.navigate([nextState.url]);
},
() => console.warn('denied')
);
}
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/resolver/resolver.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const ResolverRoutes: Routes = [
{
path: 'blank/:index',
component: ResolverWizardComponent,
canDeactivate: [],
canDeactivate: [
CanDeactivateGuard
],
children: [
{
path: '',
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/wizard/reducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ export const getSplitSchema = (schema: any, step: WizardStep) => {
const required = (schema.required || []).filter(val => keys.indexOf(val) > -1);
let s: any = {
type: schema.type,
definitions: schema.definitions,
properties: {
...keys.reduce( (properties, key) => ({ ...properties, [key]: schema.properties[key] }) , {})
}
};

if (schema.definitions) {
s.definitions = schema.definitions;
}

if (required && required.length) {
s.required = required;
}
Expand Down

0 comments on commit c391456

Please sign in to comment.