mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-12 05:40:45 +08:00
fix: surface actionable channel message errors
This commit is contained in:
parent
b42fc411c2
commit
7cbed3aefb
59 changed files with 2405 additions and 607 deletions
|
|
@ -1,6 +1,20 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { h } from './i18n.js';
|
||||
import { h, isEnglish } from './i18n.js';
|
||||
|
||||
function messageErrorTime(value) {
|
||||
try {
|
||||
return new Intl.DateTimeFormat(isEnglish() ? 'en-US' : 'zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(new Date(value));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function ChannelListHeading({ className = '', id, title, connectionLabel }) {
|
||||
const helpId = React.useId();
|
||||
|
|
@ -46,3 +60,24 @@ export function BotStatusMeta({
|
|||
h('span', null, '最近检查'),
|
||||
h('span', null, formatCheckedTime(lastCheckedAt))));
|
||||
}
|
||||
|
||||
export function LastMessageErrorSummary({ className = '', error }) {
|
||||
if (!error) return null;
|
||||
const occurredAt = messageErrorTime(error.at);
|
||||
return h('div', {
|
||||
className: `${className} dim-cardSummary`.trim(),
|
||||
role: 'status',
|
||||
},
|
||||
h('strong', null, '最近一条消息处理失败'),
|
||||
':',
|
||||
h('span', null, error.message),
|
||||
'(',
|
||||
h('span', null, '错误码'),
|
||||
` ${error.code} · `,
|
||||
h('span', null, '参考号'),
|
||||
` ${error.referenceId}`,
|
||||
occurredAt ? h(React.Fragment, null,
|
||||
' · ',
|
||||
h('time', { dateTime: new Date(error.at).toISOString() }, occurredAt)) : null,
|
||||
')');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue