From b28ca5f27d1a6e541deca9ea4dcf8591366da397 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT <pierre.git@communiquons.org> Date: Mon, 16 Jun 2025 19:42:57 +0200 Subject: [PATCH] Add new options --- .../src/widgets/forms/CheckboxInput.tsx | 4 +- .../src/widgets/forms/CloudInitEditor.tsx | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx b/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx index 837fb39..91d151f 100644 --- a/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx +++ b/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx @@ -17,7 +17,9 @@ export function CheckboxInput(p: { <Checkbox disabled={!p.editable} checked={p.checked} - onChange={(e) => { p.onValueChange(e.target.checked); }} + onChange={(e) => { + p.onValueChange(e.target.checked); + }} /> } label={p.label} diff --git a/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx b/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx index a84ba8f..57b4f58 100644 --- a/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx +++ b/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx @@ -214,6 +214,23 @@ function CloudInitUserDataAssistant(p: CloudInitProps): React.ReactElement { onChange={onChange} yaml={user_data} /> + <CloudInitBooleanInput + editable={p.editable} + name="Expire password to require new password on next login" + yaml={user_data} + attrPath={["chpasswd", "expire"]} + onChange={onChange} + refUrl="https://cloudinit.readthedocs.io/en/latest/reference/modules.html#set-passwords" + /> + <br /> + <CloudInitBooleanInput + editable={p.editable} + name="Enable SSH password auth" + yaml={user_data} + attrPath={["ssh_pwauth"]} + onChange={onChange} + refUrl="https://cloudinit.readthedocs.io/en/latest/reference/modules.html#set-passwords" + /> <CloudInitTextInput editable={p.editable} name="Keyboard layout" @@ -262,3 +279,25 @@ function CloudInitTextInput(p: { /> ); } + +function CloudInitBooleanInput(p: { + editable: boolean; + name: string; + refUrl: string; + attrPath: Iterable<unknown>; + yaml: YAML.Document; + onChange: () => void; +}): React.ReactElement { + return ( + <CheckboxInput + editable={p.editable} + label={p.name} + checked={p.yaml.getIn(p.attrPath) === true} + onValueChange={(v) => { + if (v !== undefined) p.yaml.setIn(p.attrPath, v); + else p.yaml.deleteIn(p.attrPath); + p.onChange?.(); + }} + /> + ); +}