// Janela "Novo job": motor Glacier próprio, aberto por open_window a partir
// do app principal (handlers/jobs.luau → open_new_job_window), que semeia a
// conexão + os catálogos de projetos/serviços já buscados pela janela
// principal (open_window({ data = ...
screen(title = "Novo job — Rustploy") {
resources {
component(name = SemProjetosParaJob) {
text(class = u-muted, content = "Nenhum projeto ainda.")
}
link(rel = import, href = "components/picker_row.gvb", as = PickerRow)
link(rel = import, href = "components/tab_button.gvb", as = TabButton)
script(src = "scripts/new_job_window.luau")
}
column(class = dialog__screen) {
row(class = titlebar) {
row(class = titlebar__drag, on_press = window:drag) {
text(class = titlebar__dot, content = "●")
text(class = titlebar__title, content = "Novo job — Rustploy")
}
button(class = titlebar__btn, on_click = window:minimize, text = "—")
button(class = "titlebar__btn titlebar__btn--close", on_click = window:close, text = "✕")
}
scrollable(class = dialog__body, direction = vertical) {
column(class = form-panel) {
// Passo 1: escolher o projeto
if @new_job_step == "pick_project" {
text(class = u-label-cap, content = "ESCOLHA O PROJETO")
text(
class = u-muted,
content = """
O job sobe um stack docker-compose próprio; o projeto define a
rede.
""",
)
column(class = kv-list) {
each @new_job_projects as p (fallback = SemProjetosParaJob) {
PickerRow(
title = @p.name,
subtitle = "",
button_label = "Selecionar ›",
action = new_job_pick_project:@p.id,
)
}
}
row(class = dialog__actions) {
column(class = u-fill)
button(class = "btn btn--ghost", on_click = cancel, disabled = @busy_cancel, text = Cancelar)
}
}
if @new_job_step == "pick_service" {
text(
class = u-label-cap,
content = "SERVIÇO GATILHO (OPCIONAL) — @new_job_project_name",
)
text(
class = u-muted,
content = """
Empresta env vars/secrets de base ao job (a rede Docker já vem do
projeto). O job não roda dentro do container dele — sobe um stack
novo, próprio. Sem serviço gatilho, o job é 100% autônomo e só
recebe as env vars do projeto.
""",
)
row(class = env__add) {
button(
class = "btn btn--ghost",
on_click = new_job_pick_no_service,
disabled = @busy_new_job_pick_no_service,
text = "Nenhum — job autônomo ›",
)
}
text(
if = @new_job_services_filtered,
equals = "[]",
class = u-muted,
content = "Este projeto ainda não tem serviços.",
)
column(class = kv-list) {
PickerRow(
:for-each = new_job_services_filtered,
var = s,
title = @s.name,
subtitle = "",
button_label = "Selecionar ›",
action = new_job_pick_service:@s.id,
)
}
row(class = dialog__actions) {
column(class = u-fill)
button(class = "btn btn--ghost", on_click = new_job_back, disabled = @busy_new_job_back, text = "‹ Voltar")
}
}
if @new_job_step == "form" {
if @new_job_edit_id != "" {
text(class = u-label-cap, content = "EDITAR JOB — @new_job_name")
} else {
text(
class = u-label-cap,
content = "NOVO JOB — @new_job_project_name / @new_job_service_name",
)
}
form(
name = new_job_form,
on_submit = new_job_create,
width = fill,
spacing = 10,
) {
text(class = field__label, content = "NOME")
input(
class = dialog__input,
form_control = new_job_name,
:value = new_job_name,
on_change = field:new_job_name,
placeholder = "ex.: backup-db",
)
text(class = u-label-cap, content = "FONTE DO COMPOSE")
scroll(class = tabs__scroll, direction = horizontal) {
row(class = tabs__main) {
TabButton(
label = Compose,
current = @new_job_source,
target = compose,
action = new_job_source:compose,
)
TabButton(
label = Git,
current = @new_job_source,
target = git,
action = new_job_source:git,
)
}
}
if @new_job_source == "compose" {
text(class = field__label, content = "DOCKER-COMPOSE.YML")
textarea(
class = env__editor,
font = mono,
:value = new_job_compose,
placeholder = l"""
services:
job:
image: busybox
command: ["sh", "-c", "echo ok"]
""",
)
}
if @new_job_source == "git" {
text(
class = u-muted,
content = """
Selecione a conta conectada, o repositório e a branch. O repo
precisa já ter um docker-compose.yml no caminho informado.
""",
)
row(class = busy-row, if = @new_job_git_message, not_equals = "") {
spinner(class = busy-row__spin, if = @new_job_git_busy)
text(class = u-muted, content = "@new_job_git_message")
}
text(class = field__label, content = "CONTA GIT")
select(
class = form-select,
:options = new_job_git_providers,
:value = new_job_git_provider_id,
on_change = new_job_git_provider_pick,
placeholder = "selecione a conta",
labelField = display,
valueField = id,
)
text(class = u-muted, content = "Conecte contas em Settings → Git.")
text(class = field__label, content = "REPOSITÓRIO")
select(
class = form-select,
:options = new_job_git_repos,
:value = new_job_git_repo,
on_change = new_job_git_repo_pick,
placeholder = "selecione o repositório",
labelField = full_name,
valueField = full_name,
)
text(class = field__label, content = "BRANCH")
select(
class = form-select,
:options = new_job_git_branches,
:value = new_job_git_branch,
on_change = field:new_job_git_branch,
placeholder = "selecione a branch",
labelField = name,
valueField = name,
)
text(class = field__label, content = "CAMINHO DO COMPOSE NO REPO")
input(
class = dialog__input,
form_control = new_job_compose_path,
:value = new_job_compose_path,
on_change = field:new_job_compose_path,
placeholder = docker-compose.yml,
)
}
text(
class = field__label,
content = "MAIN SERVICE (nome dentro do compose acima)",
)
input(
class = dialog__input,
form_control = new_job_main_service,
:value = new_job_main_service,
on_change = field:new_job_main_service,
placeholder = "ex.: job",
)
text(class = field__label, content = "VARIÁVEIS DE AMBIENTE (opcional)")
text(
class = u-muted,
content = """
Sobrescrevem as do projeto/serviço gatilho por cima. Formato
KEY=VALUE, uma por linha (# comentário).
""",
)
textarea(
class = env__editor,
font = mono,
:value = new_job_env_text,
placeholder = "FLOW_MYENV=test",
)
text(class = u-label-cap, content = "RECORRÊNCIA")
scroll(class = tabs__scroll, direction = horizontal) {
row(class = tabs__main) {
TabButton(
label = Manual,
current = @new_job_kind,
target = manual,
action = new_job_kind:manual,
)
TabButton(
label = Intervalo,
current = @new_job_kind,
target = interval,
action = new_job_kind:interval,
)
TabButton(
label = Diária,
current = @new_job_kind,
target = daily,
action = new_job_kind:daily,
)
TabButton(
label = Semanal,
current = @new_job_kind,
target = weekly,
action = new_job_kind:weekly,
)
}
}
if @new_job_kind == "interval" {
text(class = field__label, content = "A CADA QUANTAS HORAS")
// Teto de 168 = uma semana, igual ao da limpeza automática em
// home.gv. Acima disso existe a recorrência "Semanal".
spinbox(
field_class = field__spin,
form_control = new_job_hours,
:value = new_job_hours,
min = 1,
max = 168,
width = 90,
placeholder = 6,
)
}
if @new_job_kind == "daily" {
row(class = env__add) {
column(class = field) {
text(class = field__label, content = "HORÁRIO")
timeedit(:value = new_job_time)
}
}
}
if @new_job_kind == "weekly" {
text(class = field__label, content = "DIA DA SEMANA")
// Mesma troca de home.gv: sete <TabButton> + handler viraram um
// <radiogroup>, que grava `new_job_weekday` sozinho.
scroll(class = tabs__scroll, direction = horizontal) {
row(class = tabs__main) {
radiogroup(
:value = new_job_weekday,
:items = weekdays,
layout = row,
)
}
}
row(class = env__add) {
column(class = field) {
text(class = field__label, content = "HORÁRIO")
timeedit(:value = new_job_time)
}
}
}
text(
if = @new_job_error,
not_equals = "",
class = u-error,
content = "@new_job_error",
)
row(class = busy-row, if = @new_job_message, not_equals = "") {
spinner(class = busy-row__spin, if = @new_job_busy)
text(class = u-muted, content = "@new_job_message")
}
row(class = dialog__actions) {
column(class = u-fill)
button(
class = "btn btn--ghost",
if = @new_job_edit_id,
not_equals = "",
on_click = new_job_back,
disabled = @busy_new_job_back,
text = Fechar,
)
button(
class = "btn btn--ghost",
if = @new_job_edit_id,
equals = "",
on_click = new_job_back,
disabled = @busy_new_job_back,
text = "‹ Voltar",
)
button(
class = "btn btn--primary",
if = @new_job_edit_id,
not_equals = "",
on_click = new_job_create,
disabled = @busy_new_job_create,
text = Salvar,
)
button(
class = "btn btn--primary",
if = @new_job_edit_id,
equals = "",
on_click = new_job_create,
disabled = @busy_new_job_create,
text = "Criar job",
)
}
}
}
}
}
}
}