feat(ui-cli-account): label the section's phase from the shared dictionary

The section labels its status from the plugin's `status.*` keys unless the
plugin passes a step label for an operation in progress. The notice
translator no longer narrows the toast's notice type.
This commit is contained in:
gengruilin committed 2026-10-14 17:03:32 +08:00
1 parent 7a2156aacb
commit 363ca76ac1
1 file changed
+4 -3
@@ -13,6 +13,7 @@ export type CliAccountKey =
| 'activation.title' | 'activation.body' | 'activation.later'
| 'failure.details' | 'failure.exitCode'
| `badge.${Exclude<CliAccountPhase, 'checking'>}`
| `status.${Exclude<CliAccountPhase, 'connecting'>}`
const TONE: Record<CliAccountPhase, StateDotState> = {
checking: 'ongoing', connecting: 'ongoing', connected: 'done', disconnected: 'idle', unavailable: 'warning', stopped: 'warning',
@@ -43,7 +44,7 @@ export interface CliAccountSectionProps {
readonly t: Translate<CliAccountKey>
readonly packageName: string
readonly phase: CliAccountPhase
readonly status: string
readonly status?: string | undefined
readonly busy: boolean
readonly linked: boolean
readonly actions: readonly CliAccountAction[]
@@ -76,7 +77,7 @@ export function CliAccountSection(props: CliAccountSectionProps): ReactNode {
<h4 className={css.title}>{t('section.title')}</h4>
<div className={css.status}>
<StateDot state={TONE[phase]} />
<span className={css.label}>{status}</span>
<span className={css.label}>{status ?? t(`status.${phase === 'connecting' ? 'checking' : phase}`)}</span>
<div className={css.actions}>{actions.map(button)}</div>
</div>
{detail === undefined ? null : <p className={css.detail}>{detail}</p>}
@@ -151,7 +152,7 @@ export function CliAccountConfirm({ t, open, title, body, confirm, onClose, onCo
}
export interface CliAccountToastProps<Notice extends string> {
readonly t: Translate<`notice.${CliAccountNotice<Notice>['kind']}`>
readonly t: Translate<`notice.${NoInfer<CliAccountNotice<Notice>['kind']>}`>
readonly notice: CliAccountNotice<Notice> | undefined
readonly onDone: () => void
}