refactor(dashboard): one confirm bar instead of five copies - #131
Open
glennmichael123 wants to merge 1 commit into
Open
refactor(dashboard): one confirm bar instead of five copies#131glennmichael123 wants to merge 1 commit into
glennmichael123 wants to merge 1 commit into
Conversation
Part of #125. partials/op-confirm.stx takes three optional params — label (default 'Run'), danger (default false) and output (default true) — so the five pages that hand-rolled their own bar can use it. Defaults keep the 13 existing callers byte-identical. Migrated: firewall, team, ssh-keys, secrets, alarms. Each renames its confirm signals to the contract the partial binds to (pending/typed/confirmTok/ confirmVerb/canRun/runOp/cancelOp) and drops ~6 lines of duplicated markup. Fixes divergences the copies had drifted into: - firewall's confirm button said "Run" under a "Remove" trigger - the shared bar rendered a non-danger button even for backup:restore - neither the partial nor any copy set type="button" (they defaulted to submit) - the confirm input had only a placeholder, no accessible name The two free-form command runners keep their own bars: those pages already bind the partial to their operations, so a second include would collide on names. The JS block stays per-page. Extracting it needs shared client scope, which stx cannot currently give us — see the follow-up issue. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Part of #125.
partials/op-confirm.stxnow takes three optional params —label(default'Run'),danger(defaultfalse),output(defaulttrue) — so the five pages that hand-rolled their own bar can use the shared one. The defaults keep the 13 existing callers byte-identical.Migrated:
firewall,team,ssh-keys,secrets,alarms— each renames its confirm signals to the contract the partial binds to (pending/typed/confirmTok/confirmVerb/canRun/runOp/cancelOp) and drops ~6 lines of duplicated markup.Divergences this fixes
The copies had quietly drifted apart:
firewall's confirm button said "Run" under a "Remove" triggerbackup:restoretype="button"— they defaulted tosubmitplaceholder="confirm", no accessible nameWhat this does not do
The ~15-line JS block stays duplicated per page. That was the other half of #125 and it isn't currently possible — I tried three ways and verified each against a working control:
import { useOpConfirm } from '../../src/use-op-confirm.ts'<script client>import … from '@composables'window.__composables, but stx has no auto-registrationstx bundles an importing client script into module scope, so directives (
@click="askOp(…)",@show="pending()…") can no longer resolve those names. It fails closed — the click is a silent no-op, no console error — which is exactly why this would have been nasty to ship blind. Follow-up filed upstream.The two free-form command runners keep their own bars: those pages already bind the partial to their operations, so a second include would collide on names.
Verification
Ran every confirm bar in a headless browser against the live dev server — clicking the trigger, checking the token/label/gating, typing the token, and confirming the request only fires afterwards:
The two untouched pages confirm the defaults cause no regression. Lint clean.
Unrelated but worth knowing:
packages/ui'sdev/buildscripts pass--pages, which stx removed (it now auto-detectspages/).bun run devfails outright until that's updated — likely why this UI hasn't been exercised locally.