Repository navigation
refactor(admin): use Flarum's own controls for the admin toggles - #72
Open
karl-bullock wants to merge 4 commits into
Open
karl-bullock wants to merge 4 commits into
karl-bullock wants to merge 4 commits into
Conversation
The navigation settings and the allowed-groups list were hand-rolled `<label class="checkbox">` inputs. No core admin page renders those: a boolean setting goes through buildSettingComponent with type 'bool', which renders a Switch and ties the help text to the input with aria-describedby, and a list of named options is rendered as Switch rows (flarum/audit's limited-settings form). The three navigation settings now go through buildSettingComponent with their existing defaults, and the allowed-groups list uses Switch rows. Core's Checkbox is not used for the list: it is styled for icon-only use, and with a visible label an unchecked box shows a red cross, which reads as "forbidden" when an empty list actually means no restriction. js/dist is rebuilt in the next commit.
Includes transpiled JS/TS, and Typescript declaration files (typings).
Member
Author
|
Verification notes for this branch at 5d1c1d0:
|
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.
Summary
The admin page and the category editor drew their own checkboxes: a raw
<label class="checkbox">around a native<input type="checkbox">. Stock Flarum does not do that in admin — boolean settings go throughbuildSettingComponent({ type: 'bool' }), which renders theSwitchcomponent and ties the help text to the input, and a list of named options is rendered asSwitchrows (seeflarum/audit).This replaces both with core components, so the extension's admin screens look and behave like the rest of Flarum.
Thanks to @huoxin233: #64 first proposed using Flarum's native
Switchfor the navigation settings. This covers that and the allowed-groups list in the category editor.Changes
js/src/admin/components/SupportAdminPage.tsx: the three navigation settings are rendered withthis.buildSettingComponent({ setting, label, help, type: 'bool', default }). Defaults are unchanged (1,1,0).js/src/admin/components/CategoryEditorModal.tsx: the allowed-groups list usesSwitchrows instead of raw checkboxes. The container is namedLinkRobinsSupport-groupSwitches, and the group links to the help text about leaving all switches off.less/admin.less: the hand-written.checkboxrules are gone; the group container only sets the vertical rhythm core's switch lists use.js/distrebuilt.Why Switch and not Checkbox for the group list
Core's
Checkboxis used icon-only. With a visible label it draws a red cross when off, which reads as "not allowed" — but an unchecked box here means "no restriction", since an empty list allows every group the ticket type permits.Switchrows are what Flarum itself uses for a list of named options (flarum/audit'sLimitedSettingsModal).Before / after
Both navigation captures show all three controls on Flarum Test #2. Before, the section uses raw checkboxes. After, it uses Flarum switches with their help text attached.
Allowed user groups — before: raw checkboxes. After:
Switchrows.The same list at phone width with six groups (three of them created on the bench for the check):
Checks
Run on the linkrobins bench (Flarum 2.0.2, stock image + this checkout):
Switches;label.checkboxnodes on the page: 0.<input>carriesaria-describedbypointing at its help text.aria-describedbyresolves to the help text on desktop and at 390 px.npm run check-typings,npm run format-check,npm run build: clean.Review screenshots are stored on the
pr-assets-72branch.