From d0609f7fc7a55992603809d88cac84af8bfe2a7c Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Thu, 24 Oct 2024 18:05:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20back,front:=20when=20moving=20an?= =?UTF-8?q?=20item,=20check=20for=20a=20new=20available=20name=20(#706)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/src/services/documents/services/index.ts | 10 ++++++++++ tdrive/frontend/public/locales/en.json | 1 + tdrive/frontend/public/locales/fr.json | 1 + tdrive/frontend/public/locales/ru.json | 1 + tdrive/frontend/public/locales/vi.json | 1 + .../src/app/features/drive/hooks/use-drive-actions.tsx | 6 ++++-- .../src/app/views/client/body/drive/context-menu.tsx | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tdrive/backend/node/src/services/documents/services/index.ts b/tdrive/backend/node/src/services/documents/services/index.ts index 13b04b25..cdc65508 100644 --- a/tdrive/backend/node/src/services/documents/services/index.ts +++ b/tdrive/backend/node/src/services/documents/services/index.ts @@ -557,6 +557,16 @@ export class DocumentsService { throw Error("Move operation not permitted"); } else { oldParent = item.parent_id; + const newParentId = content.parent_id; + const needRenameTo = await getItemName( + newParentId, + item.id, + item.name, + item.is_directory, + this.repository, + context, + ); + if (needRenameTo !== item.name) renamedTo = item.name = needRenameTo; } if (key === "access_info") { // if manage access is disabled, we don't allow changing access level diff --git a/tdrive/frontend/public/locales/en.json b/tdrive/frontend/public/locales/en.json index 60f980ac..dd7b17d5 100644 --- a/tdrive/frontend/public/locales/en.json +++ b/tdrive/frontend/public/locales/en.json @@ -197,6 +197,7 @@ "hooks.use-drive-actions.unable_remove_file": "Unable to remove this file.", "hooks.use-drive-actions.unable_restore_file": "Unable to restore this item.", "hooks.use-drive-actions.unable_update_file": "Unable to update this file.", + "hooks.use-drive-actions.update_caused_a_rename": "Item was renamed to '{{$2}}'.", "login.create_account": "Create account", "login.login_error": "Error during login", "molecules.download_banner.download_button": "Download desktop app", diff --git a/tdrive/frontend/public/locales/fr.json b/tdrive/frontend/public/locales/fr.json index 0cdda18d..82bda248 100644 --- a/tdrive/frontend/public/locales/fr.json +++ b/tdrive/frontend/public/locales/fr.json @@ -190,6 +190,7 @@ "hooks.use-drive-actions.unable_remove_file": "Impossible de supprimer ce fichier", "hooks.use-drive-actions.unable_restore_file": "Impossible de restaurer cet élément.", "hooks.use-drive-actions.unable_update_file": "Impossible de mettre à jour ce fichier", + "hooks.use-drive-actions.update_caused_a_rename": "Renommé en '{{$2}}'.", "login.create_account": "Créer un compte", "login.login_error": "Erreur lors de la connexion", "molecules.download_banner.download_button": "Télécharger l'application de bureau", diff --git a/tdrive/frontend/public/locales/ru.json b/tdrive/frontend/public/locales/ru.json index 0fa58f64..faa07d8e 100644 --- a/tdrive/frontend/public/locales/ru.json +++ b/tdrive/frontend/public/locales/ru.json @@ -197,6 +197,7 @@ "hooks.use-drive-actions.unable_remove_file": "Невозможно удалить эти файлы.", "hooks.use-drive-actions.unable_restore_file": "Невозможно восстановить эти файлы.", "hooks.use-drive-actions.unable_update_file": "Невозможно обновить эти файлы.", + "hooks.use-drive-actions.update_caused_a_rename": "Элемент был переименован в «{{$2}}».", "login.create_account": "Создать учетную запись", "login.login_error": "Ошибка при входе в систему", "molecules.download_banner.download_button": "Скачать настольное приложение", diff --git a/tdrive/frontend/public/locales/vi.json b/tdrive/frontend/public/locales/vi.json index ab68f399..8e4813ab 100644 --- a/tdrive/frontend/public/locales/vi.json +++ b/tdrive/frontend/public/locales/vi.json @@ -179,6 +179,7 @@ "hooks.use-drive-actions.unable_remove_file": "Không thể xóa tệp này.", "hooks.use-drive-actions.unable_restore_file": "Không thể khôi phục mục này.", "hooks.use-drive-actions.unable_update_file": "Không thể cập nhật tệp này.", + "hooks.use-drive-actions.update_caused_a_rename": "Mục đã được đổi tên thành '{{$2}}'.", "login.create_account": "Tạo tài khoản", "login.login_error": "Lỗi trong khi đăng nhập", "molecules.download_banner.download_button": "Tải xuống ứng dụng dành cho máy tính", diff --git a/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx b/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx index 426fec9a..337187f0 100644 --- a/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx +++ b/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx @@ -138,9 +138,11 @@ export const useDriveActions = (inPublicSharing?: boolean) => { ); const update = useCallback( - async (update: Partial, id: string, parentId: string) => { + async (update: Partial, id: string, parentId: string, previousName?: string) => { try { - await DriveApiClient.update(companyId, id, update); + const newItem = await DriveApiClient.update(companyId, id, update); + if (previousName && previousName !== newItem.name && !update.name) + ToasterService.warn(Languages.t('hooks.use-drive-actions.update_caused_a_rename', [previousName, newItem.name])); await refresh(id || '', true); if (!inPublicSharing) await refresh(parentId || '', true); if (update?.parent_id !== parentId) await refresh(update?.parent_id || '', true); diff --git a/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx b/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx index e0b04d38..ec6655dc 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx @@ -148,6 +148,7 @@ export const useOnBuildContextMenu = ( }, item.id, item.parent_id, + item.name, ); }, }),