Merge pull request #5177 from gitbutlerapp/branch

fix: New branch dropzone only accepts uncommited files
This commit is contained in:
Esteban Vega 2024-10-16 19:50:42 +02:00 committed by GitHub
commit 08b29a7176
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -15,8 +15,9 @@
const branchController = getContext(BranchController);
function accepts(data: any) {
if (data instanceof DraggableFile) return !data.files.some((f) => f.locked);
if (data instanceof DraggableHunk) return !data.hunk.locked;
if (data instanceof DraggableFile)
return !(data.isCommitted || data.files.some((f) => f.locked));
if (data instanceof DraggableHunk) return !(data.isCommitted || data.hunk.locked);
return false;
}

View File

@ -21,6 +21,10 @@ export class DraggableHunk {
public readonly lockedTo: HunkLock[],
public readonly commitId: string | undefined
) {}
get isCommitted(): boolean {
return !!this.commitId;
}
}
export class DraggableFile {
@ -35,6 +39,10 @@ export class DraggableFile {
if (this.selection && this.selection.length > 0) return this.selection;
return [this.file];
}
get isCommitted(): boolean {
return !!this.commit;
}
}
export class DraggableCommit {