rustploy-gui 0.1.25

Rustploy — desktop client (glacier-ui) for the Rustploy PaaS daemon
// Janela "Novo token do registry": motor Glacier próprio, aberto por open_window a partir do app principal.
screen(title = "Novo token — Rustploy") {
  resources {

    style """
    .dialog__secret {
      width: fill;
      background: var(--raised);
      border-radius: 4;
      border-width: 1;
      border-color: var(--accent);
      padding: 12;
      spacing: 8;
    }
    """

    script(src = "scripts/new_registry_token_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 token — 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: formulário
        if @new_registry_token_step == "form" {
          text(class = u-label-cap, content = "NOVO TOKEN DE ACESSO (BASIC AUTH)")

          text(
            class = u-muted,
            content = "Usado em `docker login`/push/pull contra o registry embutido.",
          )

          form(
            name = new_registry_token_form,
            on_submit = new_registry_token_create,
            on_validation_error = new_registry_token_show_validation_errors,
            width = fill,
            spacing = 10,
          ) {
            text(class = field__label, content = "NOME")

            input(
              class = dialog__input,
              form_control = new_registry_token_name,
              rules = required,
              msg = "informe um nome",
              placeholder = "ex.: ci-deploy",
            )

            text(
              class = u-error,
              if = @error_new_registry_token_name,
              not_empty,
              content = "@error_new_registry_token_name",
            )

            text(class = u-label-cap, content = "ESCOPO")

            scroll(class = tabs__scroll, direction = horizontal) {
              tabbar(
                :value = new_registry_token_scope, active = @new_registry_token_scope, :items = new_registry_token_scopes,
                tab_class = tabs__tab, tab_active_class = "tabs__tab tabs__tab--active", padding = "9 16", size = 14,
              )
            }

            text(
              if = @new_registry_token_error,
              not_equals = "",
              class = u-error,
              content = "@new_registry_token_error",
            )

            row(class = busy-row, if = @new_registry_token_message, not_equals = "") {
              spinner(class = busy-row__spin, if = @new_registry_token_busy)
              text(class = u-muted, content = "@new_registry_token_message")
            }

            row(class = dialog__actions) {
              column(class = u-fill)

              button(
                class = "btn btn--ghost",
                on_click = window:close,
                text = Cancelar,
              )

              button(type = submit, disabled = @busy_new_registry_token_create, class = "btn btn--primary", text = "Criar token")
            }
          }
        }

        // Passo 2: segredo exibido uma única vez
        if @new_registry_token_step == "reveal" {
          text(class = u-label-cap, content = "TOKEN CRIADO — COPIE AGORA")

          text(
            class = u-error,
            content = """
              O segredo não pode ser recuperado depois de fechar esta janela.
            """,
          )

          column(class = dialog__secret) {
            text(class = field__label, content = "COMANDO DOCKER LOGIN")
            text(class = "kv-list__val kv-list__val--compact", content = "@new_registry_token_login_command")

            row(class = dialog__actions) {
              column(class = u-fill)

              button(
                class = "btn btn--ghost btn--xs",
                on_click = copy_ctx:new_registry_token_login_command,
                text = Copiar,
              )
            }
          }

          row(class = dialog__actions) {
            column(class = u-fill)
            button(class = "btn btn--primary", on_click = window:close, text = Fechar)
          }
        }
      }
    }
  }
}