Skip to content

Commit

Permalink
Improved Upload Command (#13775)
Browse files Browse the repository at this point in the history
- if nothing is selected uploads to the workspace root
- if a folder is selected uploads to that folder
- if a file is selected uploads to the parent folder

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
  • Loading branch information
jonah-iden authored Jun 6, 2024
1 parent a6fb882 commit a3c8906
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class FileSystemFrontendContribution implements FrontendApplicationContri
commands.registerCommand(FileSystemCommands.UPLOAD, {
isEnabled: (...args: unknown[]) => {
const selection = this.getSelection(...args);
return !!selection && this.canUpload(selection);
return !!selection && !environment.electron.is();
},
isVisible: () => !environment.electron.is(),
execute: (...args: unknown[]) => {
Expand All @@ -162,14 +162,10 @@ export class FileSystemFrontendContribution implements FrontendApplicationContri
});
}

protected canUpload({ fileStat }: FileSelection): boolean {
return !environment.electron.is() && fileStat.isDirectory;
}

protected async upload(selection: FileSelection): Promise<FileUploadResult | undefined> {
try {
const source = TreeWidgetSelection.getSource(this.selectionService.selection);
const fileUploadResult = await this.uploadService.upload(selection.fileStat.resource);
const fileUploadResult = await this.uploadService.upload(selection.fileStat.isDirectory ? selection.fileStat.resource : selection.fileStat.resource.parent);
if (ExpandableTreeNode.is(selection) && source) {
await source.model.expandNode(selection);
}
Expand Down

0 comments on commit a3c8906

Please sign in to comment.