Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make it possible to disable/enable config file #867

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions src/pages/networks/NetworkDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
InfoCircleOutlined,
LoadingOutlined,
MoreOutlined,
PlayCircleOutlined,
PlusOutlined,
QuestionCircleOutlined,
ReloadOutlined,
Expand Down Expand Up @@ -2482,6 +2483,36 @@ export default function NetworkDetailsPage(props: PageProps) {
setIsUpdateClientModalOpen(true);
},
},
{
key: 'toggle',
icon: node.static_node?.enabled ? <StopOutlined /> : <PlayCircleOutlined />,
label: node.static_node?.enabled ? 'Disable' : 'Enable',
disabled: !isAdminUserOrRole(store.user!) && store.username !== node.static_node?.ownerid,
onClick: () => {
const clientData: ExternalClient = {
clientid: node.static_node?.clientid ?? '',
description: '',
privatekey: node.static_node?.privatekey ?? '',
publickey: node.static_node?.publickey ?? '',
network: networkId ?? '',
address: node.static_node?.address ?? '',
address6: node.static_node?.address6 ?? '',
ingressgatewayid: node.static_node?.ingressgatewayid ?? '',
ingressgatewayendpoint: node.static_node?.ingressgatewayendpoint ?? '',
lastmodified: node.lastmodified ?? 0,
enabled: node.static_node?.enabled ?? false,
ownerid: node.static_node?.ownerid ?? '',
internal_ip_addr: '',
internal_ip_addr6: '',
dns: node.static_node?.dns ?? '',
extraallowedips: node.static_node?.extraallowedips ?? [],
postup: node.static_node?.postup,
postdown: node.static_node?.postdown,
tags: node.static_node.tags,
};
toggleClientStatus(clientData, !node.static_node?.enabled);
},
},
{
key: 'view',
label: (
Expand Down Expand Up @@ -2530,7 +2561,7 @@ export default function NetworkDetailsPage(props: PageProps) {
onClick: () => {
const clientData: ExternalClient = {
clientid: node.static_node?.clientid ?? '',
description: '', // Empty string as it's required but not in static node
description: '',
privatekey: node.static_node?.privatekey ?? '',
publickey: node.static_node?.publickey ?? '',
network: networkId ?? '',
Expand All @@ -2541,8 +2572,8 @@ export default function NetworkDetailsPage(props: PageProps) {
lastmodified: node.lastmodified ?? 0,
enabled: node.static_node?.enabled ?? false,
ownerid: node.static_node?.ownerid ?? '',
internal_ip_addr: '', // Empty string as it's required but not in static node
internal_ip_addr6: '', // Empty string as it's required but not in static node
internal_ip_addr: '',
internal_ip_addr6: '',
dns: node.static_node?.dns ?? '',
extraallowedips: node.static_node?.extraallowedips ?? [],
postup: node.static_node?.postup,
Expand Down
Loading