提交 a3198370 编写于 作者: I isidor

explorer: disable dragging readonly items

#71159
上级 63b80d0a
......@@ -429,6 +429,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
private toDispose: IDisposable[];
private dropEnabled: boolean;
private isCopy: boolean;
constructor(
@INotificationService private notificationService: INotificationService,
......@@ -549,7 +550,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
}
getDragURI(element: ExplorerItem): string | null {
if (this.explorerService.isEditable(element)) {
if (this.explorerService.isEditable(element) || (!this.isCopy && element.isReadonly)) {
return null;
}
......@@ -565,6 +566,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
}
onDragStart(data: IDragAndDropData, originalEvent: DragEvent): void {
this.isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh);
const items = (data as ElementsDragAndDropData<ExplorerItem>).elements;
if (items && items.length && originalEvent.dataTransfer) {
// Apply some datatransfer types to allow for dragging the element outside of the application
......@@ -597,7 +599,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
}
// In-Explorer DND (Move/Copy file)
else {
this.handleExplorerDrop(data, target, originalEvent);
this.handleExplorerDrop(data, target);
}
}
......@@ -712,15 +714,14 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
return Promise.resolve(undefined);
}
private handleExplorerDrop(data: IDragAndDropData, target: ExplorerItem, originalEvent: DragEvent): Promise<void> {
private handleExplorerDrop(data: IDragAndDropData, target: ExplorerItem): Promise<void> {
const elementsData = (data as ElementsDragAndDropData<ExplorerItem>).elements;
const items = distinctParents(elementsData, s => s.resource);
const isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh);
let confirmPromise: Promise<IConfirmationResult>;
// Handle confirm setting
const confirmDragAndDrop = !isCopy && this.configurationService.getValue<boolean>(FileDragAndDrop.CONFIRM_DND_SETTING_KEY);
const confirmDragAndDrop = !this.isCopy && this.configurationService.getValue<boolean>(FileDragAndDrop.CONFIRM_DND_SETTING_KEY);
if (confirmDragAndDrop) {
confirmPromise = this.dialogService.confirm({
message: items.length > 1 && items.every(s => s.isRoot) ? localize('confirmRootsMove', "Are you sure you want to change the order of multiple root folders in your workspace?")
......@@ -748,7 +749,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
return updateConfirmSettingsPromise.then(() => {
if (res.confirmed) {
const rootDropPromise = this.doHandleRootDrop(items.filter(s => s.isRoot), target);
return Promise.all(items.filter(s => !s.isRoot).map(source => this.doHandleExplorerDrop(source, target, isCopy)).concat(rootDropPromise)).then(() => undefined);
return Promise.all(items.filter(s => !s.isRoot).map(source => this.doHandleExplorerDrop(source, target, this.isCopy)).concat(rootDropPromise)).then(() => undefined);
}
return Promise.resolve(undefined);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册