Skip to content

Commit aaf2720

Browse files
committed
fix(ContentNavigator): changed to server side handling for drag and drop on restserveradapter
Signed-off-by: Kishan Patel <[email protected]>
1 parent 532dc28 commit aaf2720

File tree

3 files changed

+14
-61
lines changed

3 files changed

+14
-61
lines changed

client/src/components/ContentNavigator/ContentDataProvider.ts

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -681,21 +681,6 @@ class ContentDataProvider
681681
return !!newUri;
682682
}
683683

684-
private async checkIfItemExistsInTarget(
685-
itemName: string,
686-
target: ContentItem,
687-
): Promise<boolean> {
688-
try {
689-
const children = await this.getChildren(target);
690-
return children.some((child) => child.name === itemName);
691-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
692-
} catch (error) {
693-
// If we can't retrieve children, assume the item doesn't exist
694-
// to avoid blocking the move operation unnecessarily
695-
return false;
696-
}
697-
}
698-
699684
private async handleContentItemDrop(
700685
target: ContentItem,
701686
item: ContentItem,
@@ -711,19 +696,10 @@ class ContentDataProvider
711696
} else if (target.type === FAVORITES_FOLDER_TYPE) {
712697
success = await this.addToMyFavorites(item);
713698
} else {
714-
// Check if an item with the same name already exists in the target
715-
const itemExists = await this.checkIfItemExistsInTarget(
716-
item.name,
717-
target,
718-
);
719-
if (itemExists) {
720-
message = Messages.FileAlreadyExistsError;
721-
} else {
722-
const targetUri = target.resourceId ?? target.uri;
723-
success = await this.moveItem(item, targetUri);
724-
if (success) {
725-
this.refresh();
726-
}
699+
const targetUri = target.resourceId ?? target.uri;
700+
success = await this.moveItem(item, targetUri);
701+
if (success) {
702+
this.refresh();
727703
}
728704
}
729705

@@ -742,20 +718,6 @@ class ContentDataProvider
742718
displayErrorMessages: boolean = true,
743719
): Promise<boolean> {
744720
const folderName = basename(path);
745-
746-
// Check if a folder with the same name already exists in the target
747-
const itemExists = await this.checkIfItemExistsInTarget(folderName, target);
748-
if (itemExists) {
749-
displayErrorMessages &&
750-
window.showErrorMessage(
751-
l10n.t(Messages.FileAlreadyExistsError, {
752-
name: folderName,
753-
}),
754-
);
755-
756-
return false;
757-
}
758-
759721
const folder = await this.model.createFolder(target, folderName);
760722
let success = true;
761723
if (!folder) {
@@ -825,17 +787,6 @@ class ContentDataProvider
825787
return;
826788
}
827789

828-
// Check if a file with the same name already exists in the target
829-
const itemExists = await this.checkIfItemExistsInTarget(name, target);
830-
if (itemExists) {
831-
window.showErrorMessage(
832-
l10n.t(Messages.FileAlreadyExistsError, {
833-
name,
834-
}),
835-
);
836-
return;
837-
}
838-
839790
const fileCreated = await this.createFile(
840791
target,
841792
name,

client/src/components/ContentNavigator/const.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ export const Messages = {
7979
FileDragFromFavorites: l10n.t("Unable to drag files from my favorites."),
8080
FileDragFromTrashError: l10n.t("Unable to drag files from trash."),
8181
FileDropError: l10n.t('Unable to drop item "{name}".'),
82-
FileAlreadyExistsError: l10n.t(
83-
'A file or folder named "{name}" already exists in the target location.',
84-
),
8582
FileNavigationRootAdminError: l10n.t(
8683
"The files cannot be accessed from the path specified in the context definition for the SAS Compute Server. Contact your SAS administrator.",
8784
),

client/src/connection/rest/RestServerAdapter.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,17 @@ class RestServerAdapter implements ContentAdapter {
447447
},
448448
};
449449

450-
const response =
451-
await this.fileSystemApi.updateFileOrDirectoryOnSystem(params);
452-
delete this.fileMetadataMap[currentFilePath];
453-
this.updateFileMetadata(newFilePath, response);
450+
try {
451+
const response =
452+
await this.fileSystemApi.updateFileOrDirectoryOnSystem(params);
453+
delete this.fileMetadataMap[currentFilePath];
454+
this.updateFileMetadata(newFilePath, response);
454455

455-
return this.filePropertiesToContentItem(response.data).vscUri;
456+
return this.filePropertiesToContentItem(response.data).vscUri;
457+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
458+
} catch (error) {
459+
return;
460+
}
456461
}
457462

458463
public async renameItem(

0 commit comments

Comments
 (0)