diff --git a/src/components/NameServerGroupAdd.tsx b/src/components/NameServerGroupAdd.tsx index 090d6c7a..e8260667 100644 --- a/src/components/NameServerGroupAdd.tsx +++ b/src/components/NameServerGroupAdd.tsx @@ -73,6 +73,7 @@ const NameServerGroupAdd = () => { const inputNameRef = useRef(null); const inputDescriptionRef = useRef(null); const [selectCustom, setSelectCustom] = useState(false); + const [matchDomains, setMatchDomains] = useState(0); useEffect(() => { if (editName) @@ -87,7 +88,6 @@ const NameServerGroupAdd = () => { cursor: "end", }); }, [editDescription]); - useEffect(() => { if (!nsGroup) return; @@ -117,6 +117,7 @@ const NameServerGroupAdd = () => { nameservers: [] as NameServer[], groups: [], enabled: false, + search_domains_enabled: false, } as NameServerGroup) ); setEditName(false); @@ -156,6 +157,7 @@ const NameServerGroupAdd = () => { ], groups: [], enabled: true, + search_domains_enabled: false, }, { name: cloudflareChoice, @@ -176,6 +178,7 @@ const NameServerGroupAdd = () => { ], groups: [], enabled: true, + search_domains_enabled: false, }, { name: quad9Choice, @@ -196,6 +199,7 @@ const NameServerGroupAdd = () => { ], groups: [], enabled: true, + search_domains_enabled: false, }, ]; @@ -262,6 +266,8 @@ const NameServerGroupAdd = () => { groups: existingGroups, groupsToCreate: newGroups, enabled: values.enabled, + search_domains_enabled: + matchDomains > 0 ? formNSGroup.search_domains_enabled : false, } as NameServerGroupToSave; }; @@ -462,6 +468,7 @@ const NameServerGroupAdd = () => { + {setMatchDomains(fields.length)} {fields.map((field, index) => { return ( @@ -522,6 +529,13 @@ const NameServerGroupAdd = () => { }); }; + const handleChangeMarkDomain = (checked: boolean) => { + setFormNSGroup({ + ...formNSGroup, + search_domains_enabled: checked, + }); + }; + return ( <> {nsGroup && ( @@ -701,6 +715,46 @@ const NameServerGroupAdd = () => { {renderDomains} + + {matchDomains > 0 && ( + + +
+ +
+ + + E.g., "peer.example.com" will be accessible with + "peer" + +
+
+
+ + )} - {!!fields.length && ( @@ -464,86 +399,90 @@ const NameServerGroupUpdate = (props: any) => { fields: FormListFieldData[], { add, remove }: any, { errors }: any - ) => ( -
- - - - - - Add domain if you want to have a specific one - - - - - {fields.map((field, index) => { - return ( - - - + {fields.map((field, index) => { + return ( + + + + + + + ); + })} + + + + + + + + + +
+ ); + }; const handleChangeDisabled = (checked: boolean) => { setFormNSGroup({ @@ -556,6 +495,13 @@ const NameServerGroupUpdate = (props: any) => { onCancel(); }; + const handleChangeMarkDomain = (checked: boolean) => { + setFormNSGroup({ + ...formNSGroup, + search_domains_enabled: checked, + }); + }; + return ( <> @@ -580,148 +526,186 @@ const NameServerGroupUpdate = (props: any) => { onValuesChange={onChange} > - - - -
- - - {!editName && formNSGroup.id ? ( -
toggleEditName(true)} - style={{ - fontSize: "22px", - margin: " 0px 0px 10px", - cursor: "pointer", - fontWeight: "500", - lineHeight: "24px", - }} - > - {formNSGroup.id - ? formNSGroup.name - : "New nameserver group"} -
- ) : ( - - -
- - - toggleEditName(false)} - onBlur={() => toggleEditName(false)} - autoComplete="off" - maxLength={40} - /> - -
- -
- )} - {!editDescription ? ( -
toggleEditDescription(true)} - > - {formNSGroup.description && - formNSGroup.description.trim() !== "" - ? formNSGroup.description - : "Add description"} -
- ) : ( - - -
+ +
+ + + {!editName && formNSGroup.id ? ( +
toggleEditName(true)} + style={{ + fontSize: "22px", + margin: " 0px 0px 10px", + cursor: "pointer", + fontWeight: "500", + lineHeight: "24px", + }} + > + {formNSGroup.id + ? formNSGroup.name + : "New nameserver group"} +
+ ) : ( + + +
+
- -
- )} - -
-
- + Name + + + toggleEditName(false)} + onBlur={() => toggleEditName(false)} + autoComplete="off" + maxLength={40} + /> + +
+ +
+ )} + {!editDescription ? ( +
toggleEditDescription(true)} + > + {formNSGroup.description && + formNSGroup.description.trim() !== "" + ? formNSGroup.description + : "Add description"} +
+ ) : ( + + +
+ + + + toggleEditDescription(false) + } + onBlur={() => toggleEditDescription(false)} + autoComplete="off" + /> + +
+ +
+ )} + +
+
+ - - - {renderNSList} - - + + + {renderNSList} + + - - {renderDomains} + + {renderDomains} + + + {matchDomains > 0 && ( + + +
+ +
+ + + E.g., "peer.example.com" will be accessible with + "peer" + +
+
+
-
- + )} + +