🩹 back,front: when moving an item, check for a new available name (#706)
This commit is contained in:
committed by
ericlinagora
parent
e07ddf5197
commit
d0609f7fc7
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "Скачать настольное приложение",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -138,9 +138,11 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
|
||||
);
|
||||
|
||||
const update = useCallback(
|
||||
async (update: Partial<DriveItem>, id: string, parentId: string) => {
|
||||
async (update: Partial<DriveItem>, 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);
|
||||
|
||||
@@ -148,6 +148,7 @@ export const useOnBuildContextMenu = (
|
||||
},
|
||||
item.id,
|
||||
item.parent_id,
|
||||
item.name,
|
||||
);
|
||||
},
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user