Page MenuHomePhabricator

Decision on how UI schema abstraction should work
Open, Needs TriagePublic

Description

Background

CommunityConfiguration client library "json-form" generates a generic form based on json-schemadefinitions. On the high level it renders a Codex field for each property found in the given schema. In some situations there's a need to do some visual customisation of the form in a particular provider. For instance hiding a particular property, displaying a property with a non-standard control, customize the form layout or grouping properties.

In order to meet the initial release of the extension deadlines some visualization customisations have been introduce in the extension ad-hoc, mixing validation and presenation concerns. An example of this mixing of concerns is the "control" keyword used for rendering MediaWiki specific controls via references, (T357718).
The parent form specification task had a proposal to avoid this problem: using a UI Schema. However the definition was quite vague:

The concept is borrowed from jsonforms/uischema and consists of a JSON definition file which describes the controls, layout and rules of a form.

As an example:

schema.json
{
	"$schema": "https://json-schema.org/draft-04/schema#",
	"$id": "http://example.com/communityconfiguration/help-panel/1.0.0",
	"type": "object",
	"properties": {
		"GEHelpPanelAskMentor": {
			"type": "boolean",
			"description": "When using the help panel's question-asking functionality, post on the mentor's talk page instead of on the help desk page.",
			"default": true
		},
		"GEHelpPanelHelpDeskPostOnTop": {
			"type": "boolean",
			"description": "Whether to post new questions on the top of the help desk. Default is to post on the bottom (like section=new does). Only affects wikitext pages.",
			"default": true
		},
		"GEHelpPanelExcludedNamespaces": {
			"type": "array",
			"items": {
				"type": "number"
			}
		},
		"GEHelpPanelReadingModeNamespaces": {
			"type": "array",
			"items": {
				"type": "number"
			}
		},
		"GEHelpPanelSearchNamespaces": {
			"type": "array",
			"items": {
				"type": "number"
			}
		}
	},
	"required": [
		"GEHelpPanelAskMentor",
		"GEHelpPanelHelpDeskPostOnTop",
		"GEHelpPanelExcludedNamespaces",
		"GEHelpPanelReadingModeNamespaces",
		"GEHelpPanelSearchNamespaces"
	],
	"additionalProperties": false
}
uischema.json
{
    "type": "VerticalLayout",
    "elements": [
        {
            "type": "Group",
            "label": "Simple group",
            "elements": [
                {
                    "type": "Control",
                    "scope": "#/properties/GEHelpPanelAskMentor"
                },
                {
                    "type": "Control",
                    "scope": "#/properties/GEHelpPanelHelpDeskPostOnTop"
                }
            ]
        },
        {
            "type": "Group",
            "label": "Complex group",
            "elements": [
                {
                    "type": "Control",
                    "scope": "#/properties/GEHelpPanelExcludedNamespaces"
                }
            ]
        }
    ]
}

The UI schema does not need to be necessarily defined in JSON it could also be done in PHP. If no UI schema is provided CC2.0 can fallback to a "vanilla" set of controls and some default settings for form displaying.

Possible use cases of UI schema

Related Objects

Event Timeline

KStoller-WMF renamed this task from Decide if a UI schema abstraction is required to Decision on how UI schema abstraction should work.Oct 17 2024, 4:25 PM
KStoller-WMF moved this task from Needs Discussion to Triaged on the Growth-Team board.