force router refresh on save closes #198

This commit is contained in:
Milo Schwartz
2025-02-14 12:27:03 -05:00
parent f61d442989
commit 4c1366ef91
3 changed files with 15 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ import {
} from "@app/components/Settings"; } from "@app/components/Settings";
import { SwitchInput } from "@app/components/SwitchInput"; import { SwitchInput } from "@app/components/SwitchInput";
import { InfoPopup } from "@app/components/ui/info-popup"; import { InfoPopup } from "@app/components/ui/info-popup";
import { useRouter } from "next/navigation";
const UsersRolesFormSchema = z.object({ const UsersRolesFormSchema = z.object({
roles: z.array( roles: z.array(
@@ -82,6 +83,7 @@ export default function ResourceAuthenticationPage() {
const { env } = useEnvContext(); const { env } = useEnvContext();
const api = createApiClient({ env }); const api = createApiClient({ env });
const router = useRouter();
const [pageLoading, setPageLoading] = useState(true); const [pageLoading, setPageLoading] = useState(true);
@@ -236,6 +238,7 @@ export default function ResourceAuthenticationPage() {
title: "Saved successfully", title: "Saved successfully",
description: "Whitelist settings have been saved" description: "Whitelist settings have been saved"
}); });
router.refresh();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
toast({ toast({
@@ -283,6 +286,7 @@ export default function ResourceAuthenticationPage() {
title: "Saved successfully", title: "Saved successfully",
description: "Authentication settings have been saved" description: "Authentication settings have been saved"
}); });
router.refresh();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
toast({ toast({
@@ -314,6 +318,7 @@ export default function ResourceAuthenticationPage() {
updateAuthInfo({ updateAuthInfo({
password: false password: false
}); });
router.refresh();
}) })
.catch((e) => { .catch((e) => {
toast({ toast({
@@ -344,6 +349,7 @@ export default function ResourceAuthenticationPage() {
updateAuthInfo({ updateAuthInfo({
pincode: false pincode: false
}); });
router.refresh();
}) })
.catch((e) => { .catch((e) => {
toast({ toast({

View File

@@ -64,6 +64,7 @@ import {
import { SwitchInput } from "@app/components/SwitchInput"; import { SwitchInput } from "@app/components/SwitchInput";
import { useSiteContext } from "@app/hooks/useSiteContext"; import { useSiteContext } from "@app/hooks/useSiteContext";
import { InfoPopup } from "@app/components/ui/info-popup"; import { InfoPopup } from "@app/components/ui/info-popup";
import { useRouter } from "next/navigation";
// Regular expressions for validation // Regular expressions for validation
const DOMAIN_REGEX = const DOMAIN_REGEX =
@@ -125,6 +126,7 @@ export default function ReverseProxyTargets(props: {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [pageLoading, setPageLoading] = useState(true); const [pageLoading, setPageLoading] = useState(true);
const router = useRouter();
const addTargetForm = useForm({ const addTargetForm = useForm({
resolver: zodResolver(addTargetSchema), resolver: zodResolver(addTargetSchema),
@@ -299,6 +301,7 @@ export default function ReverseProxyTargets(props: {
}); });
setTargetsToRemove([]); setTargetsToRemove([]);
router.refresh();
} catch (err) { } catch (err) {
console.error(err); console.error(err);
toast({ toast({
@@ -339,6 +342,7 @@ export default function ReverseProxyTargets(props: {
title: "SSL Configuration", title: "SSL Configuration",
description: "SSL configuration updated successfully" description: "SSL configuration updated successfully"
}); });
router.refresh();
} }
} }

View File

@@ -71,6 +71,7 @@ import {
isValidUrlGlobPattern isValidUrlGlobPattern
} from "@server/lib/validators"; } from "@server/lib/validators";
import { Switch } from "@app/components/ui/switch"; import { Switch } from "@app/components/ui/switch";
import { useRouter } from "next/navigation";
// Schema for rule validation // Schema for rule validation
const addRuleSchema = z.object({ const addRuleSchema = z.object({
@@ -107,6 +108,7 @@ export default function ResourceRules(props: {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [pageLoading, setPageLoading] = useState(true); const [pageLoading, setPageLoading] = useState(true);
const [rulesEnabled, setRulesEnabled] = useState(resource.applyRules); const [rulesEnabled, setRulesEnabled] = useState(resource.applyRules);
const router = useRouter();
const addRuleForm = useForm({ const addRuleForm = useForm({
resolver: zodResolver(addRuleSchema), resolver: zodResolver(addRuleSchema),
@@ -253,6 +255,7 @@ export default function ResourceRules(props: {
title: "Enable Rules", title: "Enable Rules",
description: "Rule evaluation has been updated" description: "Rule evaluation has been updated"
}); });
router.refresh();
} }
} }
@@ -370,6 +373,7 @@ export default function ResourceRules(props: {
}); });
setRulesToRemove([]); setRulesToRemove([]);
router.refresh();
} catch (err) { } catch (err) {
console.error(err); console.error(err);
toast({ toast({
@@ -590,7 +594,7 @@ export default function ResourceRules(props: {
<SwitchInput <SwitchInput
id="rules-toggle" id="rules-toggle"
label="Enable Rules" label="Enable Rules"
defaultChecked={resource.applyRules} defaultChecked={rulesEnabled}
onCheckedChange={async (val) => { onCheckedChange={async (val) => {
await saveApplyRules(val); await saveApplyRules(val);
}} }}