Skip to content

Commit

Permalink
SHIBUI-914 Updating sources to use json-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 4, 2018
1 parent 6ca0465 commit 3e1a499
Show file tree
Hide file tree
Showing 44 changed files with 1,054 additions and 565 deletions.
3 changes: 3 additions & 0 deletions ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { FormModule } from './schema-form/schema-form.module';
import { environment } from '../environments/environment.prod';
import { getCurrentLocale } from './shared/util';
import { I18nModule } from './i18n/i18n.module';
import { WidgetRegistry } from 'ngx-schema-form';
import { CustomWidgetRegistry } from './schema-form/registry';

@NgModule({
declarations: [
Expand Down Expand Up @@ -59,6 +61,7 @@ import { I18nModule } from './i18n/i18n.module';
],
providers: [
NavigatorService,
{ provide: WidgetRegistry, useClass: CustomWidgetRegistry },
{ provide: RouterStateSerializer, useClass: CustomRouterStateSerializer },
{
provide: HTTP_INTERCEPTORS,
Expand Down
104 changes: 104 additions & 0 deletions ui/src/app/metadata/domain/model/wizards/metadata-source-wizard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { Wizard, WizardStep } from '../../../../wizard/model';
import { MetadataResolver } from '../metadata-resolver';

export class MetadataSourceWizard implements Wizard<MetadataResolver> {
label = 'Metadata Source';
type = '@MetadataProvider';
steps: WizardStep[] = [
{
index: 2,
id: 'org-info',
label: 'label.org-info',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'organization',
'contacts'
]
},
{
index: 3,
id: 'metadata-ui',
label: 'label.metadata-ui',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'mdui'
]
},
{
index: 4,
id: 'descriptor-info',
label: 'label.descriptor-info',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'serviceProviderSsoDescriptor'
]
},
{
index: 5,
id: 'logout-endpoints',
label: 'label.logout-endpoints',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'logoutEndpoints'
]
},
{
index: 6,
id: 'key-info',
label: 'label.key-info',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'securityInfo'
]
},
{
index: 7,
id: 'assertion',
label: 'label.assertion',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'assertionConsumerServices'
]
},
{
index: 8,
id: 'relying-party',
label: 'label.relying-party',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'relyingPartyOverrides'
]
},
{
index: 9,
id: 'attribute',
label: 'label.attribute-release',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'attributeRelease'
]
},
{
index: 10,
id: 'finish',
label: 'label.finished',
schema: 'assets/schema/source/metadata-source.json',
fields: [
'serviceEnabled'
],
summary: true
}
];

parser (changes: Partial<MetadataResolver>, schema?: any): any {
return changes;
}

formatter (changes: Partial < MetadataResolver >, schema ?: any): any {
return changes;
}

getValidators(...args: any[]): { [key: string]: any } {
return {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('Entity Attributes filter form', () => {

describe('transformer', () => {
it('should not modify the object', () => {
expect(EntityAttributesFilter.translate.formatter({})).toEqual({});
expect(EntityAttributesFilter.translate.parser({})).toEqual({});
expect(EntityAttributesFilter.formatter({})).toEqual({});
expect(EntityAttributesFilter.parser({})).toEqual({});
});
});
});
6 changes: 2 additions & 4 deletions ui/src/app/metadata/filter/model/entity-attributes.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export const EntityAttributesFilter: FormDefinition<MetadataFilter> = {
const validators = {};
return validators;
},
translate: {
parser: (changes: any): MetadataFilter => changes,
formatter: (changes: MetadataFilter): any => changes
}
parser: (changes: any): MetadataFilter => changes,
formatter: (changes: MetadataFilter): any => changes
};
7 changes: 5 additions & 2 deletions ui/src/app/metadata/metadata.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NgModule } from '@angular/core';


import { ResolverModule } from './resolver/resolver.module';
import { FilterModule } from './filter/filter.module';
import { DomainModule } from './domain/domain.module';
Expand All @@ -9,6 +8,8 @@ import { ManagerModule } from './manager/manager.module';
import { MetadataRoutingModule } from './metadata.routing';
import { ProviderModule } from './provider/provider.module';
import { I18nModule } from '../i18n/i18n.module';
import { CustomWidgetRegistry } from '../schema-form/registry';
import { WidgetRegistry } from 'ngx-schema-form';


