// 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 = 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)
style """
/* Titlebar custom (mesma linguagem visual do app.gv) */
.titlebar { width: fill; height: 32; background: var(--surface); align-y: center; }
.titlebar_drag { width: fill; height: fill; align-y: center; padding: 0 0 0 16; spacing: 9; }
.titlebar_dot { size: 10; color: var(--blue); }
.titlebar_title { size: 12; bold: true; color: var(--muted); }
.win_btn { width: 48; padding: 5 0; color: var(--border); text-align: center; }
.win_close { width: 48; padding: 5 0; color: var(--danger); text-align: center; }
.njob_screen { width: fill; height: fill; }
.njob_body { width: fill; height: fill; }
.np_label { size: 11; bold: true; color: var(--muted); }
.np_input { width: fill; }
.np_group { width: fill; spacing: 6; }
.np_actions { width: fill; spacing: 10; align-y: center; }
.np_spacer { width: fill; }
"""
script(src = "scripts/new_job_window.luau")
}
column(class = njob_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 = win_btn, on_click = window:minimize, text = "—")
button(class = win_close, on_click = window:close, text = "✕")
}
scrollable(class = njob_body, direction = vertical) {
column(class = form_panel) {
// Passo 1: escolher o projeto
if @njob_step == "pick_project" {
text(class = label_cap, content = "ESCOLHA O PROJETO")
text(
class = muted,
content = """
O job sobe um stack docker-compose próprio; o projeto define a
rede.
""",
)
column(class = kv_list) {
each @njob_projects as p (fallback = SemProjetosParaJob) {
PickerRow(
title = @p.name,
subtitle = "",
button_label = "Selecionar ›",
action = njob_pick_project:@p.id,
)
}
}
row(class = np_actions) {
column(class = np_spacer)
button(class = btn_ghost, on_click = cancel, text = Cancelar)
}
}
if @njob_step == "pick_service" {
text(
class = label_cap,
content = "SERVIÇO GATILHO (OPCIONAL) — @njob_project_name",
)
text(
class = 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_ghost,
on_click = njob_pick_no_service,
text = "Nenhum — job autônomo ›",
)
}
text(
if = @njob_services_filtered,
equals = "[]",
class = muted,
content = "Este projeto ainda não tem serviços.",
)
column(class = kv_list) {
PickerRow(
:for-each = njob_services_filtered,
var = s,
title = @s.name,
subtitle = "",
button_label = "Selecionar ›",
action = njob_pick_service:@s.id,
)
}
row(class = np_actions) {
column(class = np_spacer)
button(class = btn_ghost, on_click = njob_back, text = "‹ Voltar")
}
}
if @njob_step == "form" {
if @njob_edit_id != "" {
text(class = label_cap, content = "EDITAR JOB — @njob_name")
} else {
text(
class = label_cap,
content = "NOVO JOB — @njob_project_name / @njob_service_name",
)
}
form(
name = njob_form,
on_submit = njob_create,
width = fill,
spacing = 10,
) {
text(class = np_label, content = "NOME")
input(
class = np_input,
form_control = njob_name,
:value = njob_name,
on_change = field:njob_name,
placeholder = "ex.: backup-db",
)
text(class = label_cap, content = "FONTE DO COMPOSE")
row(class = tabs) {
TabButton(
label = Compose,
current = @njob_source,
target = compose,
action = njob_source:compose,
)
TabButton(
label = Git,
current = @njob_source,
target = git,
action = njob_source:git,
)
}
if @njob_source == "compose" {
text(class = np_label, content = "DOCKER-COMPOSE.YML")
textarea(
class = env_editor,
font = mono,
:value = njob_compose,
placeholder = l"""
services:
job:
image: busybox
command: ["sh", "-c", "echo ok"]
""",
)
}
if @njob_source == "git" {
text(
class = 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 = @njob_git_msg, not_equals = "") {
spinner(class = busy_spin, if = @njob_git_busy)
text(class = muted, content = "@njob_git_msg")
}
text(class = np_label, content = "CONTA GIT")
select(
class = select,
:options = njob_git_providers,
:value = njob_git_provider_id,
on_change = njob_git_provider_pick,
placeholder = "selecione a conta",
labelField = display,
valueField = id,
)
text(class = muted, content = "Conecte contas em Settings → Git.")
text(class = np_label, content = "REPOSITÓRIO")
select(
class = select,
:options = njob_git_repos,
:value = njob_git_repo,
on_change = njob_git_repo_pick,
placeholder = "selecione o repositório",
labelField = full_name,
valueField = full_name,
)
text(class = np_label, content = "BRANCH")
select(
class = select,
:options = njob_git_branches,
:value = njob_git_branch,
on_change = field:njob_git_branch,
placeholder = "selecione a branch",
labelField = name,
valueField = name,
)
text(class = np_label, content = "CAMINHO DO COMPOSE NO REPO")
input(
class = np_input,
form_control = njob_compose_path,
:value = njob_compose_path,
on_change = field:njob_compose_path,
placeholder = docker-compose.yml,
)
}
text(
class = np_label,
content = "MAIN SERVICE (nome dentro do compose acima)",
)
input(
class = np_input,
form_control = njob_main_service,
:value = njob_main_service,
on_change = field:njob_main_service,
placeholder = "ex.: job",
)
text(class = np_label, content = "VARIÁVEIS DE AMBIENTE (opcional)")
text(
class = 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 = njob_env_text,
placeholder = "FLOW_MYENV=test",
)
text(class = label_cap, content = "RECORRÊNCIA")
row(class = tabs) {
TabButton(
label = Manual,
current = @njob_kind,
target = manual,
action = njob_kind:manual,
)
TabButton(
label = Intervalo,
current = @njob_kind,
target = interval,
action = njob_kind:interval,
)
TabButton(
label = Diária,
current = @njob_kind,
target = daily,
action = njob_kind:daily,
)
TabButton(
label = Semanal,
current = @njob_kind,
target = weekly,
action = njob_kind:weekly,
)
}
if @njob_kind == "interval" {
text(class = np_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 = spin_field,
form_control = njob_hours,
:value = njob_hours,
min = 1,
max = 168,
width = 90,
placeholder = 6,
)
}
if @njob_kind == "daily" {
row(class = env_add) {
column(class = np_group) {
text(class = np_label, content = "HORÁRIO")
timeedit(:value = njob_time)
}
}
}
if @njob_kind == "weekly" {
text(class = np_label, content = "DIA DA SEMANA")
// Mesma troca de home.gv: sete <TabButton> + handler viraram um
// <radiogroup>, que grava `njob_weekday` sozinho.
row(class = tabs) {
radiogroup(
:value = njob_weekday,
:items = weekdays,
layout = row,
)
}
row(class = env_add) {
column(class = np_group) {
text(class = np_label, content = "HORÁRIO")
timeedit(:value = njob_time)
}
}
}
text(
if = @njob_err,
not_equals = "",
class = err,
content = "@njob_err",
)
row(class = busy_row, if = @njob_msg, not_equals = "") {
spinner(class = busy_spin, if = @njob_busy)
text(class = muted, content = "@njob_msg")
}
row(class = np_actions) {
column(class = np_spacer)
button(
class = btn_ghost,
if = @njob_edit_id,
not_equals = "",
on_click = njob_back,
text = Fechar,
)
button(
class = btn_ghost,
if = @njob_edit_id,
equals = "",
on_click = njob_back,
text = "‹ Voltar",
)
button(
class = btn_primary,
if = @njob_edit_id,
not_equals = "",
on_click = njob_create,
text = Salvar,
)
button(
class = btn_primary,
if = @njob_edit_id,
equals = "",
on_click = njob_create,
text = "Criar job",
)
}
}
}
}
}
}
}