feat(explorer): friendly reminder for anonymous session without share link access permission

This commit is contained in:
Aaron Liu 2025-08-21 14:11:57 +08:00
parent a710dbb2f4
commit ad1a02152c
6 changed files with 22 additions and 1 deletions

View File

@ -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",

View File

@ -263,6 +263,7 @@
"restore": "復元",
"unpin": "固定解除",
"youDontHaveReadPermissionToThisFile": "アクセス権限がありません",
"anonymousAccessDenied": "アクセス権限がありません。ログインしてください。",
"sharedWithOthers": "他の人と共有",
"new": "新規作成",
"open": "開く",

View File

@ -263,6 +263,7 @@
"restore": "还原",
"unpin": "取消固定",
"youDontHaveReadPermissionToThisFile": "你没有权限读取此内容",
"anonymousAccessDenied": "你没有权限读取此内容,请尝试登录账号。",
"sharedWithOthers": "与他人分享",
"new": "新建",
"open": "打开",

View File

@ -263,6 +263,7 @@
"restore": "還原",
"unpin": "取消固定",
"youDontHaveReadPermissionToThisFile": "你沒有許可權讀取此內容",
"anonymousAccessDenied": "你沒有許可權讀取此內容,請嘗試登入帳號。",
"sharedWithOthers": "與他人分享",
"new": "新建",
"open": "開啟",

View File

@ -139,6 +139,7 @@ export const Code = {
StaleVersion: 40076,
BatchOperationNotFullyCompleted: 40081,
DomainNotLicensed: 40087,
AnonymouseAccessDenied: 40088,
CodeLoginRequired: 401,
PermissionDenied: 403,
NodeFound: 404,

View File

@ -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 (
<Box sx={{ textAlign: "center" }}>
<LockClosed sx={{ fontSize: 60 }} color={"action"} />
<Typography color={"text.secondary"}>{t("application:fileManager.anonymousAccessDenied")}</Typography>
<SecondaryButton variant={"contained"} color={"inherit"} onClick={signIn} sx={{ mt: 4 }}>
{t("application:login.signIn")}
</SecondaryButton>
</Box>
);
case Code.IncorrectPassword:
return <RetryPassword />;
// @ts-ignore