Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/locales/en/subaccount.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"delete": "Delete",
"save": "Save"
},
"listStates": {
"retry": "Try again",
"unavailable": "Unavailable",
"genericError": "Something went wrong. Please try again.",
"loadingAriaLabel": "Loading"
},
"shared": {
"loadingBrandingAriaLabel": "Loading console branding"
},
Expand Down Expand Up @@ -46,7 +52,7 @@
"bucketActionsLabel": "Bucket actions",
"view": "View",
"deleteBucket": "Delete bucket",
"loading": "Loading buckets…",
"loadError": "Couldn't load your buckets",
"noBucketsFound": "No buckets found",
"tryDifferentSearch": "Try a different search term",
"statBucketsHint_one": "In {{count}} region",
Expand Down Expand Up @@ -108,7 +114,7 @@
"columnLastModified": "Last modified",
"columnVersionId": "Version ID",
"selectAll": "Select all",
"loadingObjects": "Loading objects…",
"loadError": "Couldn't load this folder",
"loadingConfig": "Loading bucket configuration…",
"fieldBucketName": "Bucket name",
"fieldRegion": "Region",
Expand Down Expand Up @@ -155,7 +161,6 @@
"shares": {
"title": "Shared",
"searchPlaceholder": "Search shared links...",
"loading": "Loading shared links…",
"emptyDefault": "No shared links yet",
"emptyFiltered": "No shared links found",
"emptyFilteredHint": "Try a different search term",
Expand Down Expand Up @@ -355,7 +360,7 @@
"columnActiveStorage": "Active storage (TB)",
"columnDeletedStorage": "Deleted storage (TB)",
"columnActiveObjects": "Active objects",
"loading": "Loading usage data…",
"loadError": "Couldn't load usage data",
"empty": "No usage data for this period",
"emptyHint": "Try expanding the date range."
},
Expand Down
13 changes: 9 additions & 4 deletions src/locales/es/subaccount.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"delete": "Eliminar",
"save": "Guardar"
},
"listStates": {
"retry": "Reintentar",
"unavailable": "No disponible",
"genericError": "Algo ha salido mal. Inténtalo de nuevo.",
"loadingAriaLabel": "Cargando"
},
"shared": {
"loadingBrandingAriaLabel": "Cargando la personalización de la consola"
},
Expand Down Expand Up @@ -46,7 +52,7 @@
"bucketActionsLabel": "Acciones del bucket",
"view": "Ver",
"deleteBucket": "Eliminar bucket",
"loading": "Cargando buckets…",
"loadError": "No se pudieron cargar tus buckets",
"noBucketsFound": "No se encontraron buckets",
"tryDifferentSearch": "Prueba con otro término de búsqueda",
"statBucketsHint_one": "En {{count}} región",
Expand Down Expand Up @@ -108,7 +114,7 @@
"columnLastModified": "Última modificación",
"columnVersionId": "ID de versión",
"selectAll": "Seleccionar todo",
"loadingObjects": "Cargando objetos…",
"loadError": "No se pudo cargar esta carpeta",
"loadingConfig": "Cargando la configuración del bucket…",
"fieldBucketName": "Nombre del bucket",
"fieldRegion": "Región",
Expand Down Expand Up @@ -155,7 +161,6 @@
"shares": {
"title": "Compartidos",
"searchPlaceholder": "Buscar enlaces compartidos...",
"loading": "Cargando enlaces compartidos…",
"emptyDefault": "Todavía no hay enlaces compartidos",
"emptyFiltered": "No se encontraron enlaces compartidos",
"emptyFilteredHint": "Prueba con otro término de búsqueda",
Expand Down Expand Up @@ -355,7 +360,7 @@
"columnActiveStorage": "Almacenamiento activo (TB)",
"columnDeletedStorage": "Almacenamiento eliminado (TB)",
"columnActiveObjects": "Objetos activos",
"loading": "Cargando datos de uso…",
"loadError": "No se pudieron cargar los datos de uso",
"empty": "No hay datos de uso para este período",
"emptyHint": "Prueba a ampliar el rango de fechas."
},
Expand Down
3 changes: 3 additions & 0 deletions src/services/s3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const isAccessDeniedError = (err: unknown): boolean =>
(err as { name?: string })?.name === 'AccessDenied' ||
(err as { $metadata?: { httpStatusCode?: number } })?.$metadata?.httpStatusCode === 403;

export const s3ErrorMessage = (err: unknown, fallback: string): string =>
err instanceof Error && err.message ? err.message : fallback;

