diff --git a/addons/github/ui/src/addon.jsx b/addons/github/ui/src/addon.jsx index 6ad153b751..f86ac11761 100644 --- a/addons/github/ui/src/addon.jsx +++ b/addons/github/ui/src/addon.jsx @@ -1,44 +1,58 @@ /* eslint-disable no-unused-vars -- components used only inside JSX look unused to this config, which has no eslint-plugin-react */ +import { useEffect, useState } from 'react' import { RouteProvider } from 'react-router-dom' import { getSdk, } from '../../../internal/host-compat/src/runtime.js' import { registerLocales } from '../../../internal/host-compat/src/i18n.js' +import Icon from '../../../internal/host-compat/src/components/Icon' import ConnectorPage from '../../../internal/connector-ui/src/ConnectorPage' -import { Field, FieldError, Notice, RadioCards, TextInput } from '../../../internal/connector-ui/src/controls' +import { connectorsApi } from '../../../internal/connector-ui/src/api' +import { Field, Notice, RadioCards, TextInput } from '../../../internal/connector-ui/src/controls' import en from './i18n/github.en.json' -import { checkLine, extraBody, extraForm, extraValid, githubSecret, parseRepos, reposProblem, tokenProblem, WRITE_MODES, writeModeOf } from './repos' +import { checkFailure, checkItem, extraBody, extraForm, extraValid, followName, githubSecret, parseRepos, PERMISSIONS, reposIssue, tokenProblem, WRITE_MODES, writeModeOf } from './repos' +import { finishTest, resultOf, startTest, subscribe } from './results' +import './github.css' registerLocales({ github: { en } }) +const TOKEN_URL = 'https://github.com/settings/personal-access-tokens/new' + +function TokenLink({ t, className, label }) { + return ( + + {label || t('tokenLink')} + + ) +} + // The fine-grained token. It is typed only to replace it. function GitHubToken({ form, setForm, t }) { const problem = tokenProblem(form) + const hint = <>{t('tokenHelp')}{!form.id && <>{' '}} return ( - + {(p) => ( setForm({ ...form, token: e.target.value })} /> )} ) } -// The repositories the agent may read. The host refuses any other one before +// The repositories the agent may use. The host refuses any other one before // the add-on is called. function GitHubFields({ form, setForm, t }) { - const problem = reposProblem(form.repos_text) + const issue = reposIssue(form.repos_text) const count = parseRepos(form.repos_text).length + const change = (text) => setForm({ ...form, repos_text: text, name: followName(form.name, form.repos_text, text) }) return ( <> - {tokenProblem(form) && {t(tokenProblem(form))}} - + {(p) => (