This is an automated email from the ASF dual-hosted git repository. hsluoyz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git
commit cb44f191b53cb10790528ac9bfb9bc613175c57a Author: Yang Luo <[email protected]> AuthorDate: Fri Sep 4 23:46:03 2026 +0800 fix(web): leave the page once a save succeeds --- web/src/pages/AccountPage.tsx | 3 ++- web/src/pages/ProviderEditPage.tsx | 1 + web/src/pages/SettingPage.tsx | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web/src/pages/AccountPage.tsx b/web/src/pages/AccountPage.tsx index 2d89274..97a32d6 100644 --- a/web/src/pages/AccountPage.tsx +++ b/web/src/pages/AccountPage.tsx @@ -39,7 +39,8 @@ export default function AccountPage({account}: {account: Account}) { .then(res => { if (res.status === "ok") { Setting.showMessage("success", i18next.t("general:Successfully saved")); - window.location.reload(); + // A full load, so the nav picks up the new name and avatar. + Setting.goToLink("/"); } else { Setting.showMessage("error", res.msg); } diff --git a/web/src/pages/ProviderEditPage.tsx b/web/src/pages/ProviderEditPage.tsx index 3bb8e4e..e175e43 100644 --- a/web/src/pages/ProviderEditPage.tsx +++ b/web/src/pages/ProviderEditPage.tsx @@ -143,6 +143,7 @@ export default function ProviderEditPage() { return; } Setting.showMessage("success", i18next.t("provider:Provider saved")); + navigate("/providers"); }) .catch(error => { Setting.showMessage("error", `${i18next.t("provider:Failed to save")}: ${error}`); diff --git a/web/src/pages/SettingPage.tsx b/web/src/pages/SettingPage.tsx index 800ade9..db00c54 100644 --- a/web/src/pages/SettingPage.tsx +++ b/web/src/pages/SettingPage.tsx @@ -13,7 +13,7 @@ // limitations under the License. import * as React from "react"; -import {useLocation} from "react-router-dom"; +import {useLocation, useNavigate} from "react-router-dom"; import i18next from "i18next"; import * as SettingBackend from "@/backend/SettingBackend"; @@ -66,6 +66,7 @@ export default function SettingPage({account}: {account: Account}) { // The rail links to a section by hash, and the browser cannot honour that on // its own while the page is still the loading placeholder. const {hash} = useLocation(); + const navigate = useNavigate(); const loaded = setting !== null; React.useEffect(() => { if (!loaded || !hash) { @@ -94,8 +95,8 @@ export default function SettingPage({account}: {account: Account}) { .then(res => { setSaving(false); if (res.status === "ok") { - setSetting(res.data); Setting.showMessage("success", i18next.t("general:Successfully saved")); + navigate("/"); } else { Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
