Skip to content

Commit

Permalink
feat(web): add 403 page
Browse files Browse the repository at this point in the history
  • Loading branch information
LeezQ committed Feb 14, 2023
1 parent 2de068b commit ddbc358
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 11 deletions.
3 changes: 2 additions & 1 deletion web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@
"EditTip": "modified, unpublished",
"NoInfo": "No information",
"RefreshDataSuccess": "data refreshed",
"Language": "Language"
"Language": "Language",
"update success": "update completed"
}
5 changes: 3 additions & 2 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@
"RefreshData": "刷新数据",
"NoInfo": "暂无信息",
"RefreshDataSuccess": "数据刷新成功",
"Language": "语言"
}
"Language": "语言",
"update success": "更新成功"
}
5 changes: 3 additions & 2 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@
"EditTip": "已修改,未发布",
"NoInfo": "暂无信息",
"RefreshDataSuccess": "数据刷新成功",
"Language": "语言"
}
"Language": "语言",
"update success": "更新成功"
}
25 changes: 25 additions & 0 deletions web/src/pages/403.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import { Button, Center, HStack } from "@chakra-ui/react";

export default function Index() {
const navigate = useNavigate();
return (
<div className=" bg-white h-screen">
<Center h="80vh" w="100vw" className="flex-col !items-start pl-80">
<h1 style={{ fontSize: 38 }}>403</h1>
<p className="font-semibold mb-8" style={{ fontSize: 60 }}>
You don't have permission to access this page
</p>
<HStack spacing={6}>
<Button size={"lg"} variant="outline">
Go back
</Button>
<Button size={"lg"} onClick={() => navigate("/", { replace: true })}>
Take me home
</Button>
</HStack>
</Center>
</div>
);
}
22 changes: 21 additions & 1 deletion web/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import { Button, Center, HStack } from "@chakra-ui/react";

export default function Index() {
return <div>404</div>;
const navigate = useNavigate();
return (
<div className=" bg-white h-screen">
<Center h="80vh" w="100vw" className="flex-col !items-start pl-80">
<h1 style={{ fontSize: 38 }}>404</h1>
<p className="font-semibold mb-8" style={{ fontSize: 60 }}>
We can't find that page
</p>
<HStack spacing={6}>
<Button size={"lg"} variant="outline">
Go back
</Button>
<Button size={"lg"} onClick={() => navigate("/", { replace: true })}>
Take me home
</Button>
</HStack>
</Center>
</div>
);
}
2 changes: 1 addition & 1 deletion web/src/pages/app/functions/mods/DebugPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default function DebugPanel() {
>
<TabList className="mb-2 flex-none">
<Tab>
Parameters
Params
{queryParams.length > 0 && (
<span className="ml-1">({queryParams.length})</span>
)}
Expand Down
4 changes: 3 additions & 1 deletion web/src/pages/home/mods/CreateAppModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ const CreateAppModal = (props: { application?: any; children: React.ReactElement

if (!res.error) {
onClose();
showSuccess(isEdit ? "update success." : "create success.");
if (isEdit) {
showSuccess(t("update success"));
}
queryClient.invalidateQueries(["appListQuery"]);
} else {
showError(res.error);
Expand Down
5 changes: 2 additions & 3 deletions web/src/pages/home/mods/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import useGlobalStore from "@/pages/globalStore";
function List(props: { appListQuery: any }) {
const navigate = useNavigate();

const { showSuccess, setCurrentApp } = useGlobalStore();
const { setCurrentApp } = useGlobalStore();

const [searchKey, setSearchKey] = useState("");

Expand All @@ -42,7 +42,6 @@ function List(props: { appListQuery: any }) {
const deleteAppMutation = useMutation((params: any) => ApplicationControllerRemove(params), {
onSuccess: () => {
appListQuery.refetch();
showSuccess("delete success.");
},
onError: () => {},
});
Expand Down Expand Up @@ -123,7 +122,7 @@ function List(props: { appListQuery: any }) {
{t("HomePanel.Develop")}
</Button>
<Menu>
<MenuButton disabled={item?.phase !== APP_PHASE_STATUS.Started}>
<MenuButton>
<IconWrap>
<BsThreeDotsVertical size={16} />
</IconWrap>
Expand Down
4 changes: 4 additions & 0 deletions web/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const routes = [
},
],
},
{
path: "/403",
element: () => import("@/pages/403"),
},
route404,
],
},
Expand Down
2 changes: 2 additions & 0 deletions web/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ request.interceptors.response.use(
// eslint-disable-next-line no-restricted-globals
(window as any).location.href = (import.meta.env.VITE_SERVER_URL + "/v1/login") as string;
return;
} else if (data.statusCode === 403) {
(window as any).location.href = "/403";
}
toast({
title: data.message,
Expand Down

0 comments on commit ddbc358

Please sign in to comment.