fix: additional tooltips for add plan modal

This commit is contained in:
garethgeorge
2024-05-18 19:12:31 -07:00
parent 294864fe43
commit fcdf07da6c

View File

@@ -152,60 +152,64 @@ export const AddPlanModal = ({ template }: { template: Plan | null }) => {
disabled={confirmLoading} disabled={confirmLoading}
> >
{/* Plan.id */} {/* Plan.id */}
<Form.Item<Plan> <Tooltip title="Unique ID that identifies this plan in the backrest UI (e.g. s3-myplan). This cannot be changed after creation.">
hasFeedback <Form.Item<Plan>
name="id" hasFeedback
label="Plan Name" name="id"
initialValue={template ? template.id : ""} label="Plan Name"
validateTrigger={["onChange", "onBlur"]} initialValue={template ? template.id : ""}
rules={[ validateTrigger={["onChange", "onBlur"]}
{ rules={[
required: true, {
message: "Please input plan name", required: true,
}, message: "Please input plan name",
{
validator: async (_, value) => {
if (template) return;
if (config?.plans?.find((r) => r.id === value)) {
throw new Error("Plan with name already exists");
}
}, },
message: "Plan with name already exists", {
}, validator: async (_, value) => {
{ if (template) return;
pattern: namePattern, if (config?.plans?.find((r) => r.id === value)) {
message: throw new Error("Plan with name already exists");
"Name must be alphanumeric with dashes or underscores as separators", }
}, },
]} message: "Plan with name already exists",
> },
<Input {
placeholder={"plan" + ((config?.plans?.length || 0) + 1)} pattern: namePattern,
disabled={!!template} message:
/> "Name must be alphanumeric with dashes or underscores as separators",
</Form.Item> },
]}
>
<Input
placeholder={"plan" + ((config?.plans?.length || 0) + 1)}
disabled={!!template}
/>
</Form.Item>
</Tooltip>
{/* Plan.repo */} {/* Plan.repo */}
<Form.Item<Plan> <Tooltip title="The repo that backrest will store your snapshots in.">
name="repo" <Form.Item<Plan>
label="Repository" name="repo"
validateTrigger={["onChange", "onBlur"]} label="Repository"
initialValue={template ? template.repo : ""} validateTrigger={["onChange", "onBlur"]}
rules={[ initialValue={template ? template.repo : ""}
{ rules={[
required: true, {
message: "Please select repository", required: true,
}, message: "Please select repository",
]} },
> ]}
<Select >
// defaultValue={repos.length > 0 ? repos[0].id : undefined} <Select
options={repos.map((repo) => ({ // defaultValue={repos.length > 0 ? repos[0].id : undefined}
value: repo.id, options={repos.map((repo) => ({
}))} value: repo.id,
disabled={!!template} }))}
/> disabled={!!template}
</Form.Item> />
</Form.Item>
</Tooltip>
{/* Plan.paths */} {/* Plan.paths */}
<Form.Item label="Paths" required={true}> <Form.Item label="Paths" required={true}>
@@ -258,106 +262,136 @@ export const AddPlanModal = ({ template }: { template: Plan | null }) => {
</Form.Item> </Form.Item>
{/* Plan.excludes */} {/* Plan.excludes */}
<Form.Item label="Excludes" required={false}> <Tooltip
<Form.List title={
name="excludes" <>
rules={[]} Paths to exclude from your backups. See the{" "}
initialValue={template ? template.excludes : []} <a
> href="https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files"
{(fields, { add, remove }, { errors }) => ( target="_blank"
<> >
{fields.map((field, index) => ( restic docs
<Form.Item required={false} key={field.key}> </a>{" "}
<Form.Item for more info.
{...field} </>
validateTrigger={["onChange", "onBlur"]} }
initialValue={""} >
rules={[ <Form.Item label="Excludes" required={false}>
{ <Form.List
required: true, name="excludes"
}, rules={[]}
]} initialValue={template ? template.excludes : []}
noStyle >
> {(fields, { add, remove }, { errors }) => (
<URIAutocomplete <>
style={{ width: "90%" }} {fields.map((field, index) => (
onBlur={() => form.validateFields()} <Form.Item required={false} key={field.key}>
globAllowed={true} <Form.Item
{...field}
validateTrigger={["onChange", "onBlur"]}
initialValue={""}
rules={[
{
required: true,
},
]}
noStyle
>
<URIAutocomplete
style={{ width: "90%" }}
onBlur={() => form.validateFields()}
globAllowed={true}
/>
</Form.Item>
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
style={{ paddingLeft: "5px" }}
/> />
</Form.Item> </Form.Item>
<MinusCircleOutlined ))}
className="dynamic-delete-button" <Form.Item>
onClick={() => remove(field.name)} <Button
style={{ paddingLeft: "5px" }} type="dashed"
/> onClick={() => add()}
style={{ width: "90%" }}
icon={<PlusOutlined />}
>
Add Exclusion Glob
</Button>
<Form.ErrorList errors={errors} />
</Form.Item> </Form.Item>
))} </>
<Form.Item> )}
<Button </Form.List>
type="dashed" </Form.Item>
onClick={() => add()} </Tooltip>
style={{ width: "90%" }}
icon={<PlusOutlined />}
>
Add Exclusion Glob
</Button>
<Form.ErrorList errors={errors} />
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
{/* Plan.excludes */} {/* Plan.iexcludes */}
<Form.Item label="Excludes (Case Insensitive)" required={false}> <Tooltip
<Form.List title={
name="iexcludes" <>
rules={[]} Case insensitive paths to exclude from your backups. See the{" "}
initialValue={template ? template.iexcludes : []} <a
> href="https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files"
{(fields, { add, remove }, { errors }) => ( target="_blank"
<> >
{fields.map((field, index) => ( restic docs
<Form.Item required={false} key={field.key}> </a>{" "}
<Form.Item for more info.
{...field} </>
validateTrigger={["onChange", "onBlur"]} }
initialValue={""} >
rules={[ <Form.Item label="Excludes (Case Insensitive)" required={false}>
{ <Form.List
required: true, name="iexcludes"
}, rules={[]}
]} initialValue={template ? template.iexcludes : []}
noStyle >
> {(fields, { add, remove }, { errors }) => (
<URIAutocomplete <>
style={{ width: "90%" }} {fields.map((field, index) => (
onBlur={() => form.validateFields()} <Form.Item required={false} key={field.key}>
globAllowed={true} <Form.Item
{...field}
validateTrigger={["onChange", "onBlur"]}
initialValue={""}
rules={[
{
required: true,
},
]}
noStyle
>
<URIAutocomplete
style={{ width: "90%" }}
onBlur={() => form.validateFields()}
globAllowed={true}
/>
</Form.Item>
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
style={{ paddingLeft: "5px" }}
/> />
</Form.Item> </Form.Item>
<MinusCircleOutlined ))}
className="dynamic-delete-button" <Form.Item>
onClick={() => remove(field.name)} <Button
style={{ paddingLeft: "5px" }} type="dashed"
/> onClick={() => add()}
style={{ width: "90%" }}
icon={<PlusOutlined />}
>
Add Case Insensitive Exclusion Glob
</Button>
<Form.ErrorList errors={errors} />
</Form.Item> </Form.Item>
))} </>
<Form.Item> )}
<Button </Form.List>
type="dashed" </Form.Item>
onClick={() => add()} </Tooltip>
style={{ width: "90%" }}
icon={<PlusOutlined />}
>
Add Case Insensitive Exclusion Glob
</Button>
<Form.ErrorList errors={errors} />
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
{/* Plan.cron */} {/* Plan.cron */}
<Tooltip title="Cron expression to schedule the plan in 24 hour time"> <Tooltip title="Cron expression to schedule the plan in 24 hour time">