export const s3Service = {
listBuckets: async (
client: S3Client,
Expand Down
139 changes: 139 additions & 0 deletions src/sub-account/components/ListStates.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { CSSProperties } from 'react';
import { useTranslation } from 'react-i18next';
import { WarningIcon } from '@phosphor-icons/react';
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import { T } from '../tokens';
import { ListStatus } from '../hooks/listLoad';

export type SkeletonCell = 'tile' | 'icon' | 'text' | 'pill' | 'checkbox' | 'none';

const TEXT_WIDTHS = ['55%', '40%', '62%', '35%', '48%'];

const SkeletonCellContent = ({ cell, row }: { cell: SkeletonCell; row: number }) => {
if (cell === 'none') return <span />;
if (cell === 'checkbox') return <Skeleton width={16} height={16} />;
if (cell === 'pill') return <Skeleton width={70} height={20} borderRadius={999} />;
if (cell === 'text') return <Skeleton width="65%" height={14} />;
const iconSize = cell === 'tile' ? 32 : 20;
return (
<div style={{ display: 'flex', alignItems: 'center', gap: 10, minWidth: 0 }}>
<Skeleton width={iconSize} height={iconSize} borderRadius={cell === 'tile' ? 8 : 4} />
<div style={{ flex: 1, paddingRight: 16 }}>
<Skeleton width={TEXT_WIDTHS[row % TEXT_WIDTHS.length]} height={14} />
</div>
</div>
);
};

interface ListSkeletonRowsProps {
cells: SkeletonCell[];
gridTemplateColumns: string;
rowHeight: number;
padding?: string;
rows?: number;
}

/** Placeholder rows with the same geometry as the real rows, so nothing shifts when data arrives. */
export const ListSkeletonRows = ({
cells,
gridTemplateColumns,
rowHeight,
padding = '0 24px',
rows = 5,
}: ListSkeletonRowsProps) => {
const { t } = useTranslation('subaccount');
const rowStyle: CSSProperties = {
display: 'grid',
gridTemplateColumns,
alignItems: 'center',
padding,
height: rowHeight,
borderBottom: `1px solid ${T.gray15}`,
};
return (
<SkeletonTheme baseColor={T.gray15} highlightColor={T.gray10}>
<div aria-busy="true" aria-label={t('listStates.loadingAriaLabel')}>
{Array.from({ length: rows }, (_, row) => (
<div key={row} style={rowStyle}>
{cells.map((cell, column) => (
<SkeletonCellContent key={column} cell={cell} row={row} />
))}
</div>
))}
</div>
</SkeletonTheme>
);
};

interface ListErrorStateProps {
title: string;
message: string;
onRetry: () => void;
}

export const ListErrorState = ({ title, message, onRetry }: ListErrorStateProps) => {
const { t } = useTranslation('subaccount');
return (
<div
role="alert"
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
gap: 10,
padding: '56px 24px',
textAlign: 'center',
}}
>
<div
style={{
width: 48,
height: 48,
borderRadius: '50%',
background: '#FEF2F2',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<WarningIcon size={24} color={T.red} aria-hidden="true" />
</div>
<p style={{ margin: 0, fontSize: 15, fontWeight: 600, color: T.gray100 }}>{title}</p>
<p style={{ margin: 0, fontSize: 13, color: T.gray60, maxWidth: 360, wordBreak: 'break-word' }}>{message}</p>
<button
type="button"
onClick={onRetry}
style={{
marginTop: 6,
height: 36,
padding: '0 14px',
border: `1px solid ${T.gray20}`,
borderRadius: 8,
background: T.white,
color: T.gray80,
fontSize: 13,
fontWeight: 500,
fontFamily: 'inherit',
cursor: 'pointer',
}}
>
{t('listStates.retry')}
</button>
</div>
);
};

interface StatPlaceholderProps {
status: Exclude<ListStatus, 'ready'>;
height: number;
width: number;
}

export const StatPlaceholder = ({ status, height, width }: StatPlaceholderProps) =>
status === 'loading' ? (
<SkeletonTheme baseColor={T.gray15} highlightColor={T.gray10}>
<Skeleton width={width} height={height} />
</SkeletonTheme>
) : (
<span style={{ color: T.gray50, fontWeight: 400 }}>—</span>
);
15 changes: 13 additions & 2 deletions src/sub-account/components/shares/SharesCardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { useTranslation } from 'react-i18next';
import Input from '../../../components/Input';
import { T } from '../../tokens';
import { StatPlaceholder } from '../ListStates';
import { ListStatus } from '../../hooks/listLoad';

interface SharesCardHeaderProps {
totalCount: number;
status: ListStatus;
search: string;
onSearchChange: (value: string) => void;
}

export const SharesCardHeader = ({ totalCount, search, onSearchChange }: SharesCardHeaderProps) => {
export const SharesCardHeader = ({ totalCount, status, search, onSearchChange }: SharesCardHeaderProps) => {
const { t } = useTranslation('subaccount');
return (
<div
style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '20px 24px', gap: 16 }}
>
<div>
<p style={{ fontSize: 16, fontWeight: 600, color: T.gray100 }}>{t('shares.title')}</p>
<p style={{ fontSize: 13, color: T.gray50, marginTop: 2 }}>{t('shares.linkCount', { count: totalCount })}</p>
<p style={{ fontSize: 13, color: T.gray50, marginTop: 2 }}>
{status === 'ready' ? (
t('shares.linkCount', { count: totalCount })
) : status === 'loading' ? (
<StatPlaceholder status="loading" width={80} height={12} />
) : (
' '
)}
</p>
</div>
<div style={{ width: 280 }}>
<Input
Expand Down
29 changes: 22 additions & 7 deletions src/sub-account/components/shares/SharesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { useTranslation } from 'react-i18next';
import { card } from '../../tokens';
import { ShareListItem } from '../../services/share.service';
import { COLUMN_KEYS, toBodyState } from './constants';
import { centeredMessage, headerCell, headerRow } from './styles';
import { ListStatus } from '../../hooks/listLoad';
import { COLUMN_KEYS, GRID_TEMPLATE, toBodyState } from './constants';
import { headerCell, headerRow } from './styles';
import { ListErrorState, ListSkeletonRows } from '../ListStates';
import { SharesCardHeader } from './SharesCardHeader';
import { SharesEmptyState } from './SharesEmptyState';
import { ShareRow } from './ShareRow';

interface SharesTableProps {
shares: ShareListItem[];
totalCount: number;
isLoading: boolean;
status: ListStatus;
loadErrorMessage: string;
onRetry: () => void;
search: string;
onSearchChange: (value: string) => void;
onRevoke: (share: ShareListItem) => void;
Expand All @@ -21,19 +25,21 @@ interface SharesTableProps {
export const SharesTable = ({
shares,
totalCount,
isLoading,
status,
loadErrorMessage,
onRetry,
search,
onSearchChange,
onRevoke,
canToggleVisibility,
onToggleVisibility,
}: SharesTableProps) => {
const { t } = useTranslation('subaccount');
const bodyState = toBodyState(isLoading, shares.length);
const bodyState = toBodyState(status, shares.length);

return (
<div style={{ ...card, overflow: 'hidden' }}>
<SharesCardHeader totalCount={totalCount} search={search} onSearchChange={onSearchChange} />
<SharesCardHeader totalCount={totalCount} status={status} search={search} onSearchChange={onSearchChange} />

<div role="row" style={headerRow}>
{COLUMN_KEYS.map((column) => (
Expand All @@ -43,7 +49,16 @@ export const SharesTable = ({
))}
</div>

{bodyState === 'loading' && <div style={centeredMessage}>{t('shares.loading')}</div>}
{bodyState === 'error' && (
<ListErrorState title={t('shares.loadError')} message={loadErrorMessage} onRetry={onRetry} />
)}
{bodyState === 'loading' && (
<ListSkeletonRows
cells={['tile', 'text', 'text', 'pill', 'text', 'none']}
gridTemplateColumns={GRID_TEMPLATE}
rowHeight={56}
/>
)}
{bodyState === 'empty' && <SharesEmptyState hasSearch={!!search} />}
{bodyState === 'items' &&
shares.map((share) => (
Expand Down
5 changes: 3 additions & 2 deletions src/sub-account/components/shares/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { BODY_STATE } from '../../../components/settings/MembersTable';
import { ShareListItem } from '../../services/share.service';
import { ListStatus } from '../../hooks/listLoad';

export const NO_VALUE = '—';

Expand All @@ -21,7 +22,7 @@ export const shareTypeLabelKey = (share: ShareListItem) => (share.isFolder ? 'sh
export const shareAccessLabelKey = (share: ShareListItem) =>
share.isPublic ? 'shares.accessPublic' : 'shares.accessMembers';

export const toBodyState = (isLoading: boolean, count: number): BODY_STATE => {
if (isLoading) return 'loading';
export const toBodyState = (status: ListStatus, count: number): BODY_STATE | 'error' => {
if (status !== 'ready') return status;
return count === 0 ? 'empty' : 'items';
};
Loading
Loading