Skip to content

Commit e0ae7d0

Browse files
add search domains enabled to namespace (#288)
--------- Co-authored-by: braginini <[email protected]>
1 parent ddd812e commit e0ae7d0

File tree

5 files changed

+328
-286
lines changed

5 files changed

+328
-286
lines changed

src/components/NameServerGroupAdd.tsx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const NameServerGroupAdd = () => {
7373
const inputNameRef = useRef<any>(null);
7474
const inputDescriptionRef = useRef<any>(null);
7575
const [selectCustom, setSelectCustom] = useState(false);
76+
const [matchDomains, setMatchDomains] = useState(0);
7677

7778
useEffect(() => {
7879
if (editName)
@@ -87,7 +88,6 @@ const NameServerGroupAdd = () => {
8788
cursor: "end",
8889
});
8990
}, [editDescription]);
90-
9191
useEffect(() => {
9292
if (!nsGroup) return;
9393

@@ -117,6 +117,7 @@ const NameServerGroupAdd = () => {
117117
nameservers: [] as NameServer[],
118118
groups: [],
119119
enabled: false,
120+
search_domains_enabled: false,
120121
} as NameServerGroup)
121122
);
122123
setEditName(false);
@@ -156,6 +157,7 @@ const NameServerGroupAdd = () => {
156157
],
157158
groups: [],
158159
enabled: true,
160+
search_domains_enabled: false,
159161
},
160162
{
161163
name: cloudflareChoice,
@@ -176,6 +178,7 @@ const NameServerGroupAdd = () => {
176178
],
177179
groups: [],
178180
enabled: true,
181+
search_domains_enabled: false,
179182
},
180183
{
181184
name: quad9Choice,
@@ -196,6 +199,7 @@ const NameServerGroupAdd = () => {
196199
],
197200
groups: [],
198201
enabled: true,
202+
search_domains_enabled: false,
199203
},
200204
];
201205

@@ -262,6 +266,8 @@ const NameServerGroupAdd = () => {
262266
groups: existingGroups,
263267
groupsToCreate: newGroups,
264268
enabled: values.enabled,
269+
search_domains_enabled:
270+
matchDomains > 0 ? formNSGroup.search_domains_enabled : false,
265271
} as NameServerGroupToSave;
266272
};
267273

@@ -462,6 +468,7 @@ const NameServerGroupAdd = () => {
462468
</Col>
463469
</Space>
464470
</Row>
471+
{setMatchDomains(fields.length)}
465472
{fields.map((field, index) => {
466473
return (
467474
<Row key={index} style={{ marginBottom: "5px" }}>
@@ -522,6 +529,13 @@ const NameServerGroupAdd = () => {
522529
});
523530
};
524531

532+
const handleChangeMarkDomain = (checked: boolean) => {
533+
setFormNSGroup({
534+
...formNSGroup,
535+
search_domains_enabled: checked,
536+
});
537+
};
538+
525539
return (
526540
<>
527541
{nsGroup && (
@@ -701,6 +715,46 @@ const NameServerGroupAdd = () => {
701715
<Col span={24}>
702716
<Form.List name="domains">{renderDomains}</Form.List>
703717
</Col>
718+
719+
{matchDomains > 0 && (
720+
<Col span={24}>
721+
<Form.Item name="search_domains_enabled" label="">
722+
<div
723+
style={{
724+
display: "flex",
725+
gap: "15px",
726+
}}
727+
>
728+
<Switch
729+
onChange={handleChangeMarkDomain}
730+
size="small"
731+
/>
732+
<div>
733+
<label
734+
style={{
735+
color: "rgba(0, 0, 0, 0.88)",
736+
fontSize: "14px",
737+
fontWeight: "500",
738+
}}
739+
>
740+
Mark match domains as search domains
741+
</label>
742+
<Paragraph
743+
type={"secondary"}
744+
style={{
745+
marginTop: "-2",
746+
fontWeight: "400",
747+
marginBottom: "0",
748+
}}
749+
>
750+
E.g., "peer.example.com" will be accessible with
751+
"peer"
752+
</Paragraph>
753+
</div>
754+
</div>
755+
</Form.Item>
756+
</Col>
757+
)}
704758
<Col span={24}>
705759
<label
706760
style={{

0 commit comments

Comments
 (0)