Skip to content

Commit

Permalink
chore(dcellar-web-ui): debug enodepath
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed May 28, 2024
1 parent bca052c commit fa7eea6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
9 changes: 5 additions & 4 deletions apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
PermissionTypes,
SpResponse,
TxResponse,
encodePath,
generateUrlByBucketName,
newBucketGRN,
newObjectGRN,
Expand Down Expand Up @@ -192,7 +193,7 @@ export const downloadObject = async (
const { visibility, bucketName, objectName } = objectInfo;

const isPrivate = visibility === VisibilityType.VISIBILITY_TYPE_PRIVATE;
const link = `${endpoint}/download/${bucketName}/${encodeObjectName(objectName)}`;
const link = `${endpoint}/download/${bucketName}/${encodePath(objectName)}`;

if (!isPrivate) {
if (batch) batchDownload(link);
Expand All @@ -217,7 +218,7 @@ export const previewObject = async (
const { visibility, bucketName, objectName } = objectInfo;

const isPrivate = visibility === VisibilityType.VISIBILITY_TYPE_PRIVATE;
const link = `${endpoint}/view/${bucketName}/${encodeObjectName(objectName)}`;
const link = `${endpoint}/view/${bucketName}/${encodePath(objectName)}`;
if (!isPrivate) {
directlyDownload(link, '_blank');
return [true];
Expand Down Expand Up @@ -588,7 +589,7 @@ export const legacyGetObjectMeta = async (
objectName: string,
endpoint: string,
) => {
const url = `${generateUrlByBucketName(endpoint, bucketName)}/${encodeObjectName(
const url = `${generateUrlByBucketName(endpoint, bucketName)}/${encodePath(
objectName,
)}?object-meta`;

Expand Down Expand Up @@ -618,7 +619,7 @@ export const getObjectMeta = async (
objectName: string,
endpoint: string,
): Promise<[ObjectMeta, null] | [null, { code: number; message: string }]> => {
const url = `${generateUrlByBucketName(endpoint, bucketName)}/${encodeObjectName(
const url = `${generateUrlByBucketName(endpoint, bucketName)}/${encodePath(
objectName,
)}?object-meta`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { OBJECT_ERROR_TYPES, ObjectErrorType } from '../ObjectError';
import { setSignatureAction } from '@/store/slices/global';
import { VersionTable } from '@/modules/object/components/VersionTable';
import { Activities } from '@/components/Activities';
import { encodePath } from '@bnb-chain/greenfield-js-sdk';

const VERSION_TABS = ['General Info', 'Activities', 'Versions'];

Expand Down Expand Up @@ -240,7 +241,7 @@ export const DetailObjectOperation = memo<DetailObjectOperationProps>(
renderPropRow(
'Universal link',
renderUrlWithLink(
`${primarySp.endpoint}/view/${currentBucketName}/${encodeObjectName(
`${primarySp.endpoint}/view/${currentBucketName}/${encodePath(
objectInfo.ObjectName,
)}`,
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GAClick } from '@/components/common/GATracker';
import { useAppDispatch, useAppSelector } from '@/store';
import { setObjectShareModePath } from '@/store/slices/object';
import { encodeObjectName, trimLongStr } from '@/utils/string';
import { encodePath } from '@bnb-chain/greenfield-js-sdk';
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, Flex, Text } from '@node-real/uikit';
import Link from 'next/link';
import { Fragment, memo } from 'react';
Expand Down Expand Up @@ -78,12 +79,7 @@ export const ObjectBreadcrumb = memo<ObjectBreadcrumbProps>(function ObjectBread
const renderBreadcrumb = () => {
const res = items.map((i, index) => {
const link = items.slice(0, index + 1).join('/');
return renderBreadcrumbItem(
encodeObjectName(link),
i,
index === items.length - 1,
index === 0,
);
return renderBreadcrumbItem(encodePath(link), i, index === items.length - 1, index === 0);
});
if (hideLeft === undefined) return res;
return res.slice(hideLeft);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Link from 'next/link';
import { memo } from 'react';
import { OBJECT_ERROR_TYPES, ObjectErrorType } from '../ObjectError';
import { setSignatureAction } from '@/store/slices/global';
import { encodePath } from '@bnb-chain/greenfield-js-sdk';

interface ObjectNameColumnProps {
item: ObjectEntity;
Expand Down Expand Up @@ -124,7 +125,7 @@ export const ObjectNameColumn = memo<ObjectNameColumnProps>(function NameItem({
return (
<Container>
<Link
href={`/buckets/${currentBucketName}/${encodeObjectName(objectName)}`}
href={`/buckets/${currentBucketName}/${encodePath(objectName)}`}
onClick={(e) => {
if (disabled) {
e.stopPropagation();
Expand All @@ -138,9 +139,7 @@ export const ObjectNameColumn = memo<ObjectNameColumnProps>(function NameItem({
if (shareMode) {
e.stopPropagation();
e.preventDefault();
dispatch(
setObjectShareModePath(`${currentBucketName}/${encodeObjectName(objectName)}`),
);
dispatch(setObjectShareModePath(`${currentBucketName}/${encodePath(objectName)}`));
}
return;
}
Expand Down
3 changes: 2 additions & 1 deletion apps/dcellar-web-ui/src/modules/upload/NameItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { setObjectOperation } from '@/store/slices/object';
import { formatBytes } from '@/utils/formatter';
import { encodeObjectName } from '@/utils/string';
import { ReactNode } from 'react';
import { encodePath } from '@bnb-chain/greenfield-js-sdk';

type Props = {
name: string;
Expand Down Expand Up @@ -43,7 +44,7 @@ export const NameItem = ({ name, size, msg, status, task, ...styleProps }: Props

if (name.endsWith('/')) {
dispatch(setTaskManagement(false));
return router.push(`/buckets/${task.bucketName}/${encodeObjectName(objectName)}`);
return router.push(`/buckets/${task.bucketName}/${encodePath(objectName)}`);
}

dispatch(
Expand Down
3 changes: 2 additions & 1 deletion apps/dcellar-web-ui/src/modules/upload/PathItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EllipsisText } from '@/components/common/EllipsisText';
import { useAppDispatch } from '@/store';
import { setTaskManagement } from '@/store/slices/global';
import { encodeObjectName } from '@/utils/string';
import { encodePath } from '@bnb-chain/greenfield-js-sdk';

interface PathItemProps {
path: string;
Expand Down Expand Up @@ -37,7 +38,7 @@ export const PathItem = memo<PathItemProps>(function PathItem({ path, status, ..
text={path}
{...styleProps}
>
<Link href={`/buckets/${encodeObjectName(path)}`} legacyBehavior passHref>
<Link href={`/buckets/${encodePath(path)}`} legacyBehavior passHref>
<Text
borderBottom={finished ? '1px solid' : ''}
as={'a'}
Expand Down
4 changes: 2 additions & 2 deletions apps/dcellar-web-ui/src/utils/string.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IQuotaProps } from '@bnb-chain/greenfield-js-sdk';
import { IQuotaProps, encodePath } from '@bnb-chain/greenfield-js-sdk';
import BigNumber from 'bignumber.js';
import { hexlify, toUtf8Bytes } from 'ethers/lib/utils';

Expand Down Expand Up @@ -148,7 +148,7 @@ export const copy = (text: string) => {
};

const getObjectPath = (bucketName = '', objectName = '') => {
return [bucketName, encodeObjectName(objectName)].join('/');
return [bucketName, encodePath(objectName)].join('/');
};

export const getShareLink = (bucketName: string, objectName: string) => {
Expand Down

0 comments on commit fa7eea6

Please sign in to comment.