Skip to content

Commit

Permalink
implement better windows upload support
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Dover authored and Scott Dover committed Oct 26, 2023
1 parent 22dadbd commit 6c39b07
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 21 deletions.
61 changes: 41 additions & 20 deletions client/src/components/ContentNavigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ConfigurationChangeEvent,
Disposable,
ExtensionContext,
OpenDialogOptions,
ProgressLocation,
Uri,
commands,
Expand Down Expand Up @@ -337,28 +338,23 @@ class ContentNavigator implements SubscriptionProvider {
);
},
),
// Below, we have three commands to upload files. Mac is currently the only
// platform that supports uploading both files and folders. So, for any platform
// that isn't Mac, we list a distinct upload file(s) or upload folder(s) command.
// See the `OpenDialogOptions` interface for more information.
commands.registerCommand(
"SAS.uploadResource",
async (resource: ContentItem) => {
const uris: Uri[] = await window.showOpenDialog({
canSelectFolders: true,
canSelectMany: true,
canSelectFiles: true,
});
if (!uris) {
return;
}

await window.withProgress(
{
location: ProgressLocation.Notification,
title: l10n.t("Uploading files..."),
},
async () => {
await this.contentDataProvider.uploadUrisToTarget(uris, resource);
},
);
},
async (resource: ContentItem) => this.uploadResource(resource),
),
commands.registerCommand(
"SAS.uploadFileResource",
async (resource: ContentItem) =>
this.uploadResource(resource, { canSelectFolders: false }),
),
commands.registerCommand(
"SAS.uploadFolderResource",
async (resource: ContentItem) =>
this.uploadResource(resource, { canSelectFiles: false }),
),
workspace.onDidChangeConfiguration(
async (event: ConfigurationChangeEvent) => {
Expand All @@ -373,6 +369,31 @@ class ContentNavigator implements SubscriptionProvider {
];
}

private async uploadResource(
resource: ContentItem,
openDialogOptions: Partial<OpenDialogOptions> = {},
) {
const uris: Uri[] = await window.showOpenDialog({
canSelectFolders: true,
canSelectMany: true,
canSelectFiles: true,
...openDialogOptions,
});
if (!uris) {
return;
}

await window.withProgress(
{
location: ProgressLocation.Notification,
title: l10n.t("Uploading files..."),
},
async () => {
await this.contentDataProvider.uploadUrisToTarget(uris, resource);
},
);
}

private viyaEndpoint(): string {
const activeProfile = profileConfig.getProfileByName(
profileConfig.getActiveProfile(),
Expand Down
30 changes: 29 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,16 @@
"title": "%commands.SAS.upload%",
"category": "SAS"
},
{
"command": "SAS.uploadFileResource",
"title": "%commands.SAS.uploadFiles%",
"category": "SAS"
},
{
"command": "SAS.uploadFolderResource",
"title": "%commands.SAS.uploadFolders%",
"category": "SAS"
},
{
"command": "SAS.saveHTML",
"title": "%commands.SAS.download%",
Expand Down Expand Up @@ -705,7 +715,17 @@
},
{
"command": "SAS.uploadResource",
"when": "(viewItem =~ /update/ || viewItem =~ /createChild/) && view == contentdataprovider && !listMultiSelection",
"when": "(viewItem =~ /update/ || viewItem =~ /createChild/) && view == contentdataprovider && !listMultiSelection && workspacePlatform == mac",
"group": "uploaddownloadgroup@1"
},
{
"command": "SAS.uploadFileResource",
"when": "(viewItem =~ /update/ || viewItem =~ /createChild/) && view == contentdataprovider && !listMultiSelection && workspacePlatform != mac",
"group": "uploaddownloadgroup@1"
},
{
"command": "SAS.uploadFolderResource",
"when": "(viewItem =~ /update/ || viewItem =~ /createChild/) && view == contentdataprovider && !listMultiSelection && workspacePlatform != mac",
"group": "uploaddownloadgroup@1"
}
],
Expand Down Expand Up @@ -816,6 +836,14 @@
"when": "false",
"command": "SAS.uploadResource"
},
{
"when": "false",
"command": "SAS.uploadFileResource"
},
{
"when": "false",
"command": "SAS.uploadFolderResource"
},
{
"when": "false",
"command": "SAS.saveHTML"
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"commands.SAS.switchProfile": "Switch Current Connection Profile",
"commands.SAS.updateProfile": "Update Connection Profile",
"commands.SAS.upload": "Upload",
"commands.SAS.uploadFiles": "Upload File(s)",
"commands.SAS.uploadFolders": "Upload Folder(s)",
"configuration.SAS.connectionProfiles": "Define the connection profiles to connect to SAS servers. If you define more than one profile, you can switch between them.",
"configuration.SAS.connectionProfiles.activeProfile": "Active SAS Connection Profile",
"configuration.SAS.connectionProfiles.profiles": "SAS Connection Profiles",
Expand Down

0 comments on commit 6c39b07

Please sign in to comment.