diff --git a/src/components/adminPage/controller/zerotierUrl.tsx b/src/components/adminPage/controller/zerotierUrl.tsx
new file mode 100644
index 00000000..03adba3b
--- /dev/null
+++ b/src/components/adminPage/controller/zerotierUrl.tsx
@@ -0,0 +1,120 @@
+import React from "react";
+import {
+ useTrpcApiErrorHandler,
+ useTrpcApiSuccessHandler,
+} from "~/hooks/useTrpcApiHandler";
+import { api } from "~/utils/api";
+import PrivateRoot from "./privateRoot";
+import { useTranslations } from "next-intl";
+import InputField from "~/components/elements/inputField";
+
+const ZerotierUrl = () => {
+ const t = useTranslations("admin");
+
+ const handleApiError = useTrpcApiErrorHandler();
+ const handleApiSuccess = useTrpcApiSuccessHandler();
+
+ const { refetch: refetchStats } = api.admin.getControllerStats.useQuery();
+ const { data: me, refetch: refetchMe, isLoading: meLoading } = api.auth.me.useQuery();
+
+ const { mutate: setZtOptions } = api.auth.setLocalZt.useMutation({
+ onSuccess: handleApiSuccess({
+ actions: [refetchMe, refetchStats],
+ }),
+ onError: handleApiError,
+ });
+ return (
+
+
{t("controller.controllerConfig.danger_zone")}
+
+
+
+
+ {t.rich("controller.controllerConfig.proceed_with_caution", {
+ span: (content) => {content} ,
+ })}
+ {t("controller.controllerConfig.modification_warning")}
+ {me?.options.urlFromEnv || me?.options.secretFromEnv ? (
+
+
+
+ {t.rich("controller.controllerConfig.isUsingEnvVariablesAlert", {
+ span: (content) => {content} ,
+ })}
+
+
+ ) : (
+ "nope"
+ )}
+
+
+
+ new Promise((resolve) => {
+ setZtOptions({
+ localControllerSecret: me?.options?.localControllerSecret,
+ ...params,
+ });
+ resolve(true);
+ })
+ }
+ />
+
+ new Promise((resolve) => {
+ setZtOptions({
+ localControllerUrl: me?.options?.localControllerUrl,
+ ...params,
+ });
+ resolve(true);
+ })
+ }
+ />
+
+
+
+
+ );
+};
+
+export default ZerotierUrl;
diff --git a/src/pages/admin/controller/index.tsx b/src/pages/admin/controller/index.tsx
index bb7a1fab..d8319ecc 100644
--- a/src/pages/admin/controller/index.tsx
+++ b/src/pages/admin/controller/index.tsx
@@ -1,40 +1,18 @@
import { useTranslations } from "next-intl";
-import { useState, type ReactElement } from "react";
-import EditableField from "~/components/elements/inputField";
import { LayoutAdminAuthenticated } from "~/components/layouts/layout";
-import PrivateRoot from "~/components/adminPage/controller/privateRoot";
import { api } from "~/utils/api";
import DebugMirror from "~/components/adminPage/controller/debugController";
import { UnlinkedNetwork } from "~/components/adminPage/controller/unlinkedNetworkTable";
-import {
- useTrpcApiErrorHandler,
- useTrpcApiSuccessHandler,
-} from "~/hooks/useTrpcApiHandler";
+import ZerotierUrl from "~/components/adminPage/controller/zerotierUrl";
+import { ReactElement } from "react";
const Controller = () => {
- const [error, setError] = useState(false);
+ // const [error, setError] = useState(false);
const t = useTranslations("admin");
- const handleApiError = useTrpcApiErrorHandler();
- const handleApiSuccess = useTrpcApiSuccessHandler();
-
- const { data: controllerData, refetch: refetchStats } =
- api.admin.getControllerStats.useQuery(null, {
- retry: 1,
- onError: () => {
- setError(true);
- },
- onSuccess: () => {
- setError(false);
- },
- });
- const { data: unlinkedNetworks, refetch: refetchUnlinkedNetworks } =
- api.admin.unlinkedNetwork.useQuery();
- const { data: me, refetch: refetchMe, isLoading: meLoading } = api.auth.me.useQuery();
- const { mutate: setZtOptions } = api.auth.setLocalZt.useMutation({
- onSuccess: handleApiSuccess({ actions: [refetchMe, refetchStats] }),
- onError: handleApiError,
- });
+ const { data: controllerData, error: controllerError } =
+ api.admin.getControllerStats.useQuery();
+ const { data: unlinkedNetworks } = api.admin.unlinkedNetwork.useQuery();
const { networkCount, totalMembers, controllerStatus } = controllerData || {};
@@ -43,11 +21,9 @@ const Controller = () => {
const { online, tcpFallbackActive, version } = controllerStatus || {};
- if (meLoading) return null;
-
return (
- {error ? (
+ {controllerError ? (
>
)}
-
-
- {t("controller.controllerConfig.danger_zone")}
-
-
-
-
-
- {t.rich("controller.controllerConfig.proceed_with_caution", {
- span: (content) => {content} ,
- })}
- {t("controller.controllerConfig.modification_warning")}
- {me?.options.urlFromEnv || me?.options.secretFromEnv ? (
-
-
-
- {t.rich("controller.controllerConfig.isUsingEnvVariablesAlert", {
- span: (content) => {content} ,
- })}
-
-
- ) : (
- "nope"
- )}
-
-
-
- new Promise((resolve) => {
- setZtOptions(params);
- refetchUnlinkedNetworks();
- resolve(true);
- })
- }
- />
-
- new Promise((resolve) => {
- setZtOptions(params);
- refetchUnlinkedNetworks();
- resolve(true);
- })
- }
- />
-
-
-
-
+
);
};