fix: bugs in env var validation and form field handling

This commit is contained in:
Gareth George
2024-03-02 13:32:27 -08:00
parent 5e064b1036
commit 02a9575cf7
2 changed files with 13 additions and 13 deletions
+10 -10
View File
@@ -392,16 +392,6 @@ export const AddPlanModal = ({
</Form.Item>
</Tooltip>
{/* Plan.retention */}
<RetentionPolicyView />
{/* Plan.hooks */}
<Form.Item
label={<Tooltip title={hooksListTooltipText}>Hooks</Tooltip>}
>
<HooksFormList />
</Form.Item>
{/* Plan.backup_flags */}
<Form.Item label={<Tooltip title="Extra flags to add to the 'restic backup' command">Backup Flags</Tooltip>}>
<Form.List
@@ -450,6 +440,16 @@ export const AddPlanModal = ({
</Form.List>
</Form.Item>
{/* Plan.retention */}
<RetentionPolicyView />
{/* Plan.hooks */}
<Form.Item
label={<Tooltip title={hooksListTooltipText}>Hooks</Tooltip>}
>
<HooksFormList />
</Form.Item>
<Form.Item shouldUpdate label="Preview">
{() => (
<Collapse
+3 -3
View File
@@ -283,7 +283,6 @@ export const AddRepoModal = ({
{(fields, { add, remove }, { errors }) => (
<>
{fields.map((field, index) => (
console.log("FIELD: ", field),
<Form.Item key={field.key}>
<Form.Item
{...field}
@@ -315,7 +314,7 @@ export const AddRepoModal = ({
<Form.Item>
<Button
type="dashed"
onClick={() => add("THIS IS A NEW VALUE")}
onClick={() => add("")}
style={{ width: "90%" }}
icon={<PlusOutlined />}
>
@@ -488,8 +487,9 @@ const envVarSetValidator = (form: FormInstance<FormData>, envVars: string[]) =>
});
// check that password is provided in some form
const password = form.getFieldValue("password");
if (
form.getFieldValue("password").length === 0 &&
(!password || password.length === 0) &&
!envVarNames.includes("RESTIC_PASSWORD") &&
!envVarNames.includes("RESTIC_PASSWORD_COMMAND") &&
!envVarNames.includes("RESTIC_PASSWORD_FILE")