diff --git a/client/src/components/ContentNavigator/ContentDataProvider.ts b/client/src/components/ContentNavigator/ContentDataProvider.ts index 69928b20a..49260e631 100644 --- a/client/src/components/ContentNavigator/ContentDataProvider.ts +++ b/client/src/components/ContentNavigator/ContentDataProvider.ts @@ -358,7 +358,7 @@ class ContentDataProvider errorMessage: string, ): Promise { if (!newUri) { - window.showErrorMessage(errorMessage); + await window.showErrorMessage(errorMessage); return; } diff --git a/client/src/components/ContentNavigator/ContentModel.ts b/client/src/components/ContentNavigator/ContentModel.ts index 2c63ecbd8..1146537ba 100644 --- a/client/src/components/ContentNavigator/ContentModel.ts +++ b/client/src/components/ContentNavigator/ContentModel.ts @@ -231,7 +231,6 @@ export class ContentModel { } const fileLink: Link | null = getLink(createdResource.links, "GET", "self"); - const memberAdded = await this.addMember( fileLink?.uri, getLink(item.links, "POST", "addMember")?.uri, @@ -240,7 +239,6 @@ export class ContentModel { contentType, }, ); - if (!memberAdded) { return; } diff --git a/client/src/components/ContentNavigator/index.ts b/client/src/components/ContentNavigator/index.ts index 3edd16611..09126b743 100644 --- a/client/src/components/ContentNavigator/index.ts +++ b/client/src/components/ContentNavigator/index.ts @@ -12,6 +12,8 @@ import { workspace, } from "vscode"; +import { createWriteStream } from "fs"; + import { profileConfig } from "../../commands/profile"; import { SubscriptionProvider } from "../SubscriptionProvider"; import { ConnectionType } from "../profile"; @@ -19,7 +21,11 @@ import ContentDataProvider from "./ContentDataProvider"; import { ContentModel } from "./ContentModel"; import { Messages } from "./const"; import { ContentItem } from "./types"; -import { isContainer as getIsContainer, isItemInRecycleBin } from "./utils"; +import { + isContainer as getIsContainer, + getUri, + isItemInRecycleBin, +} from "./utils"; const fileValidator = (value: string): string | null => /^([^/<>;\\{}?#]+)\.\w+$/.test( @@ -273,31 +279,27 @@ class ContentNavigator implements SubscriptionProvider { ), commands.registerCommand( "SAS.downloadResource", - async (item: ContentItem) => { - const uri = await window.showSaveDialog({}); + async (resource: ContentItem) => { + const uri = await window.showSaveDialog({ + defaultUri: Uri.file(resource.name), + }); if (!uri) { return; } - this.treeViewSelections(item).forEach( - async (resource: ContentItem) => { - console.log("resource", resource); - console.log("uri", uri); + await window.withProgress( + { + location: ProgressLocation.Notification, + title: l10n.t("Downloading file..."), + }, + async () => { + const stream = createWriteStream(uri.fsPath); + stream.write( + await this.contentDataProvider.readFile(getUri(resource)), + ); + stream.end(); }, ); - // const uri = await window.showSaveDialog({ - // defaultUri: Uri.file( - // `${item.library}.${item.name}.csv`.toLocaleLowerCase(), - // ), - // }); - // if (!uri) { - // return; - // } - // const stream = createWriteStream(uri.fsPath); - // await this.libraryDataProvider.writeTableContentsToStream( - // stream, - // item, - // ); }, ), commands.registerCommand( @@ -318,7 +320,7 @@ class ContentNavigator implements SubscriptionProvider { title: l10n.t("Uploading files..."), }, async () => { - this.contentDataProvider.uploadUrisToTarget(uris, resource); + await this.contentDataProvider.uploadUrisToTarget(uris, resource); }, ); }, diff --git a/client/src/components/ContentNavigator/utils.ts b/client/src/components/ContentNavigator/utils.ts index f7c1ba6e2..e486bbbe4 100644 --- a/client/src/components/ContentNavigator/utils.ts +++ b/client/src/components/ContentNavigator/utils.ts @@ -81,6 +81,10 @@ export const resourceType = (item: ContentItem): string | undefined => { actions.push("convertNotebookToFlow"); } + if (!isContainer(item)) { + actions.push("allowDownload"); + } + if (actions.length === 0) { return; } diff --git a/package.json b/package.json index c0c0b3240..884600985 100644 --- a/package.json +++ b/package.json @@ -682,7 +682,7 @@ }, { "command": "SAS.downloadResource", - "when": "(viewItem =~ /update/ || viewItem =~ /createChild/) && view == contentdataprovider", + "when": "viewItem =~ /update/ && viewItem =~ /allowDownload/ && view == contentdataprovider", "group": "uploaddownloadgroup@0" }, {