diff --git a/packages/client/ui-wecom/src/client/WecomConnection.tsx b/packages/client/ui-wecom/src/client/WecomConnection.tsx
index 8ec82941c1..f3bd28dd55 100644
--- a/packages/client/ui-wecom/src/client/WecomConnection.tsx
+++ b/packages/client/ui-wecom/src/client/WecomConnection.tsx
@@ -13,9 +13,8 @@ export function WecomConnectionSection(props: FaceProps): ReactNode {
const { useWecomConnection, check, connect, cancel, openAuthorization, retry, t } = props
const snapshot = useWecomConnection(value => value)
const shown = presentConnection(snapshot)
- const failed = 'failed' in shown && shown.failed ? snapshot.view?.result : undefined
const actions: CliAccountAction[] = []
- let status = t(`status.${shown.phase === 'connecting' ? 'checking' : shown.phase}`)
+ let status: string | undefined
let detail: string | undefined
switch (shown.phase) {
case 'disconnected': actions.push({ label: t('action.connect'), onClick: connect, variant: 'primary' }); detail = t('detail.disconnected'); break
@@ -34,7 +33,7 @@ export function WecomConnectionSection(props: FaceProps): ReactNode {
}
return (
+ actions={actions} detail={detail} failure={'failed' in shown && shown.failed !== undefined ? { text: t('failed'), command: shown.failed.failure } : undefined} />
)
}
diff --git a/packages/client/ui-wecom/src/client/connection.ts b/packages/client/ui-wecom/src/client/connection.ts
index 0a49c7efd1..8dc225dc23 100644
--- a/packages/client/ui-wecom/src/client/connection.ts
+++ b/packages/client/ui-wecom/src/client/connection.ts
@@ -12,7 +12,7 @@ export type WecomNotice = 'connected'
export type ConnectionSnapshot = CliAccountSnapshot
export type ConnectionPresentation =
- | { readonly phase: Exclude; readonly failed: boolean }
+ | { readonly phase: Exclude; readonly failed: WecomState['result'] }
| { readonly phase: 'connecting'; readonly step: 'authorizing' | 'connecting'; readonly url: string | undefined; readonly cancellable: boolean }
export interface ConnectionFace {
@@ -26,9 +26,9 @@ export interface ConnectionFace {
}
export function presentConnection({ view, stopped }: Pick): ConnectionPresentation {
- if (stopped) return { phase: 'stopped', failed: false }
+ if (stopped) return { phase: 'stopped', failed: undefined }
const operation = view?.operation
- if (view === undefined || operation?.kind === 'check') return { phase: 'checking', failed: false }
+ if (view === undefined || operation?.kind === 'check') return { phase: 'checking', failed: undefined }
if (operation !== undefined) {
return {
phase: 'connecting',
@@ -37,9 +37,9 @@ export function presentConnection({ view, stopped }: Pick