Repository navigation
feat(ui): the kit holds everything the custom tabs repeat: the house look, banners, tabs, the variable browser and the expression editor - #197
Conversation
…look, banners, tabs, the variable browser and the expression editor
…er the connect asks for its list
There was a problem hiding this comment.
Requesting changes for three findings inline: the poll interval leaks on each failed socket load, the expression preview's UTF-8 cutter drops a character that fits (and duplicates devices.lua's correct one), and a comment in expressions-demo.js repeats its header.
Beyond CI I ran the render leg for ui-expressions locally, reproduced the poll leak against the page test's harness and the cutter under Lua 5.1, and checked d17d1da's tab and properties-card changes: a switch is shown once (the hashchange guard compares like with like, "" for no detail, including when onSwitch calls setDetail), and back, forward and edited addresses still switch.
…ut, compact fields, the select arrow as a token, a refused call answering at once, and a card that leaves out what a page shows elsewhere
There was a problem hiding this comment.
Requesting changes. The three must-fixes from my review at d17d1da are still open, with no change or reply: the poll interval leaking one setInterval per failed socket load (page.js, now :329), cut in expression-tab.lua:28 dropping a character whose bytes all fit, and expressions-demo.js:16-17 repeating its file header. This head adds two more, inline.
Beyond CI, I ran a node test against this head that hands Kit.expressionEditor a selector for its textarea (it throws at insertBefore, while the same call with the element passes), and checked the exclude, chevron and not-taken paths against the existing page.js tests.
…le last character, the editor's textarea by selector, compileError reading tokens as evaluate does, and a browser a redraw replaced stops following
There was a problem hiding this comment.
All five must-fixes from my last two reviews are fixed. A socket that fails to load now starts no second poll: the new test fails against 9ab73a8's page.js and passes here. One page.cut keeps a whole last character for both callers. The editor resolves a selector before it moves the textarea. The repeated headers are gone. The nits are handled too: compileError's __p[1] turns two tokens in a row into an error, and a browser that onChange unsubscribes from inside the callback is safe because the watcher loop iterates a slice() copy. In demo mode the properties card now waits for the connect, and the connect sends _GET_PROPERTIES once.
There was a problem hiding this comment.
Approving. The trim holds: each guard it drops covers a state its callers cannot reach. api() is called only by sendTo past its !apiHost branch and by subscribe, which needs a live socket. A pick builds the same PARAM{owner,var} as before, from attributes render already reduced to digits. Without expressions-demo.js, a demo preview takes the same path it took at ab95a1d when the file was left out. The merge of main brings in #198 unchanged.
Beyond CI I ran the ui-expressions build leg through packaging, and swapped owner and variable in pick's token: the browser's tests fail 2 of 11.
This is UI kit v2: everything the custom Composer tabs and their drivers repeat moves into
src/lib/ui/, so a driver keeps only its own views and commands. Derek, on the first round's merge ask: "the original UI extraction should have pulled all of this out. The goal is simpler business and shared templates is where the mundane complexity lives. Do it now and re-roll all the PRs."Across the five pages adopted onto v0.9.83 to v0.9.86 (Network Requests, Variable Expressions, InfluxDB, Dynamic Buttons, zigbee3), I measured 93 CSS rules byte-identical in two or more pages, 105 selectors styled in two or more, and 26 functions of one name in two or more. The four drivers also each wrote their own answer helper,
_SET_PROPERTYand device listing. The open adoption PRs (finitelabs/control4-finite-labs-essentials#89, finitelabs/control4-influxdb#97, finitelabs/control4-dynamic-buttons#48, finitelabs/control4-zigbee3#433) are held and get re-rolled onto this.Trimmed on review. Derek asked whether the PR carried slop. I checked every export and option against the four drivers and cut about 1,100 lines:
Kit.api,encodeParams,markPropertyErrorandapiTokenas exports; the test-only exports; the browser'sonPickandtoken; the editor'sformatError,minHeightand selector forms; and guards for states that cannot happen.tests/ui_dom.mjs) instead of three copies, and CONTRIBUTING drops a paragraph the files' headers already say.House look (
style.css). The pages' copies are reconciled to one version each, by plain selector, since Composer's engine may be old:kit-pill.infoThe properties card's field rules now come from the base.
test_ui_pages.luanow fails a page that restyles any selector the kit styles (a page may still add its own tokens in:root), and checks each component's files come as a pair.Page core (
page.js).lib.ui.page'ssend, onejsonparameter, so numbers and booleans survive the socket.Kit.call(a command and its answer push, with anERRORpush as a refusal);Kit.follow(itemId)for another item on the same link; tabs kept in the address (#tab/detail), withKit.setTabsfor a set built per state;Kit.ago; andKit.listen/Kit.demoAnswerfor components._GET_PROPERTIESon each connect and after each property change, since a Support Code changes Log Level's list.connectDriverasks what a connect asks, so the page's demo answer reaches its handlers.build_checks.pychecks the DriverCentral page has no dev login.Variable browser (
variables.jsand.css,lib.ui.devices).lib.ui.devicesreplaceslib.expressions' Device Browser (removed, with its tests) and the inline copies in Network Requests and InfluxDB.exclude,withoutVariables,valueBytesandwrap(a license gate).Kit.devicesis the store, which InfluxDB's own picker can share.Kit.variableBrowseris the tree, with Essentials' search and Dynamic Buttons' buttons and delegated clicks, and it inserts into any field a page names.Expression editor (
expressions.jsand.css,lib.ui.expression-tab), withexpressions.Kit.expressionEditorprovides the overlay highlighting from one names list, help sections, a live preview routed per editor, plain-language errors, a watch count and a hold that Save waits on.Kit.expressionHelpmakes a shared help panel, as Network Requests needs.ExpressionTab.serveanswers the preview, withmodes,maxLength,hold,extraandwrap.Expressions.compileErrorcomes from Dynamic Buttons'Looks.compileError.Driver side.
page-paramsnever raises: a body that does not decode is{}with a warning.TabProperties:serve()answers the card's two commands.Template.
uiandexpressionstogether, and adds the browser's test toui.ui-expressionsrender covers that pair; it joins the CI matrix by itself. Itsrender (ui-expressions)andbuild (ui-expressions)checks need adding to the ruleset.make render-ui-jsruns each kit script's Node tests that the render ships.Tests.
make render-checkspasses forui,ui-expressionsanddefault,make build-checksforuiandui-expressions, andmake invalid-combinations.Behavior changes the re-roll carries to the four drivers.
and/or/notanddevice_name/room_name, and no longermaporvalue.