rustploy-gui 0.1.44

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 = "{t('new_registry_token_window.new_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)
        text("{t('new_registry_token_window.new_token_rustploy')}", class = titlebar__title)
      }

      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(
            "{t('new_registry_token_window.new_access_token_basic_auth')}",
            class = u-label-cap
          )

          text(
            "{t('new_registry_token_window.used_in_docker_login_push')}",
            class = u-muted,
          )

          form(
            name = new_registry_token_form,
            on_submit = new_registry_token_create,
            on_validation_error = new_registry_token_show_validation_errors,
            class = "form form--gap-10",
          ) {
            text("{t('common.name')}", class = field__label)

            input(
              class = dialog__input,
              form_control = new_registry_token_name,
              rules = required,
              msg = "{t('common.enter_a_name')}",
              placeholder = "{t('new_registry_token_window.e_g_ci_deploy')}",
            )

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

            text("{t('common.scope')}", class = u-label-cap)

            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(
              "@new_registry_token_error",
              if = @new_registry_token_error,
              not_equals = "",
              class = u-error,
            )

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

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

              button(
                class = "btn btn--ghost",
                on_click = window:close,
                text = "{t('common.cancel')}",
              )

              button(
                type = submit,
                disabled = @busy_new_registry_token_create,
                class = "btn btn--primary",
                text = "{t('new_registry_token_window.create_token')}"
              )
            }
          }
        }

        // Passo 2: segredo exibido uma única vez
        if @new_registry_token_step == "reveal" {
          text(
            "{t('new_registry_token_window.token_created_copy_it_now')}",
            class = u-label-cap
          )

          text(
            "{t('new_registry_token_window.the_secret_cannot_be_recovered_after')}",
            class = u-error,
          )

          column(class = dialog__secret) {
            text(
              "{t('new_registry_token_window.docker_login_command')}",
              class = field__label
            )

            text(
              "@new_registry_token_login_command",
              class = "kv-list__val kv-list__val--compact"
            )

            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 = "{t('common.copy')}",
              )
            }
          }

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