Repository navigation
feat(console): a settings toggle that declares confirmOffText asks before it is turned off - #30575
Merged
Merged
Conversation
…fore it is turned off The settings page's toggle row reads SpecifierSchema.confirmOffText: turning the switch from on to off opens a confirmation carrying the text (resolved through settings.NAMESPACE.keys.KEY.confirmOffText, else the manifest literal); Cancel leaves the switch on with nothing drafted, Continue drafts false for the page's Save. Turning on asks nothing; a toggle without the key is unchanged. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgX6EQZ4fi7BLKzhfLT
…the next commit Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgX6EQZ4fi7BLKzhfLT
…mit for the PR body) Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgX6EQZ4fi7BLKzhfLT
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgX6EQZ4fi7BLKzhfLT
4 tasks
…tocol none, a patch Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgX6EQZ4fi7BLKzhfLT
Contributor
Author
|
domain:ui#4 · os-sales · session_01L6bhgVfPeFZkN1FP93imKU 维护者速读
席位核对 — ACCEPT · head e88fef3
Generated by Claude Code |
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.
Requested by Sales · project thread
domain:ui#4 · os-sales · session_01L6bhgX6EQZ4fi7BLKzhfLT
Fixes #30500
Refs #30299
Clause-②: no
Metadata-protocol: none
维护者速读
confirmOffText的开关(目前是「认证」页的「启用邮箱/密码登录」),从开拨到关时先弹确认框,显示这段话;点「取消」开关保持开、不进未保存更改、什么都不存;点「继续」开关才变关,再按页面的「保存更改」照常保存。打开开关不问,没声明的开关行为不变。confirmOffText,认证 manifest 也声明了,但控制台不读,Setup 关掉密码登录时一句都不问(声明 ≠ 兑现)。action_button确认框已用的AlertDialog与actionConfirm.*文案键,不加 locale 键、不加导出;服务器「最后一种登录方式」的拒绝仍在,确认框不替代它。回滚即撤本 PR。ui/apps/console/src/pages/settings/SettingsField.tsx的ToggleSwitch与case 'toggle';useSettingsLabel.ts新的fieldConfirmOff;新测试SettingsView.confirmOff-30500.test.tsx。pnpm --dir ui exec vitest run apps/console/src/pages/settings/__tests__/SettingsView.confirmOff-30500.test.tsx,预期 1 个文件、8 条全绿。What changes
The settings page's
togglerow readsSpecifierSchema.confirmOffText("Confirm dialog text shown before a toggle's value changes to off (omit = no confirm)"), whichauth.manifest.tsdeclares onemail_password_enabled.SettingsField.tsx: the toggle's switch is a newToggleSwitch. When the specifier declares the key and the switch goes from on to off, it opens anAlertDialogcarrying the text and hands nothing toonChange. Cancel leaves the switch on and the page's draft untouched, so there is no unsaved change and nothing any Save could send. Continue handsfalsetoonChange; the page's Save button sends it like any other edit. Turning the switch on asks nothing. A toggle without the key changes at once, exactly as before. Judged on the declaration (!= null), as theaction_buttonarm judges a handler'sconfirmText. The dialog is opened by state rather than anAlertDialogTrigger(only one of the switch's two directions asks), so focus is handed back to the switch when it closes.settings.NAMESPACE.keys.KEY.confirmOffTextthrough the page's label helpers, the slottranslation.zod.tsdeclares beside the key'slabel; a miss is the manifest literal. The spec types the key asI18nLabel, so an inline locale map literal is picked for the page's language withpickLocalized.useSettingsLabel.ts:fieldConfirmOff(key, fallback), through the hook's oneresolve().types.ts: the mirror gains an optionalconfirmOffText, typed as a string or an inline locale map (a record of language tag to string).actionConfirm.title/cancel/confirmkeys theaction_buttonconfirmation uses; no locale key is added.Live, Setup > Authentication (showcase
objectstack dev --seed-admin, this branch's console under vite, Playwright 1440 px; "before" is the same page with the confirm's guard ablated live withablation-replace.mjs --hold, then restored):zh-CN after Cancel (switch on, no unsaved bar):
zh-CN after Continue (switch off, one unsaved change):
zh-CN after Save (saved, row reads Modified):
Why
Ruling A on #30418 (6657805240), bind (4): the console's settings page honours
confirmOffTextbefore save. Until now the key was declared with no reader, so Setup turned email and password sign-in off on one click (#30299's last remainder).Tests
ui/apps/console/src/pages/settings/__tests__/SettingsView.confirmOff-30500.test.tsx: the whole page over a stubbedfetchand the realapi.ts, so the save cases read the PUT body as it leaves the client.{"email_password_enabled":false};true;false;settings.auth.keys.email_password_enabled.confirmOffText, and an inline locale map literal picked fordewhen nothing is served.Acceptance notes
Modified/Overridesbadge) clears the layer's value without asking. It could land on off only for a toggle whose fallback is off;email_password_enableddefaults totrue, and no other shipped specifier declaresconfirmOffText. Discard returns to the stored value and asks nothing either.400 SETTINGS_VALIDATIONwith the server's sentence under the row; with Google sign-in set in the same save it went through200.action_buttonarm resolves a handler'sconfirmTextwithresolveLabel, which reads a string or the retired{ defaultValue, key }shape, so an inline locale map there would render an empty question. No shipped manifest declares one. Carrier: none.Clause-②: nostands.Metadata-protocol: none: the spec is untouched andconfirmOffTextalready meant this (PR feat(spec): a settings toggle can declare the question asked before it is turned off (confirmOffText) #30489); the console only honours it, and AGENTS.md §3 names the console asnone, so the changeset ispatchon@object-ui/console(corrected by the seat from the first head'ssemantic/minor).claude/project-thread-ngbinh, notclaude/issue-30500-*(named in the claim amendment).Verification
Unit tests
f6ce715a:pnpm exec vitest run --maxWorkers=2 apps/console/src/pages/settings/__tests__/SettingsView.confirmOff-30500.test.tsx(inui/, underos-verify-lock):Test Files 1 passed (1),Tests 8 passed (8),VERDICT command-exit 0.4a1e9138(main with PR feat(console): Allowed IP ranges shows the address the server judges before a save #30540 merged in):pnpm exec vitest run --maxWorkers=2 apps/console/src/pages/settings:Test Files 36 passed (36),Tests 305 passed (305),VERDICT command-exit 0.Ablation
ablation-replace.mjsonSettingsField.tsx, anchorif (checked && !next && confirmOffText !== undefined) {toif (false) {(anchor 1 to 0, blob 861c4c87 to fd282923): the new file goes6 failed | 2 passed (8). The six declared-path cases are red; the two that must not ask (off to on, a toggle without the key) stay green, as expected. Restored: blob equals HEAD,git diff HEADempty.Live readings (real stack)
Showcase
objectstack dev --seed-adminon its own port, the branch's console under vite withDEV_PROXY_TARGET, Playwright 1440 px, page/system/settings/auth, rowemail_password_enabled.aria-checked=true, no unsaved bar. Cancel: switch still on, no unsaved bar, focus on the switch. Continue: switch off, "1 unsaved change". Save with no other sign-in method:PUT /api/settings/authbody{"email_password_enabled":false}, answered400 SETTINGS_VALIDATION, the server's sentence under the row. Save with Google sign-in set in the same save:200,email_password_enabledstoredfalse.settings.auth.keys.email_password_enabled.confirmOffText); Cancel and Continue as above; Save200, "设置已保存", the row reads 已修改.false.Derived gates (dispatch-gates --commands at f6ce715; the list re-derived identical at 4a1e913)
34 derived, 34 run, all exit 0;
--ranreconciliation: 34 run, 0 NOT-MEASURED, 0 UNRUN. The ratchet families re-run on the merge head4a1e9138:pnpm check:type-check-coverage :: exit 0,pnpm check:type-check-debt :: exit 0.Also:
turbo run build --filter='@object-ui/console^...'then@object-ui/consoletype-checkat4a1e9138:VERDICT command-exit 0.eslinton the four changed console files: 0 errors (1 warning, on a line this PR does not touch).pnpm --dir ui run check:new-line-citations: 0 new citations. Repo-wide lint and the full UI suites are CI's.Human Minimum
packages/specholds no runtime logic. (no spec change)pnpm lintpasses. (eslint on the changed files locally; repo-wide lint is CI's)main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code