🐛 fix(vscode): GitHub 请求和 gh auth token 加超时,设置页连不上 GitHub 时不再显示成未登录
This commit is contained in:
1 parent
9c7c9d8636
commit
a8d922f3ba
16 files changed
+267
-44
No files matched your search
@@ -580,6 +580,7 @@ export function App() {
|
||||
host={settings?.host ?? ''}
|
||||
forgeKind={settings?.forgeKind ?? 'gitea'}
|
||||
ghLogin={settings?.ghLogin}
|
||||
ghLoginError={settings?.ghLoginError}
|
||||
errorMessage={settings?.errorMessage}
|
||||
canCancel={settings?.canCancel}
|
||||
initialTokenSaved={settings?.tokenSaved ?? false}
|
||||
|
||||
@@ -117,6 +117,13 @@ describe('设置面板的仓库连接', () => {
|
||||
expect(html).toContain('未登录')
|
||||
expect(html).toContain('gh auth login')
|
||||
})
|
||||
|
||||
it('gitHub 仓库连不上 GitHub 时显示原因,不说成没登录', () => {
|
||||
const html = render({ host: 'github.com', forgeKind: 'github', ghLoginError: '无法连接 GitHub,暂时确认不了登录状态:请求超时', initialTokenSaved: false })
|
||||
expect(html).toContain('无法连接 GitHub')
|
||||
expect(html).toContain('请求超时')
|
||||
expect(html).not.toContain('未登录')
|
||||
})
|
||||
})
|
||||
|
||||
describe('webhook 配置说明', () => {
|
||||
|
||||
@@ -77,6 +77,8 @@ export interface SettingsModalProps {
|
||||
forgeKind: ForgeKind
|
||||
/** gh 当前登录的 GitHub 账号;没登录或登录失效时没有。只在 GitHub 仓库下有意义。 */
|
||||
ghLogin?: string
|
||||
/** 查 gh 账号时连不上 GitHub、超时这类失败的说明;有它时不能按没登录显示。 */
|
||||
ghLoginError?: string
|
||||
errorMessage?: string
|
||||
canCancel?: boolean
|
||||
initialTokenSaved: boolean
|
||||
@@ -168,7 +170,7 @@ const FIELD_TO_GROUP: Record<ErrorKey, GroupKey> = {
|
||||
webhookPort: 'network',
|
||||
}
|
||||
|
||||
function GhLoginStatus({ login }: { login?: string }): ReactElement {
|
||||
function GhLoginStatus({ login, error }: { login?: string, error?: string }): ReactElement {
|
||||
return (
|
||||
<div className="mb-3 text-xs">
|
||||
<span className="mb-1 block opacity-80">GitHub 账号</span>
|
||||
@@ -180,15 +182,17 @@ function GhLoginStatus({ login }: { login?: string }): ReactElement {
|
||||
<b>{login}</b>
|
||||
</span>
|
||||
)
|
||||
: (
|
||||
<span className="text-state-red">
|
||||
未登录或登录已失效:请在终端运行
|
||||
{' '}
|
||||
<code>gh auth login</code>
|
||||
{' '}
|
||||
登录 github.com,然后回到看板点刷新
|
||||
</span>
|
||||
)}
|
||||
: error
|
||||
? <span className="text-state-red">{error}</span>
|
||||
: (
|
||||
<span className="text-state-red">
|
||||
未登录或登录已失效:请在终端运行
|
||||
{' '}
|
||||
<code>gh auth login</code>
|
||||
{' '}
|
||||
登录 github.com,然后回到看板点刷新
|
||||
</span>
|
||||
)}
|
||||
<span className="mt-1 block text-[10px] opacity-60">
|
||||
GitHub 仓库直接用 GitHub CLI(gh)的登录,插件不另存 token;换账号用
|
||||
{' '}
|
||||
@@ -283,6 +287,7 @@ export function SettingsModal({
|
||||
host: initialHost,
|
||||
forgeKind,
|
||||
ghLogin,
|
||||
ghLoginError,
|
||||
errorMessage,
|
||||
canCancel,
|
||||
initialTokenSaved,
|
||||
@@ -581,7 +586,7 @@ export function SettingsModal({
|
||||
{activeGroup === 'auth' && (
|
||||
<>
|
||||
{forgeKind === 'github'
|
||||
? <GhLoginStatus login={ghLogin} />
|
||||
? <GhLoginStatus login={ghLogin} error={ghLoginError} />
|
||||
: (
|
||||
<>
|
||||
<Field label="Gitea Host" error={errors.host}>
|
||||
|
||||
@@ -71,6 +71,7 @@ export interface SettingsOverlayState {
|
||||
host: string
|
||||
forgeKind: ForgeKind
|
||||
ghLogin?: string
|
||||
ghLoginError?: string
|
||||
errorMessage?: string
|
||||
canCancel: boolean
|
||||
tokenSaved: boolean
|
||||
@@ -961,6 +962,7 @@ export function useIssues(): UseIssuesResult {
|
||||
host: msg.host,
|
||||
forgeKind: msg.forgeKind,
|
||||
ghLogin: msg.ghLogin,
|
||||
ghLoginError: msg.ghLoginError,
|
||||
errorMessage: msg.errorMessage,
|
||||
canCancel: msg.canCancel === true,
|
||||
tokenSaved: msg.tokenSaved,
|
||||
|
||||
@@ -112,6 +112,8 @@ export type ExtensionToWebview
|
||||
forgeKind: ForgeKind
|
||||
/** gh 当前登录的 GitHub 账号;没登录或登录失效时没有。 */
|
||||
ghLogin?: string
|
||||
/** 查 gh 账号时连不上 GitHub、超时这类失败的说明;有它时不能按没登录显示。 */
|
||||
ghLoginError?: string
|
||||
errorMessage?: string
|
||||
canCancel?: boolean
|
||||
tokenSaved: boolean
|
||||
|
||||
Reference in new issue
Block a user