component {
resources {
component(name = SemVariaveis) {
text("{t('common.no_variables')}", class = u-muted)
}
}
scrollable(
direction = vertical,
class = u-fill-all,
if = @project_loading,
not_equals = true,
) {
column(class = env--flow) {
row(class = env__head) {
text(
"{t('project_env.inherited_by_all_services_of_this')}",
class = "u-muted u-fill",
)
button(
"{t('common.export')}",
class = "btn btn--ghost btn--wide",
on_click = project_env_export,
disabled = @busy_project_env_export
)
text(" ")
if @project_env_text_open == "true" {
button(
"{t('common.close')}",
class = "btn btn--blue btn--wide",
on_click = project_env_text_toggle,
disabled = @busy_project_env_text_toggle
)
} else {
button(
"{t('common.env')}",
class = tabs__tab,
on_click = project_env_text_toggle,
disabled = @busy_project_env_text_toggle
)
}
}
row(class = env__add) {
text("{t('project_env.move_to_service')}", class = u-muted)
select(
class = form-select,
:options = project_service_options,
:value = move_target_service_id,
on_change = move_target_pick,
label_field = display,
value_field = id,
)
}
form(
error_prefix = error_,
name = project_env_add,
on_submit = project_env_add,
on_validation_error = project_env_show_validation_errors,
class = "form form--gap-8",
) {
row(class = env__add) {
input(
class = env__input,
form_control = project_env_new_key,
rules = required,
msg = "{t('common.enter_the_key')}",
placeholder = "{t('common.key')}",
)
if @project_env_new_is_secret == "true" {
select(
class = form-select,
:options = project_env_secret_options,
:value = project_env_new_value,
on_change = field:project_env_new_value,
label_field = label,
value_field = name,
placeholder = "{t('environment.pick_secret')}",
)
} else {
input(
class = env__input,
form_control = project_env_new_value,
placeholder = "{t('common.value')}",
)
}
checkbox(
class = env__use-secret,
:checked = project_env_new_is_secret,
on_toggle = project_env_new_use_secret,
label = "{t('environment.use_secret')}",
)
button(
"{t('common.add')}",
type = submit,
disabled = @busy_project_env_add,
class = "btn btn--primary"
)
}
if @project_env_new_is_secret == "true" {
text(
"{t('project_env.no_secret_registered_create_one')}",
if = @project_secrets,
empty = "",
class = u-muted,
)
}
}
text(
"@error_project_env_new_key",
class = u-error,
if = @error_project_env_new_key,
not_equals = "",
)
column(class = env--flow) {
column(class = kv-list) {
template(
:for_each = project_env,
foreach_fallback = SemVariaveis,
var = e,
on_reorder = project_env_reorder,
reorder_key = key,
) {
if @e.__dragging == "true" {
if @e.kind == "comment" {
row(class = "kv-list__row kv-list__row--dragging") {
text(
"⋮ ",
class = "env__drag-handle env__drag-handle--dragging",
drag_handle = true,
)
text("@e.value", class = u-muted)
}
} else {
row(class = "kv-list__row kv-list__row--dragging") {
text(
"⋮ ",
class = "env__drag-handle env__drag-handle--dragging",
drag_handle = true,
)
button(
"✕",
class = env__del,
on_click = project_env_delete:@e.key,
disabled = @busy_project_env_delete
)
text(class = env__sep)
text("@e.key_display", class = env__key)
text("@e.value", class = "kv-list__val kv-list__val--compact")
}
}
} else {
if @e.kind == "comment" {
row(class = kv-list__row) {
text(
"⋮ ",
class = env__drag-handle,
drag_handle = true,
)
text("@e.value", class = u-muted)
}
} else {
row(class = kv-list__row) {
text(
"⋮ ",
class = env__drag-handle,
drag_handle = true,
)
button(
"✕",
class = env__del,
on_click = project_env_delete:@e.key,
disabled = @busy_project_env_delete
)
button(
"🔒",
class = "btn btn--ghost btn--sm",
on_click = project_env_to_secret:@e.key,
disabled = @busy_project_env_to_secret,
if = @e.kind,
equals = plain,
tooltip = "{t('environment.to_secret')}",
tooltip_delay = "500ms",
)
template(if = @e.kind, equals = plain) {
button(
"↓",
class = "btn btn--ghost btn--sm",
if = @move_target_service_id,
equals = "",
disabled = true,
tooltip = "{t('project_env.choose_service')}",
tooltip_delay = "500ms",
)
button(
"↓",
class = "btn btn--ghost btn--sm",
on_click = project_env_to_service:@e.key,
disabled = @busy_project_env_to_service,
if = @move_target_service_id,
not_equals = "",
tooltip = "{t('project_env.env_to_service')}",
tooltip_delay = "500ms",
)
}
button(
"🔓",
class = "btn btn--ghost btn--sm",
on_click = project_secret_to_env:@e.secret_name,
disabled = @busy_project_secret_to_env,
if = @e.kind,
equals = secret,
tooltip = "{t('environment.secret_to_env')}",
tooltip_delay = "500ms",
)
text(class = env__sep)
input(
class = env__inline-key,
:value = "@e.bind_key",
on_change = project_env_row_key:@e.key,
placeholder = "{t('common.key')}",
)
if @e.use_secret == "true" {
select(
class = env__secret-select,
:options = project_env_secret_options,
:value = "@e.bind_secret",
on_change = project_env_row_secret:@e.key,
label_field = label,
value_field = name,
placeholder = "{t('environment.pick_secret')}",
)
} else {
input(
class = env__inline,
:value = "@e.bind_value",
on_change = project_env_row_value:@e.key,
placeholder = "{t('common.value')}",
)
}
checkbox(
class = env__use-secret,
:checked = "@e.bind_use_secret",
on_toggle = project_env_row_use_secret:@e.key,
label = "{t('environment.use_secret')}",
)
button(
"OK",
class = "btn btn--primary btn--sm",
on_click = project_env_row_save:@e.key,
disabled = @busy_project_env_row_save,
if = @e.dirty,
equals = "true",
)
button(
"✕",
class = "btn btn--ghost btn--sm",
on_click = project_env_row_reset:@e.key,
if = @e.dirty,
equals = "true",
tooltip = "{t('environment.undo')}",
tooltip_delay = "500ms",
)
}
}
}
}
if @project_env_text_open == "true" {
text(
"{t('common.paste_edit_in_the_key')}",
class = u-muted,
)
textarea(
class = env__editor,
font = "JetBrains Mono",
:value = project_env_text,
placeholder = "{t('common.key_value_comment')}",
)
row(class = env__add) {
button(
"{t('common.save')}",
class = "btn btn--primary",
on_click = project_env_import,
disabled = @busy_project_env_import
)
button(
"{t('common.cancel')}",
class = "btn btn--ghost",
on_click = project_env_text_cancel,
disabled = @busy_project_env_text_cancel
)
}
}
}
}
}
}
}