@NgModule({
Expand All @@ -21,7 +22,9 @@ import { I18nModule } from '../i18n/i18n.module';
MetadataRoutingModule,
I18nModule
],
providers: [],
providers: [
{ provide: WidgetRegistry, useClass: CustomWidgetRegistry }
],
declarations: [
MetadataPageComponent
]
Expand Down
43 changes: 2 additions & 41 deletions ui/src/app/metadata/provider/action/editor.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@ import { Action } from '@ngrx/store';

export enum EditorActionTypes {
UPDATE_STATUS = '[Provider Editor] Update Status',
LOAD_SCHEMA_REQUEST = '[Provider Editor] Load Schema Request',
LOAD_SCHEMA_SUCCESS = '[Provider Editor] Load Schema Success',
LOAD_SCHEMA_FAIL = '[Provider Editor] Load Schema Fail',

SELECT_PROVIDER_TYPE = '[Provider Editor] Select Provider Type',

CLEAR = '[Provider Editor] Clear',

LOCK = '[Provider Editor] Lock',
UNLOCK = '[Provider Editor] Unlock'
CLEAR = '[Provider Editor] Clear'
}

export class UpdateStatus implements Action {
Expand All @@ -20,24 +12,6 @@ export class UpdateStatus implements Action {
constructor(public payload: { [key: string]: string }) { }
}

export class LoadSchemaRequest implements Action {
readonly type = EditorActionTypes.LOAD_SCHEMA_REQUEST;

constructor(public payload: string) { }
}

export class LoadSchemaSuccess implements Action {
readonly type = EditorActionTypes.LOAD_SCHEMA_SUCCESS;

constructor(public payload: any) { }
}

export class LoadSchemaFail implements Action {
readonly type = EditorActionTypes.LOAD_SCHEMA_FAIL;

constructor(public payload: Error) { }
}

export class SelectProviderType implements Action {
readonly type = EditorActionTypes.SELECT_PROVIDER_TYPE;

Expand All @@ -48,20 +22,7 @@ export class ClearEditor implements Action {
readonly type = EditorActionTypes.CLEAR;
}

export class LockEditor implements Action {
readonly type = EditorActionTypes.LOCK;
}

export class UnlockEditor implements Action {
readonly type = EditorActionTypes.UNLOCK;
}

export type EditorActionUnion =
| UpdateStatus
| LoadSchemaRequest
| LoadSchemaSuccess
| LoadSchemaFail
| SelectProviderType
| ClearEditor
| LockEditor
| UnlockEditor;
| ClearEditor;
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ProviderWizardSummaryComponent implements OnChanges {
id: step.id,
index: step.index,
label: step.label,
properties: getStepProperties(schemas[step.id], def.translate.formatter(model))
properties: getStepProperties(schemas[step.id], def.formatter(model))
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Observable, Subject } from 'rxjs';
import { Store } from '@ngrx/store';

import * as fromProvider from '../reducer';
import { UpdateStatus, LockEditor, UnlockEditor } from '../action/editor.action';
import { UpdateStatus } from '../action/editor.action';
import { Wizard, WizardStep } from '../../../wizard/model';
import { MetadataProvider } from '../../domain/model';
import { LockEditor, UnlockEditor } from '../../../wizard/action/wizard.action';

import * as fromWizard from '../../../wizard/reducer';
import { withLatestFrom, map, skipWhile, distinctUntilChanged, startWith, combineLatest } from 'rxjs/operators';
Expand Down Expand Up @@ -46,7 +47,7 @@ export class ProviderEditStepComponent implements OnDestroy {
this.changes$ = this.store.select(fromProvider.getEntityChanges);
this.provider$ = this.store.select(fromProvider.getSelectedProvider);
this.step$ = this.store.select(fromWizard.getCurrent);
this.schema$ = this.store.select(fromProvider.getSchema);
this.schema$ = this.store.select(fromWizard.getParsedSchema);

this.step$.subscribe(s => {
if (s && s.locked) {
Expand Down Expand Up @@ -86,14 +87,14 @@ export class ProviderEditStepComponent implements OnDestroy {
definition
})),
skipWhile(({ model, definition }) => !definition || !model),
map(({ model, definition }) => definition.translate.formatter(model))
map(({ model, definition }) => definition.formatter(model))
);

this.valueChangeEmitted$.pipe(
map(changes => changes.value),
withLatestFrom(this.definition$),
skipWhile(([ changes, definition ]) => !definition || !changes),
map(([ changes, definition ]) => definition.translate.parser(changes))
map(([ changes, definition ]) => definition.parser(changes))
)
.subscribe(changes => this.store.dispatch(new UpdateProvider(changes)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { skipWhile, map, combineLatest } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import * as fromWizard from '../../../wizard/reducer';
import * as fromProvider from '../reducer';
import { ClearWizard, SetDefinition, SetIndex } from '../../../wizard/action/wizard.action';
import { ClearEditor, LoadSchemaRequest } from '../action/editor.action';
import { ClearWizard, SetDefinition, SetIndex, LoadSchemaRequest } from '../../../wizard/action/wizard.action';
import { ClearEditor } from '../action/editor.action';
import { MetadataProvider } from '../../domain/model';
import { ClearProvider } from '../action/entity.action';
import { Wizard } from '../../../wizard/model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export class ProviderWizardStepComponent implements OnDestroy {
constructor(
private store: Store<fromProvider.ProviderState>,
) {
this.schema$ = this.store.select(fromProvider.getSchema);
this.schema$ = this.store.select(fromWizard.getParsedSchema);
this.definition$ = this.store.select(fromWizard.getWizardDefinition);
this.changes$ = this.store.select(fromProvider.getEntityChanges);

this.schema$.subscribe(s => console.log(s));

this.validators$ = this.definition$.pipe(
withLatestFrom(
this.store.select(fromProvider.getProviderNames),
Expand All @@ -71,14 +73,14 @@ export class ProviderWizardStepComponent implements OnDestroy {
definition
})),
skipWhile(({ model, definition }) => !definition || !model),
map(({ model, definition }) => definition.translate.formatter(model))
map(({ model, definition }) => definition.formatter(model))
);

this.valueChangeEmitted$.pipe(
withLatestFrom(this.schema$, this.definition$),
map(([changes, schema, definition]) => this.resetSelectedType(changes, schema, definition)),
skipWhile(({ changes, definition }) => !definition || !changes),
map(({ changes, definition }) => definition.translate.parser(changes))
map(({ changes, definition }) => definition.parser(changes))
)
.subscribe(changes => this.store.dispatch(new UpdateProvider(changes)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Store } from '@ngrx/store';
import * as fromProvider from '../reducer';
import * as fromWizard from '../../../wizard/reducer';
import { SetIndex, SetDisabled, ClearWizard, SetDefinition } from '../../../wizard/action/wizard.action';
import { LoadSchemaRequest, ClearEditor } from '../action/editor.action';
import { ClearEditor } from '../action/editor.action';
import { LoadSchemaRequest } from '../../../wizard/action/wizard.action';
import { startWith } from 'rxjs/operators';
import { Wizard, WizardStep } from '../../../wizard/model';
import { MetadataProvider } from '../../domain/model';
Expand Down
16 changes: 10 additions & 6 deletions ui/src/app/metadata/provider/effect/editor.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import { Effect, Actions, ofType } from '@ngrx/effects';
import { SchemaService } from '../../../schema-form/service/schema.service';

import {
LoadSchemaRequest,
LoadSchemaSuccess,
LoadSchemaFail,
EditorActionTypes
} from '../action/editor.action';
import { map, switchMap, catchError, withLatestFrom, debounceTime } from 'rxjs/operators';
import { of } from 'rxjs';
import { SetDefinition, WizardActionTypes, AddSchema } from '../../../wizard/action/wizard.action';
import {
LoadSchemaRequest,
LoadSchemaSuccess,
LoadSchemaFail,
SetDefinition,
WizardActionTypes,
AddSchema
} from '../../../wizard/action/wizard.action';
import { ResetChanges } from '../action/entity.action';

import * as fromWizard from '../../../wizard/reducer';
Expand All @@ -21,7 +25,7 @@ export class EditorEffects {

@Effect()
$loadSchemaRequest = this.actions$.pipe(
ofType<LoadSchemaRequest>(EditorActionTypes.LOAD_SCHEMA_REQUEST),
ofType<LoadSchemaRequest>(WizardActionTypes.LOAD_SCHEMA_REQUEST),
map(action => action.payload),
debounceTime(100),
switchMap((schemaPath: string) =>
Expand All @@ -36,7 +40,7 @@ export class EditorEffects {

@Effect()
$loadSchemaSuccess = this.actions$.pipe(
ofType<LoadSchemaSuccess>(EditorActionTypes.LOAD_SCHEMA_SUCCESS),
ofType<LoadSchemaSuccess>(WizardActionTypes.LOAD_SCHEMA_SUCCESS),
map(action => action.payload),
withLatestFrom(this.store.select(fromWizard.getWizardIndex)),
map(([schema, id]) => new AddSchema({ id, schema }))
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/provider/model/base.provider.form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { BaseMetadataProviderEditor } from './base.provider.form';

describe('BaseMetadataProviderForm', () => {

const parser = BaseMetadataProviderEditor.translate.parser;
const formatter = BaseMetadataProviderEditor.translate.formatter;
const parser = BaseMetadataProviderEditor.parser;
const formatter = BaseMetadataProviderEditor.formatter;

const requiredValidUntilFilter = {
maxValidityInterval: 1,
Expand Down
Loading

0 comments on commit 3e1a499

Please sign in to comment.