Skip to content

Commit

Permalink
add search domains enabled to namespace (#288)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: braginini <bangvalo@gmail.com>
  • Loading branch information
saroojbkhari and braginini authored Oct 20, 2023
1 parent ddd812e commit e0ae7d0
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 286 deletions.
56 changes: 55 additions & 1 deletion src/components/NameServerGroupAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const NameServerGroupAdd = () => {
const inputNameRef = useRef<any>(null);
const inputDescriptionRef = useRef<any>(null);
const [selectCustom, setSelectCustom] = useState(false);
const [matchDomains, setMatchDomains] = useState(0);

useEffect(() => {
if (editName)
Expand All @@ -87,7 +88,6 @@ const NameServerGroupAdd = () => {
cursor: "end",
});
}, [editDescription]);

useEffect(() => {
if (!nsGroup) return;

Expand Down Expand Up @@ -117,6 +117,7 @@ const NameServerGroupAdd = () => {
nameservers: [] as NameServer[],
groups: [],
enabled: false,
search_domains_enabled: false,
} as NameServerGroup)
);
setEditName(false);
Expand Down Expand Up @@ -156,6 +157,7 @@ const NameServerGroupAdd = () => {
],
groups: [],
enabled: true,
search_domains_enabled: false,
},
{
name: cloudflareChoice,
Expand All @@ -176,6 +178,7 @@ const NameServerGroupAdd = () => {
],
groups: [],
enabled: true,
search_domains_enabled: false,
},
{
name: quad9Choice,
Expand All @@ -196,6 +199,7 @@ const NameServerGroupAdd = () => {
],
groups: [],
enabled: true,
search_domains_enabled: false,
},
];

Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -462,6 +468,7 @@ const NameServerGroupAdd = () => {
</Col>
</Space>
</Row>
{setMatchDomains(fields.length)}
{fields.map((field, index) => {
return (
<Row key={index} style={{ marginBottom: "5px" }}>
Expand Down Expand Up @@ -522,6 +529,13 @@ const NameServerGroupAdd = () => {
});
};

const handleChangeMarkDomain = (checked: boolean) => {
setFormNSGroup({
...formNSGroup,
search_domains_enabled: checked,
});
};

return (
<>
{nsGroup && (
Expand Down Expand Up @@ -701,6 +715,46 @@ const NameServerGroupAdd = () => {
<Col span={24}>
<Form.List name="domains">{renderDomains}</Form.List>
</Col>

{matchDomains > 0 && (
<Col span={24}>
<Form.Item name="search_domains_enabled" label="">
<div
style={{
display: "flex",
gap: "15px",
}}
>
<Switch
onChange={handleChangeMarkDomain}
size="small"
/>
<div>
<label
style={{
color: "rgba(0, 0, 0, 0.88)",
fontSize: "14px",
fontWeight: "500",
}}
>
Mark match domains as search domains
</label>
<Paragraph
type={"secondary"}
style={{
marginTop: "-2",
fontWeight: "400",
marginBottom: "0",
}}
>
E.g., "peer.example.com" will be accessible with
"peer"
</Paragraph>
</div>
</div>
</Form.Item>
</Col>
)}
<Col span={24}>
<label
style={{
Expand Down
Loading

0 comments on commit e0ae7d0

Please sign in to comment.