Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-1549 (pull request #409)
Browse files Browse the repository at this point in the history
SHIBUI-1549 Fixed issue with min/max length not being applied

Approved-by: Dmitriy Kopylenko <dkopylenko@unicon.net>
Approved-by: Ryan Mathis <rmathis@unicon.net>
  • Loading branch information
rmathis committed Nov 6, 2019
2 parents 9bfc527 + f93de67 commit 535f03a
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 210 deletions.
234 changes: 129 additions & 105 deletions backend/src/main/resources/metadata-sources-ui-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,7 @@
"default": false
},
"organization": {
"type": "object",
"properties": {
"name": {
"title": "label.organization-name",
"description": "tooltip.organization-name",
"type": "string"
},
"displayName": {
"title": "label.organization-display-name",
"description": "tooltip.organization-display-name",
"type": "string"
},
"url": {
"title": "label.organization-url",
"description": "tooltip.organization-url",
"type": "string"
}
},
"dependencies": {
"name": {
"required": [
"displayName",
"url"
]
},
"displayName": {
"required": [
"name",
"url"
]
},
"url": {
"required": [
"name",
"displayName"
]
}
}
"$ref": "#/definitions/Organization"
},
"contacts": {
"title": "label.contact-information",
Expand All @@ -74,73 +37,7 @@
}
},
"mdui": {
"type": "object",
"widget": {
"id": "fieldset"
},
"fieldsets": [
{
"type": "group",
"fields": [
"displayName",
"informationUrl",
"description"
]
},
{
"type": "group",
"fields": [
"privacyStatementUrl",
"logoUrl",
"logoWidth",
"logoHeight"
]
}
],
"properties": {
"displayName": {
"title": "label.display-name",
"description": "tooltip.mdui-display-name",
"type": "string"
},
"informationUrl": {
"title": "label.information-url",
"description": "tooltip.mdui-information-url",
"type": "string"
},
"privacyStatementUrl": {
"title": "label.privacy-statement-url",
"description": "tooltip.mdui-privacy-statement-url",
"type": "string"
},
"description": {
"title": "label.description",
"description": "tooltip.mdui-description",
"type": "string",
"widget": {
"id": "textarea"
}
},
"logoUrl": {
"title": "label.logo-url",
"description": "tooltip.mdui-logo-url",
"type": "string"
},
"logoHeight": {
"title": "label.logo-height",
"description": "tooltip.mdui-logo-height",
"min": 0,
"type": "integer",
"default": 0
},
"logoWidth": {
"title": "label.logo-width",
"description": "tooltip.mdui-logo-width",
"min": 0,
"type": "integer",
"default": 0
}
}
"$ref": "#/definitions/MDUI"
},
"securityInfo": {
"type": "object",
Expand Down Expand Up @@ -439,6 +336,10 @@
"AssertionConsumerService": {
"type": "object",
"title": "label.assertion-consumer-service-endpoint",
"required": [
"locationUrl",
"binding"
],
"properties": {
"locationUrl": {
"title": "label.assertion-consumer-service-location",
Expand Down Expand Up @@ -524,6 +425,129 @@
]
}
}
},
"MDUI": {
"type": "object",
"widget": {
"id": "fieldset"
},
"fieldsets": [
{
"type": "group",
"fields": [
"displayName",
"informationUrl",
"description"
]
},
{
"type": "group",
"fields": [
"privacyStatementUrl",
"logoUrl",
"logoWidth",
"logoHeight"
]
}
],
"properties": {
"displayName": {
"title": "label.display-name",
"description": "tooltip.mdui-display-name",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"informationUrl": {
"title": "label.information-url",
"description": "tooltip.mdui-information-url",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"privacyStatementUrl": {
"title": "label.privacy-statement-url",
"description": "tooltip.mdui-privacy-statement-url",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"description": {
"title": "label.description",
"description": "tooltip.mdui-description",
"type": "string",
"widget": {
"id": "textarea"
},
"minLength": 1,
"maxLength": 255
},
"logoUrl": {
"title": "label.logo-url",
"description": "tooltip.mdui-logo-url",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"logoHeight": {
"title": "label.logo-height",
"description": "tooltip.mdui-logo-height",
"min": 0,
"type": "integer"
},
"logoWidth": {
"title": "label.logo-width",
"description": "tooltip.mdui-logo-width",
"min": 0,
"type": "integer"
}
}
},
"Organization": {
"type": "object",
"properties": {
"name": {
"title": "label.organization-name",
"description": "tooltip.organization-name",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"displayName": {
"title": "label.organization-display-name",
"description": "tooltip.organization-display-name",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"url": {
"title": "label.organization-url",
"description": "tooltip.organization-url",
"type": "string",
"minLength": 1,
"maxLength": 255
}
},
"dependencies": {
"name": {
"required": [
"displayName",
"url"
]
},
"displayName": {
"required": [
"name",
"url"
]
},
"url": {
"required": [
"name",
"displayName"
]
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export class MetadataSourceBase implements Wizard<MetadataResolver> {
};

parser(changes: Partial<MetadataResolver>, schema?: any): any {
if (!changes.organization) {
if (!schema || !schema.properties) {
return changes;
}
if (schema.properties.hasOwnProperty('organization') && !changes.organization) {
changes.organization = {};
}
return changes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { RouterStub, RouterLinkStubDirective } from '../../../../testing/router.
import { ActivatedRouteStub } from '../../../../testing/activated-route.stub';
import * as stubs from '../../../../testing/resolver.stub';
import { FileBackedHttpMetadataResolver } from '../../domain/entity';
import { InputDefaultsDirective } from '../../../shared/directive/input-defaults.directive';
import { MockI18nModule } from '../../../../testing/i18n.stub';
import { MockListValueService } from '../../../../testing/list-values.stub';
import { MockSharedModule } from '../../../../testing/shared.stub';
Expand Down Expand Up @@ -58,7 +57,6 @@ describe('Finished Form Component', () => {
declarations: [
FinishFormComponent,
RouterLinkStubDirective,
InputDefaultsDirective,
TestHostComponent
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,23 @@ export class ResolverEditStepComponent implements OnDestroy {
this.valueChangeEmitted$.pipe(
takeUntil(this.ngUnsubscribe),
map(changes => changes.value),
withLatestFrom(this.definition$, this.store.select(fromResolver.getSelectedResolver), this.changes$),
withLatestFrom(
this.definition$,
this.store.select(fromResolver.getSelectedResolver),
this.changes$,
this.schema$
),
filter(([valueChange, definition, resolver]) => definition && resolver),
map(([valueChange, definition, resolver, changes]) => definition.parser({ ...resolver, ...changes, ...valueChange }))
map(([
valueChange,
definition,
resolver,
changes,
schema
]) => {
const parsed = definition.parser({ ...valueChange }, schema);
return { ...resolver, ...changes, ...parsed };
})
)
.subscribe(changes => {
this.store.dispatch(new UpdateChangesRequest(changes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ export class ResolverWizardStepComponent implements OnDestroy {
);

this.valueChangeEmitted$.pipe(
withLatestFrom(this.definition$),
withLatestFrom(
this.definition$,
this.schema$,
this.store.select(fromResolver.getSelectedDraft)
),
filter(([ changes, definition ]) => (!!definition && !!changes)),
map(([ changes, definition ]) => definition.parser(changes.value))
map(([ changes, definition, schema, original ]) => {
const parsed = definition.parser(changes.value, schema);
return { ...original, ...parsed };
})
)
.subscribe(changes => {
this.store.dispatch(new UpdateChangesRequest(changes));
Expand Down
12 changes: 3 additions & 9 deletions ui/src/app/metadata/resolver/effect/entity.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@ export class EntityEffects {
ofType<UpdateChangesRequest>(ResolverEntityActionTypes.UPDATE_CHANGES_REQUEST),
map(action => action.payload),
withLatestFrom(
this.store.select(fromResolver.getEntityChanges),
this.store.select(fromWizard.getSchema)
this.store.select(fromResolver.getEntityChanges)
),
map(([changes, stored, schema]) => {
const props = Object.keys(schema.properties);
const diffed = props.reduce((changeObj, prop) => {
changeObj[prop] = !changes.hasOwnProperty(prop) && stored.hasOwnProperty(prop) ? null : changes[prop];
return changeObj;
}, {});
const update = { ...stored, ...diffed };
map(([changes, storedChanges]) => {
const update = { ...storedChanges, ...changes };
return new UpdateChangesSuccess(update);
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ describe('Resolver Reducer', () => {
Object.assign({}, initialState, expected)
);
});

it('should return state if the entityId is not found', () => {
let changes = { ...resolvers[1], serviceEnabled: true, id: '4' };
const action = new resolverActions.UpdateResolverSuccess({id: changes.id, changes});
const result = reducer({ ...snapshot }, action);

expect(result).toEqual(snapshot);
});
});

describe('Select Resolver', () => {
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/resolver/reducer/collection.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export function reducer(state = initialState, action: ResolverCollectionActionsU
}

case ResolverCollectionActionTypes.UPDATE_RESOLVER_SUCCESS: {
return adapter.updateOne(action.payload, state);
const removed = adapter.removeOne(action.payload.id as string, state);
const addBack = adapter.upsertOne(action.payload.changes as MetadataResolver, removed);
return addBack;
}

case ResolverCollectionActionTypes.SELECT_SUCCESS: {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/constant.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const DEFAULT_FIELD_MAX_LENGTH = 255;
export const DEFAULT_FIELD_MAX_LENGTH = 255;
Loading

0 comments on commit 535f03a

Please sign in to comment.