diff --git a/public/locales/en-US/application.json b/public/locales/en-US/application.json index 36e867d..5b56f85 100644 --- a/public/locales/en-US/application.json +++ b/public/locales/en-US/application.json @@ -262,6 +262,7 @@ "restore": "Restore", "unpin": "Unpin", "youDontHaveReadPermissionToThisFile": "You don't have access permission.", + "anonymousAccessDenied": "You don't have access permission, please try to sign in.", "sharedWithOthers": "Shared with others", "new": "New", "open": "Open", diff --git a/public/locales/ja-JP/application.json b/public/locales/ja-JP/application.json index bc51f31..34b6c85 100644 --- a/public/locales/ja-JP/application.json +++ b/public/locales/ja-JP/application.json @@ -263,6 +263,7 @@ "restore": "復元", "unpin": "固定解除", "youDontHaveReadPermissionToThisFile": "アクセス権限がありません", + "anonymousAccessDenied": "アクセス権限がありません。ログインしてください。", "sharedWithOthers": "他の人と共有", "new": "新規作成", "open": "開く", diff --git a/public/locales/zh-CN/application.json b/public/locales/zh-CN/application.json index 7d640b8..04fb309 100644 --- a/public/locales/zh-CN/application.json +++ b/public/locales/zh-CN/application.json @@ -263,6 +263,7 @@ "restore": "还原", "unpin": "取消固定", "youDontHaveReadPermissionToThisFile": "你没有权限读取此内容", + "anonymousAccessDenied": "你没有权限读取此内容,请尝试登录账号。", "sharedWithOthers": "与他人分享", "new": "新建", "open": "打开", diff --git a/public/locales/zh-TW/application.json b/public/locales/zh-TW/application.json index dae7fe9..7cf87ad 100644 --- a/public/locales/zh-TW/application.json +++ b/public/locales/zh-TW/application.json @@ -263,6 +263,7 @@ "restore": "還原", "unpin": "取消固定", "youDontHaveReadPermissionToThisFile": "你沒有許可權讀取此內容", + "anonymousAccessDenied": "你沒有許可權讀取此內容,請嘗試登入帳號。", "sharedWithOthers": "與他人分享", "new": "新建", "open": "開啟", diff --git a/src/api/request.ts b/src/api/request.ts index 5733c1e..ff3df73 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -139,6 +139,7 @@ export const Code = { StaleVersion: 40076, BatchOperationNotFullyCompleted: 40081, DomainNotLicensed: 40087, + AnonymouseAccessDenied: 40088, CodeLoginRequired: 401, PermissionDenied: 403, NodeFound: 404, diff --git a/src/component/FileManager/Explorer/ExplorerError.tsx b/src/component/FileManager/Explorer/ExplorerError.tsx index a9044b5..39c0f23 100644 --- a/src/component/FileManager/Explorer/ExplorerError.tsx +++ b/src/component/FileManager/Explorer/ExplorerError.tsx @@ -1,11 +1,12 @@ import { Alert, AlertTitle, Box, Button, Typography } from "@mui/material"; import React, { memo, useCallback, useContext, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; +import { useNavigate } from "react-router-dom"; import { AppError, Code, Response } from "../../../api/request.ts"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks.ts"; import { navigateToPath, retrySharePassword } from "../../../redux/thunks/filemanager.ts"; import { Filesystem } from "../../../util/uri.ts"; -import { FilledTextField } from "../../Common/StyledComponents.tsx"; +import { FilledTextField, SecondaryButton } from "../../Common/StyledComponents.tsx"; import ArrowLeft from "../../Icons/ArrowLeft.tsx"; import LinkDismiss from "../../Icons/LinkDismiss.tsx"; import LockClosed from "../../Icons/LockClosed.tsx"; @@ -53,6 +54,7 @@ const RetryPassword = () => { const ExplorerError = memo( React.forwardRef(({ error, ...rest }: ExplorerErrorProps, ref) => { const dispatch = useAppDispatch(); + const navigate = useNavigate(); const fmIndex = useContext(FmIndexContext); const fs = useAppSelector((state) => state.fileManager[fmIndex].current_fs); const previousPath = useAppSelector((state) => state.fileManager[fmIndex].previous_path); @@ -68,8 +70,22 @@ const ExplorerError = memo( previousPath && dispatch(navigateToPath(fmIndex, previousPath)); }, [dispatch, fmIndex, previousPath]); + const signIn = useCallback(() => { + navigate("/session?redirect=" + encodeURIComponent(window.location.pathname + window.location.search)); + }, [navigate]); + const innerError = () => { switch (error?.code) { + case Code.AnonymouseAccessDenied: + return ( + + + {t("application:fileManager.anonymousAccessDenied")} + + {t("application:login.signIn")} + + + ); case Code.IncorrectPassword: return ; // @ts-ignore