From 15c4933e7aac0305f8da98abc4fc79fd766781db Mon Sep 17 00:00:00 2001 From: devinxl Date: Tue, 11 Jul 2023 14:42:51 +0800 Subject: [PATCH] feat(dcellar-web-ui): add download no permission error --- apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx | 2 +- apps/dcellar-web-ui/src/facade/error.ts | 4 ++++ apps/dcellar-web-ui/src/facade/object.ts | 1 + apps/dcellar-web-ui/src/modules/object/ObjectError.tsx | 5 +++++ .../src/modules/object/components/ObjectList.tsx | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx b/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx index 0fa121b6..8834f3fc 100644 --- a/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx +++ b/apps/dcellar-web-ui/src/components/common/DCDrawer/index.tsx @@ -21,7 +21,7 @@ export const DCDrawer = (props: DCDrawerProps) => { return ( - + {children} diff --git a/apps/dcellar-web-ui/src/facade/error.ts b/apps/dcellar-web-ui/src/facade/error.ts index 424741c3..abed16a5 100644 --- a/apps/dcellar-web-ui/src/facade/error.ts +++ b/apps/dcellar-web-ui/src/facade/error.ts @@ -21,6 +21,7 @@ export const E_OBJECT_NAME_CONTAINS_SLASH = 'OBJECT_NAME_CONTAINS_SLASH'; export const E_CAL_OBJECT_HASH = 'CAL_OBJECT_HASH'; export const E_OBJECT_NAME_EXISTS = 'OBJECT_NAME_EXISTS'; export const E_ACCOUNT_BALANCE_NOT_ENOUGH = 'ACCOUNT_BALANCE_NOT_ENOUGH'; +export const E_NO_PERMISSION = 'NO_PERMISSION'; export declare class BroadcastTxError extends Error { readonly code: number; readonly codespace: string; @@ -50,6 +51,9 @@ export const downloadPreviewFault = (e: any): ErrorResponse => { if (e?.response?.status === 500) { return [null, E_OFF_CHAIN_AUTH]; } + if (e?.response?.status === 401) { + return [null, E_NO_PERMISSION]; + } return [null, E_UNKNOWN_ERROR]; }; diff --git a/apps/dcellar-web-ui/src/facade/object.ts b/apps/dcellar-web-ui/src/facade/object.ts index 829f91b4..76a8f298 100644 --- a/apps/dcellar-web-ui/src/facade/object.ts +++ b/apps/dcellar-web-ui/src/facade/object.ts @@ -107,6 +107,7 @@ export const downloadObject = async ( params: DownloadPreviewParams, seedString: string, ): Promise<[boolean, ErrorMsg?]> => { + debugger; const { primarySp, objectInfo } = params; const { endpoint } = primarySp; const { visibility, bucketName, objectName } = objectInfo; diff --git a/apps/dcellar-web-ui/src/modules/object/ObjectError.tsx b/apps/dcellar-web-ui/src/modules/object/ObjectError.tsx index e7e8f5ea..1ce752bb 100644 --- a/apps/dcellar-web-ui/src/modules/object/ObjectError.tsx +++ b/apps/dcellar-web-ui/src/modules/object/ObjectError.tsx @@ -44,6 +44,11 @@ export const OBJECT_ERROR_TYPES = { title: 'Account balance is not enough', icon: FILE_FAILED_URL, desc: 'Account balance is not enough, please recharge.', + }, + NO_PERMISSION: { + title: 'No permission', + icon: FILE_FAILED_URL, + desc: "You don't have this object permission.", } } diff --git a/apps/dcellar-web-ui/src/modules/object/components/ObjectList.tsx b/apps/dcellar-web-ui/src/modules/object/components/ObjectList.tsx index 9b4c46a4..add9c671 100644 --- a/apps/dcellar-web-ui/src/modules/object/components/ObjectList.tsx +++ b/apps/dcellar-web-ui/src/modules/object/components/ObjectList.tsx @@ -123,6 +123,7 @@ export const ObjectList = memo(function ObjectList() { }; const onError = (type: string) => { + console.log('type', type); const errorData = OBJECT_ERROR_TYPES[type as ObjectErrorType] ? OBJECT_ERROR_TYPES[type as ObjectErrorType] : OBJECT_ERROR_TYPES[E_UNKNOWN];