// Git: contas conectadas + formulário de conexão
component {
resources {
component(name = SemContasGit) {
text(class = u-muted, content = "Nenhuma conta Git conectada ainda.")
}
}
scrollable(direction = vertical, class = u-fill-all) {
column(class = form-panel) {
text(
class = u-label-cap,
content = "CONTAS CONECTADAS (@gitea_count)",
)
column(class = kv-list) {
template(
:for-each = gitea_providers,
var = p,
foreach_fallback = SemContasGit,
) {
row(class = kv-list__row) {
column(class = page-head__titles) {
text(class = env__key, content = "@p.name")
text(
class = u-muted,
content = "@p.kind · @p.base_url · @p.auth_mode · @p.account",
)
}
button(
class = "btn btn--danger",
on_click = git_provider_delete:@p.id,
disabled = @busy_git_provider_delete,
text = Remover,
)
}
}
}
hr
text(class = u-label-cap, content = "CONECTAR CONTA GIT")
// Tipo de provedor: Gitea ou GitHub. Troca a redirect URI (path por
// provedor) e os textos de ajuda abaixo.
scroll(class = tabs__scroll, direction = horizontal) {
row(class = tabs__main) {
TabButton(
label = Gitea,
current = @git_provider_kind,
target = gitea,
action = git_provider_kind:gitea,
)
TabButton(
label = GitHub,
current = @git_provider_kind,
target = github,
action = git_provider_kind:github,
)
}
}
text(
if = @git_provider_message,
not_equals = "",
class = u-muted,
content = "@git_provider_message",
)
button(
if = @git_provider_oauth_url,
not_equals = "",
class = "btn btn--primary",
on_click = open:git_provider_oauth_url,
text = "Abrir autorização no navegador",
)
form(
name = git_provider,
on_submit = git_provider_connect,
spacing = 10,
width = fill,
) {
row(class = healthcheck__grid) {
column(class = healthcheck__field) {
text(class = u-label-cap, content = "NOME")
input(
placeholder = "Meu Gitea",
class = field__input,
form_control = git_provider_name,
:value = git_provider_name,
on_change = field:git_provider_name,
)
text(
if = @error_git_provider_name,
not_equals = "",
class = u-error,
content = "@error_git_provider_name",
)
}
column(class = healthcheck__field) {
text(class = u-label-cap, content = "BASE URL")
input(
placeholder = "https://gitea.exemplo.com",
class = field__input,
form_control = git_provider_base_url,
:value = git_provider_base_url,
on_change = field:git_provider_base_url,
)
text(
if = @git_provider_kind,
equals = github,
class = u-muted,
content = """
Deixe vazio para github.com. Só preencha para GitHub
Enterprise Server (ex.: https://ghe.suaempresa.com).
""",
)
}
}
text(class = u-label-cap, content = "MÉTODO")
scroll(class = tabs__scroll, direction = horizontal) {
tabbar(
:value = git_provider_mode, active = @git_provider_mode, :items = git_provider_modes,
tab_class = tabs__tab, tab_active_class = "tabs__tab tabs__tab--active", padding = "9 16", size = 14,
)
}
// OAuth2
if @git_provider_mode != "pat" {
text(class = u-label-cap, content = "CLIENT ID")
input(
placeholder = "",
class = field__input,
form_control = git_provider_client_id,
:value = git_provider_client_id,
on_change = field:git_provider_client_id,
)
text(class = u-label-cap, content = "CLIENT SECRET")
input(
placeholder = "",
secure = true,
class = field__input,
form_control = git_provider_client_secret,
:value = git_provider_client_secret,
on_change = field:git_provider_client_secret,
)
text(
class = u-label-cap,
content = "REDIRECT URI (cole no app OAuth do provedor)",
)
row(class = kv-list__row) {
text(class = "kv-list__val kv-list__val--compact", content = "@git_provider_redirect")
button(
class = "btn btn--ghost btn--xs",
on_click = copy_ctx:git_provider_redirect,
text = Copiar,
)
}
text(
if = @git_provider_kind,
not_equals = github,
class = u-muted,
content = """
No Gitea: Settings → Applications → crie um OAuth2 app e
cole a Redirect URI acima.
""",
)
text(
if = @git_provider_kind,
equals = github,
class = u-muted,
content = """
No GitHub: Settings → Developer settings → OAuth Apps → New
OAuth App e cole a Redirect URI acima em "Authorization
callback URL".
""",
)
}
// PAT
if @git_provider_mode == "pat" {
text(class = u-label-cap, content = "PERSONAL ACCESS TOKEN")
input(
placeholder = "",
secure = true,
class = field__input,
form_control = git_provider_personal_access_token,
:value = git_provider_personal_access_token,
on_change = field:git_provider_personal_access_token,
)
text(
if = @git_provider_kind,
not_equals = github,
class = u-muted,
content = """
No Gitea: Settings → Applications → Generate New Token
(escopo: repo).
""",
)
text(
if = @git_provider_kind,
equals = github,
class = u-muted,
content = """
No GitHub: Settings → Developer settings → Personal access
tokens → gere um token com escopo "repo".
""",
)
}
row(class = env__add) {
button(
class = "btn btn--primary",
on_click = git_provider_connect,
disabled = @busy_git_provider_connect,
text = "Conectar conta",
)
button(
class = tabs__tab,
on_click = git_provider_refresh,
disabled = @busy_git_provider_refresh,
text = "Atualizar lista",
)
}
}
}
}
}