/* 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 { 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 ProposalCard from './ProposalCard' 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 use. The host refuses any other one before // the add-on is called. function GitHubFields({ form, setForm, t }) { 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 ( <> {(p) => (