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
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ import workspacesSelectors from 'app/store/slices/workspaces/workspaces.selector
const ReachedPlanLimitDialog = (): JSX.Element => {
const { translate } = useTranslationContext();
const isOpen = useAppSelector((state) => state.ui.isReachedPlanLimitDialogOpen);
const reachedPlanLimitInfo = useAppSelector((state) => state.ui.reachedPlanLimitDialogInfo);
const selectedWorkspace = useAppSelector(workspacesSelectors.getSelectedWorkspace);

const dispatch = useAppDispatch();

const onClose = (): void => {
dispatch(uiActions.setIsReachedPlanLimitDialogOpen(false));
dispatch(
uiActions.setOpenReachedPlanLimitDialog({
open: false,
}),
);
};

const onAccept = async (): Promise<void> => {
try {
dispatch(uiActions.setIsReachedPlanLimitDialogOpen(false));
dispatch(
uiActions.setOpenReachedPlanLimitDialog({
open: false,
}),
);
navigationService.openPreferencesDialog({
section: 'account',
subsection: 'plans',
Expand All @@ -34,21 +43,25 @@ const ReachedPlanLimitDialog = (): JSX.Element => {
return (
<BaseDialog hideCloseButton isOpen={isOpen} onClose={onClose} bgColor="bg-surface">
<div className="px-5 pb-5">
<img className="mx-auto mb-5" src={DriveStorageError} />
<img className="mx-auto mb-5" src={DriveStorageError} alt="Drive storage error" />
<div className="mb-2">
<h2 className="text-center text-2xl font-medium leading-8 text-gray-100">
{translate('error.storageIsFull')}
{reachedPlanLimitInfo?.title ?? translate('error.storageIsFull')}
</h2>
</div>
<p className="mb-5 text-center leading-tight text-gray-80">{translate('error.storageIsFullDescription')}</p>
<p className="mb-5 text-center leading-tight text-gray-80">
{reachedPlanLimitInfo?.description ?? translate('error.storageIsFullDescription')}
</p>

<div className="flex flex-row justify-end">
<Button variant="secondary" className="mr-2" onClick={() => onClose()}>
{translate('actions.cancel') as string}
</Button>
<Button variant="primary" onClick={() => onAccept()}>
{translate('actions.buyStorage') as string}
{translate('actions.cancel')}
</Button>
{!reachedPlanLimitInfo?.hidePrimaryAction && (
<Button variant="primary" onClick={() => onAccept()}>
{translate('actions.buyStorage')}
</Button>
)}
</div>
</div>
</BaseDialog>
Expand Down
6 changes: 6 additions & 0 deletions src/app/drive/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ export interface DriveItemPatch {
shares?: ShareLink[];
}

export interface ReachedPlanLimitDialogInfo {
title: string;
description: string;
hidePrimaryAction?: boolean;
}

export interface UpgradePlanDialogInfo {
title: string;
description: string;
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,9 @@
"renamingItem": "Fehler beim Umbenennen von Elementen",
"linkExpired": "Dieser sichere Link ist abgelaufen",
"teamInvitation": "Die Einladungs-E-Mail konnte nicht gesendet werden",
"ownerStorageIsFull": "Der Speicher des Eigentümers ist voll",
"storageIsFull": "Dein Speicher ist voll",
"ownerStorageIsFullDescription": "Du kannst in diesem geteilten Ordner keine Dateien hochladen.",
"storageIsFullDescription": "Sie können keine Dateien hochladen, synchronisieren oder sichern.",
"noSpaceAvailable": "Du hast die Grenzen deines aktuellen Plans erreicht und die Synchronisierung wurde gestoppt. Führe jetzt ein Upgrade durch, damit deine Dateien sicher synchronisiert bleiben.",
"sharedFolderTooBig": "Internxt Drive unterstützt das Teilen von Ordnern mit mehr als 1 GB nicht.",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,9 @@
"renamingItem": "Error when renaming item/s",
"linkExpired": "This secure link has expired",
"teamInvitation": "The invitation email could not be sent",
"ownerStorageIsFull": "Owner storage is full",
"storageIsFull": "Your storage is full",
"ownerStorageIsFullDescription": "You can’t upload files in this shared folder.",
"storageIsFullDescription": "You can’t upload, sync or backup files.",
"noSpaceAvailable": "You’ve reached the limits of your current plan and sync has stopped. Upgrade now to keep your files synced securely.",
"sharedFolderTooBig": "Internxt Drive does not support sharing folders of more than 1GB.",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,9 @@
"renamingItem": "Error al renombrar ítem/s",
"linkExpired": "Este enlace seguro ha caducado",
"teamInvitation": "No se ha podido enviar el correo electrónico de invitación",
"ownerStorageIsFull": "El almacenamiento del propietario está lleno",
"storageIsFull": "Tu almacenamiento está lleno",
"ownerStorageIsFullDescription": "No puedes subir archivos en esta carpeta compartida.",
"storageIsFullDescription": "No puedes subir, sincronizar ni respaldar archivos.",
"noSpaceAvailable": "Has alcanzado el límite y la sincronización se ha pausado. Mejora tu plan para mantener tus archivos sincronizados y seguros.",
"sharedFolderTooBig": "Internxt Drive no admite compartir carpetas de más de 1 GB",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,9 @@
"renamingItem": "Erreur lors du renommage d'éléments",
"linkExpired": "Ce lien sécurisé a expiré",
"teamInvitation": "Le courriel d'invitation n'a pas pu être envoyé",
"ownerStorageIsFull": "Le stockage du propriétaire est plein",
"storageIsFull": "Votre espace de stockage est plein",
"ownerStorageIsFullDescription": "Vous ne pouvez pas téléverser de fichiers dans ce dossier partagé.",
"storageIsFullDescription": "Vous ne pouvez pas télécharger, synchroniser ou sauvegarder des fichiers.",
"noSpaceAvailable": "Vous avez atteint les limites de votre plan actuel et la synchronisation s'est arrêtée. Mettez-le à jour maintenant pour continuer à synchroniser vos fichiers en toute sécurité.",
"sharedFolderTooBig": "Internxt Drive ne prend pas en charge le partage de dossiers de plus de 1 Go.",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,9 @@
"renamingItem": "Errore quando si rinominano gli elementi",
"linkExpired": "Questo link sicuro è scaduto",
"teamInvitation": "Non è stato possibile inviare l'e-mail di invito",
"ownerStorageIsFull": "Lo spazio di archiviazione del proprietario è pieno",
"storageIsFull": "Lo spazio di archiviazione è pieno",
"ownerStorageIsFullDescription": "Non puoi caricare file in questa cartella condivisa.",
"storageIsFullDescription": "Non puoi caricare, sincronizzare o eseguire il backup dei file",
"noSpaceAvailable": "Avete raggiunto i limiti del vostro piano attuale e la sincronizzazione si è interrotta. Effettuate subito l'aggiornamento per continuare a sincronizzare i vostri file in modo sicuro.",
"sharedFolderTooBig": "Internxt Drive non supporta la condivisione di cartelle di dimensioni superiori a 1 GB.",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,9 @@
"renamingItem": "Ошибка при переименовании элементов",
"linkExpired": "Срок действия этой безопасной ссылки истек",
"teamInvitation": "Не удалось отправить письмо с приглашением",
"ownerStorageIsFull": "Хранилище владельца заполнено",
"storageIsFull": "Ваше хранилище заполнено",
"ownerStorageIsFullDescription": "Вы не можете загружать файлы в эту общую папку.",
"storageIsFullDescription": "Вы не можете загружать, синхронизировать или создавать резервные копии файлов.",
"noSpaceAvailable": "Вы исчерпали лимит текущего тарифного плана, и синхронизация прекратилась. Перейдите на новый тарифный план, чтобы сохранить синхронизацию файлов в безопасности.",
"sharedFolderTooBig": "Internxt Drive не поддерживает общий доступ к папкам объемом более 1 ГБ.",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,9 @@
"renamingItem": "重命名項目時出錯",
"linkExpired": "此安全鏈接已過期",
"teamInvitation": "無法發送邀請郵件",
"ownerStorageIsFull": "擁有者的儲存空間已滿",
"storageIsFull": "您的存儲空間已滿",
"ownerStorageIsFullDescription": "您無法在此共享資料夾中上傳檔案。",
"storageIsFullDescription": "您無法上傳、同步或備份文件。",
"noSpaceAvailable": "您已達到當前計劃的限制,同步已停止。立即升級以保持文件的安全同步。",
"sharedFolderTooBig": "Internxt Drive不支持共享超過1GB的文件夾。",
Expand Down
2 changes: 2 additions & 0 deletions src/app/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,9 @@
"renamingItem": "重命名项目时出错",
"linkExpired": "此安全链接已过期",
"teamInvitation": "邀请邮件无法发送",
"ownerStorageIsFull": "所有者的存储空间已满",
"storageIsFull": "您的存储空间已满",
"ownerStorageIsFullDescription": "您无法在此共享文件夹中上传文件。",
"storageIsFullDescription": "无法上传同步或备份文件",
"noSpaceAvailable": "您已达到当前计划的限制,同步已停止。立即升级以确保您的文件安全同步。",
"sharedFolderTooBig": "Internxt Drive 不支持共享超过 1GB 的文件夹。",
Expand Down
38 changes: 29 additions & 9 deletions src/app/store/slices/storage/storage.thunks/uploadItemsThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
const isPlanSizeLimitExceeded = planLimit && totalItemsSize >= planLimit;

if (isPlanSizeLimitExceeded) {
dispatch(uiActions.setIsReachedPlanLimitDialogOpen(true));
dispatch(
uiActions.setOpenReachedPlanLimitDialog({
open: true,
}),
);
return false;
}
} catch (err: unknown) {
Expand Down Expand Up @@ -165,7 +169,12 @@
abortController: new AbortController(),
}));

const openMaxSpaceOccupiedDialog = () => dispatch(uiActions.setIsReachedPlanLimitDialogOpen(true));
const openMaxSpaceOccupiedDialog = () =>
dispatch(
uiActions.setOpenReachedPlanLimitDialog({
open: true,
}),
);

try {
await uploadFileWithManager(
Expand Down Expand Up @@ -249,15 +258,11 @@
const teamId = selectedWorkspace?.workspace.defaultTeamId;
const options = { ...DEFAULT_OPTIONS, ...payloadOptions };

const continueWithUpload = isUploadAllowed({ state: state, files, dispatch, isWorkspaceSelected: !!workspaceId });
if (!continueWithUpload) return;

let zeroLengthFilesNumber = 0;
for (const file of files) {
if (file.size === 0) {
zeroLengthFilesNumber = zeroLengthFilesNumber + 1;
continue;
}

const { filename, extension } = itemUtils.getFilenameAndExt(file.name);

let page = 0;
Expand Down Expand Up @@ -345,7 +350,17 @@
abortController: new AbortController(),
}));

const openMaxSpaceOccupiedDialog = () => dispatch(uiActions.setIsReachedPlanLimitDialogOpen(true));
const openMaxSpaceOccupiedDialog = () =>
dispatch(
uiActions.setOpenReachedPlanLimitDialog({
open: true,
info: {
title: t('error.ownerStorageIsFull'),
description: t('error.ownerStorageIsFullDescription'),
hidePrimaryAction: true,
},
}),
);

try {
await uploadFileWithManager(
Expand Down Expand Up @@ -439,7 +454,12 @@
},
}));

const openMaxSpaceOccupiedDialog = () => dispatch(uiActions.setIsReachedPlanLimitDialogOpen(true));
const openMaxSpaceOccupiedDialog = () =>

Check warning on line 457 in src/app/store/slices/storage/storage.thunks/uploadItemsThunk.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Update this function so that its implementation is not identical to the one on line 172.

See more on https://sonarcloud.io/project/issues?id=internxt_drive-web&issues=AZ2QToMOSZpADIv68qjQ&open=AZ2QToMOSZpADIv68qjQ&pullRequest=1931
dispatch(
uiActions.setOpenReachedPlanLimitDialog({
open: true,
}),
);

try {
await uploadFileWithManager(
Expand Down
22 changes: 18 additions & 4 deletions src/app/store/slices/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { DriveItemData, DriveItemDetails, FileInfoMenuItem, UpgradePlanDialogInfo } from 'app/drive/types';
import {
DriveItemData,
DriveItemDetails,
FileInfoMenuItem,
ReachedPlanLimitDialogInfo,
UpgradePlanDialogInfo,
} from 'app/drive/types';
import { PreviewFileItem } from '../../../share/types';
import { FileVersion } from '@internxt/sdk/dist/drive/storage/types';

Expand All @@ -20,6 +26,7 @@ interface UISliceState {
isEditFolderNameDialog: boolean;
isPreferencesDialogOpen: boolean;
isReachedPlanLimitDialogOpen: boolean;
reachedPlanLimitDialogInfo?: ReachedPlanLimitDialogInfo;
isUpgradePlanDialogOpen: boolean;
currentUpgradePlanDialogInfo: UpgradePlanDialogInfo | null;
isShareItemDialogOpen: boolean;
Expand Down Expand Up @@ -137,8 +144,15 @@ export const uiSlice = createSlice({
setIsPreferencesDialogOpen: (state: UISliceState, action: PayloadAction<boolean>) => {
state.isPreferencesDialogOpen = action.payload;
},
setIsReachedPlanLimitDialogOpen: (state: UISliceState, action: PayloadAction<boolean>) => {
state.isReachedPlanLimitDialogOpen = action.payload;
setOpenReachedPlanLimitDialog: (
state: UISliceState,
action: PayloadAction<{
open: boolean;
info?: ReachedPlanLimitDialogInfo;
}>,
) => {
state.isReachedPlanLimitDialogOpen = action.payload.open;
state.reachedPlanLimitDialogInfo = action.payload.info;
},
setIsUpgradePlanDialogOpen: (state: UISliceState, action: PayloadAction<boolean>) => {
state.isUpgradePlanDialogOpen = action.payload;
Expand Down Expand Up @@ -206,7 +220,7 @@ export const {
setIsMoveItemsDialogOpen,
setIsPreferencesDialogOpen,
setIsFileLoggerOpen,
setIsReachedPlanLimitDialogOpen,
setOpenReachedPlanLimitDialog,
setIsUpgradePlanDialogOpen,
setCurrentUpgradePlanDialogInfo,
setIsShareItemDialogOpen,
Expand Down
1 change: 1 addition & 0 deletions src/services/error.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const errorService = {
castedError = new AppError(err);
} else if (err instanceof Error) {
const headers = (err as ErrorWithStatus).headers;

castedError = new AppError(err.message || 'Unknown error', (err as ErrorWithStatus).status, undefined, headers);
} else {
const map = err as Record<string, unknown>;
Expand Down
2 changes: 1 addition & 1 deletion src/upload.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ self.addEventListener('message', async (event) => {
postMessage({ result: 'success', fileId });
} catch (err) {
console.log('[WORKER] ERROR -->', err);
const errorCloned = JSON.parse(JSON.stringify(err));
const errorCloned = { ...JSON.parse(JSON.stringify(err)), message: (err as { message?: string })?.message };
postMessage({ result: 'error', error: errorCloned });
}
} else {
Expand Down
Loading