Add Color property type frontend in RedHerb#780
Open
malberts wants to merge 1 commit intofrontend-extensibilityfrom
Open
Add Color property type frontend in RedHerb#780malberts wants to merge 1 commit intofrontend-extensibilityfrom
malberts wants to merge 1 commit intofrontend-extensibilityfrom
Conversation
Collaborator
Author
Collaborator
Author
|
I did not manually review the code here. This PR is meant for proving that we can reuse some core NeoWiki code in an extension. This might not necessarily be the best way of writing the extension logic, though. |
fc06396 to
7fe6300
Compare
First extension-provided property-type frontend built on the neowiki.registration hook surface. For #686. Stacks on #754. This is an alternative path to PR #777, not a stack on it. PR #777 is a reference-only example that moves the existing core DateTime frontend into RedHerb to demonstrate the migration path; the intent for DateTime itself is to remain in NeoWiki core as a built-in. This PR introduces Color as a permanent example of an extension-defined property type, i.e. the shape any third-party extension would take, without disturbing core's built-in types. What it adds: * ColorDisplay.vue renders a swatch + hex via a format-only check (intentionally tolerant of input-time constraints like allowedColors so previously-valid values keep rendering); falls back through I18nSlot for unparseable values. * ColorInput.vue is a cdx-text-input plus a live preview swatch and the type's start icon. Mirrors the useStringValueInput convention: invalid mid-typing stays visible to the user but does not propagate through update:modelValue or getCurrentValue(). * ColorAttributesEditor.vue wraps an optional allowedColors palette in NeoNestedField, with a drag-reorderable list via useSortable and a dirty marker driven by useChangeDetection. * RedHerbFrontendHook.php implements NeoWikiGetFrontendModules so the new ext.redherb ResourceLoader module loads alongside ext.neowiki. * ColorProperty gains an optional allowedColors attribute (validated as 6-digit hex strings), with round-trip coverage in tests/phpunit/RedHerb/ColorPropertyTest.php. Integration points exercised: * mw.hook('neowiki.registration') as a second consumer alongside core property types. * NeoWikiGetFrontendModules PHP hook. * NeoWikiServices.getPropertyTypeRegistry and NeoWikiServices.getComponentRegistry. * Composables: useValueValidation, useChangeDetection, useSortable. * Vue components from the public-API barrel: NeoNestedField, I18nSlot. NeoWikiHooksTest::testAddsCoreModuleWhenNoExtensionsHandleHook now clearHook()'s NeoWikiGetFrontendModules so it tests what its name claims regardless of which extensions the test environment loads. Known gaps: * Persistence-side schema validation rejects extension-defined type names; saves through the schema editor return hookaborted until the JSON Schema in src/Persistence/MediaWiki/schemaContentSchema.json is loosened or built from the registry. See #779. * Pinia store sharing not directly probed in this PR; deferred to a Vitest integration test in NeoWiki core. * SchemaDeserializer / RestSchemaRepository / RestLayoutRepository do not have a natural fit in the Color flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7fe6300 to
baf0332
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

First extension-provided property-type frontend built on the
neowiki.registrationhook surface. For #686. Stacks on #754.This is an alternative path to PR #777, not a stack on it. PR #777 is a reference-only example that moves the existing core DateTime frontend into RedHerb to demonstrate the migration path; the intent for DateTime itself is to remain in NeoWiki core as a built-in. This PR introduces Color as a permanent example of an extension-defined property type — i.e. the shape any third-party extension would take — without disturbing core's built-in types.
What it adds
ColorDisplay.vue— renders a swatch + hex via a format-only check (intentionally tolerant of input-time constraints likeallowedColorsso previously-valid values keep rendering); falls back throughI18nSlotfor unparseable values.ColorInput.vue—cdx-text-inputplus a live preview swatch and the type's start icon. MirrorsuseStringValueInput's convention: invalid mid-typing stays visible to the user but does not propagate throughupdate:modelValueorgetCurrentValue().ColorAttributesEditor.vue— wraps an optionalallowedColorspalette inNeoNestedField, with a drag-reorderable list usinguseSortableand a dirty marker driven byuseChangeDetection.RedHerbFrontendHook.php— implementsNeoWikiGetFrontendModulesso the newext.redherbResourceLoader module loads alongsideext.neowiki.ColorPropertygains an optionalallowedColorsattribute (validated as 6-digit hex strings), with round-trip coverage intests/phpunit/RedHerb/ColorPropertyTest.php.Integration points exercised
mw.hook('neowiki.registration')— registration viaPropertyTypeRegistrationas a second consumer alongside core property types.NeoWikiGetFrontendModulesPHP hook.NeoWikiServices.getPropertyTypeRegistry()andNeoWikiServices.getComponentRegistry()(the latter forgetIcon('color')).useValueValidation,useChangeDetection,useSortable.NeoNestedField,I18nSlot.Known gaps
"type": "color"round-trips through?action=rawonly after the JSON Schema insrc/Persistence/MediaWiki/schemaContentSchema.jsonis loosened or built from the registry — see Schema content validator's type enum blocks extension-defined property types #779. This is the only thing blocking an end-to-end UI round-trip; everything else works.useSubjectStoresymbol NeoWiki uses internally. A Vitest integration test that asserts cross-mount state visibility belongs in NeoWiki core's own test suite, not in RedHerb. Filed as a follow-up.Verification
make tsci— 771 Vitest tests pass; lint clean.make phpunit filter=ColorProperty— 14 tests, 21 assertions, green.make cs— phpcs and phpstan clean.curl 'http://localhost:8484/load.php?modules=ext.redherb&only=scripts&lang=en&debug=true'— 200, ext.redherb statusready, all three Color SFCs in payload.Special:Schemas→ Create, the Color type appears in the property-type picker with a highlighter icon. Selecting it renders ColorAttributesEditor with a sortable palette (rows have drag handle with "Drag to reorder" tooltip, swatch, hex input, "Remove color" delete button; "+" adds entries; dirty marker*on the label). The Initial valueColorInputshows the type's highlighter start-icon. Save round-trip blocked at the persistence layer per Schema content validator's type enum blocks extension-defined property types #779.🤖 Generated with Claude Code