Skip to content

Commit

Permalink
feat(dcellar-web-ui): add download no permission error
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed Jul 11, 2023
1 parent c797a5e commit 15c4933
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DCDrawer = (props: DCDrawerProps) => {

return (
<GAShow isShow={props.isOpen} name={gaShowName} data={gaShowData}>
<QDrawer closeOnOverlayClick={false} w={568} onClose={onBeforeClose} {...restProps}>
<QDrawer closeOnOverlayClick={true} w={568} onClose={onBeforeClose} {...restProps}>
{children}
</QDrawer>
</GAShow>
Expand Down
4 changes: 4 additions & 0 deletions apps/dcellar-web-ui/src/facade/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
};

Expand Down
1 change: 1 addition & 0 deletions apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions apps/dcellar-web-ui/src/modules/object/ObjectError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const ObjectList = memo<ObjectListProps>(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];
Expand Down

0 comments on commit 15c4933

Please sign in to comment.