Repository navigation
Description
Describe the bug
The Admin UI finds the relationship properties of a managed object by comparing their type with the strings "relationship" and "array". The type array of a Nullable relationship, ["relationship", "null"] (#267), and of a Nullable relationship collection, ["array", "null"] with items of type "relationship" (#269), match neither. The schema editor of the Admin UI writes these type arrays itself: SchemaUtils.setNullableProperties turns the type of a Nullable property into [type, "null"].
On master (2a03690):
GenericEditResourceView.renderbuilds the read of the edit view withResourceCollectionUtils.getFieldsToExpand(:83), which adds a singleton relationship to_fieldsonly for the type"relationship"(ResourceCollectionUtils.js:219). A relationship is not returned by default, so the value of a Nullable singleton relationship is not read, and the edit view shows it as not set.handleArrayOfTypes(:139) reduces the type arrays of the properties only after this read, before the editor is built.ResourceCollectionUtils.convertRelationshipTypes(:174-184) replaces a relationship type with"string"andtypeRelationship: truebefore the schema reaches JSONEditor, but passes a type array on unchanged.LinkedView(:108) calls it on the schema fromgetSchemawithouthandleArrayOfTypes. JSONEditor 0.7.9 gives a type array to itsmultipleeditor, which builds the editor of the first listed type right away (switchEditor(0)inbuild). There is no editor for"relationship", sogetEditorClassthrowsUnknown editor for schema, and the linked view of a managed object with a Nullable singleton relationship is not rendered.RelationshipWidgeton the dashboard selects the relationship properties of a managed object, and of the managed objects it refers to (allSchemas), by the same comparisons (:466,:491), and leaves the Nullable ones out.EditPropertyMappingDialog(:265) does not build the JSONEditor of the default value for a target property of type"relationship". For a Nullable relationship it builds one from{"type": ["relationship", "null"]}(:318), which throws as above when the dialog opens.
ResourceDelegate.getSchema gives these views the schema of a managed object, except EditPropertyMappingDialog, which gets it from AdminUtils.findPropertiesList. Both read managed.json through ConfigDelegate.readEntity, which returns a copy.
To reproduce
- In the Admin UI, open Configure > Managed Objects > User > Schema >
manager, set Nullable and save. - Open Manage > User and select a user whose
manageris set. The Manager field offers to add a manager instead of showing the current one. - In a mapping whose target is
managed/user, open the dialog of a property mapping whose target ismanager. The dialog fails, and the browser console showsUnknown editor for schema.
This was traced by reading the code on master and the source of JSONEditor 0.7.9, and has not been run in a browser.
Expected behavior
- In the managed object schemas that
ResourceDelegate.getSchema(withallSchemas) andAdminUtils.findPropertiesListreturn, a type array whose only type besides"null"is"relationship"reads"relationship", and["array", "null"]with relationshipitemsreads"array". The views and JSONEditor then handle a Nullable relationship like any other relationship. - The schema editor and
managed.jsonkeep the type arrays. The schema editor readsmanaged.jsonon its own and is not affected.
Corrected
The first version of this issue said that the edit view of a managed object with a Nullable singleton relationship is not rendered, and that a Nullable relationship collection gets no tab in it. Both are withdrawn: GenericEditResourceView.handleArrayOfTypes (:139) reduces the type arrays of the properties before the editor and the tabs are built. The Unknown editor for schema error applies to LinkedView and EditPropertyMappingDialog. In the edit view, only the read of the value is affected.
Activity
[OpenIdentityPlatform#267] [OpenIdentityPlatform#269] [OpenIdentityPl…
[OpenIdentityPlatform#267] [OpenIdentityPlatform#269] [OpenIdentityPl…
[OpenIdentityPlatform#267] [OpenIdentityPlatform#269] [OpenIdentityPl…