Skip to content

Commit

Permalink
fix: fix remaining issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Dover authored and Scott Dover committed Nov 14, 2024
1 parent 5f8b69a commit 4e5c4d8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
3 changes: 2 additions & 1 deletion client/src/components/ContentNavigator/ContentModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ export class ContentModel {
let number = 1;
let newFileName;
do {
newFileName = l10n.t("{basename}_Copy{number}.flw", {
newFileName = l10n.t("{basename}_Copy{number}{ext}", {
basename,
number: number++,
ext,
});
} while (usedFlowNames[newFileName]);

Expand Down
25 changes: 17 additions & 8 deletions client/src/components/ContentNavigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ const folderValidator = (

class ContentNavigator implements SubscriptionProvider {
private contentDataProvider: ContentDataProvider;
private contentModel: ContentModel;
private sourceType: ContentNavigatorConfig["sourceType"];
private treeIdentifier: ContentNavigatorConfig["treeIdentifier"];

get contentModel() {
return new ContentModel(this.contentAdapterForConnectionType());
}

constructor(context: ExtensionContext, config: ContentNavigatorConfig) {
this.sourceType = config.sourceType;
this.treeIdentifier = config.treeIdentifier;
this.contentModel = new ContentModel(
this.contentAdapterForConnectionType(),
);
this.contentDataProvider = new ContentDataProvider(
this.contentModel,
context.extensionUri,
Expand Down Expand Up @@ -290,6 +290,7 @@ class ContentNavigator implements SubscriptionProvider {
commands.registerCommand(
`${SAS}.convertNotebookToFlow`,
async (resource: ContentItem | Uri) => {
await this.contentModel.connect(this.viyaEndpoint());
const notebookToFlowConverter = new NotebookToFlowConverter(
resource,
this.contentModel,
Expand Down Expand Up @@ -400,7 +401,11 @@ class ContentNavigator implements SubscriptionProvider {
if (event.affectsConfiguration("SAS.connectionProfiles")) {
const endpoint = this.viyaEndpoint();
this.collapseAllContent();
this.contentDataProvider.useModel(this.contentModel);
const contentModel = new ContentModel(
this.contentAdapterForConnectionType(),
);
this.contentDataProvider.useModel(contentModel);
this.contentModel = contentModel;
if (endpoint) {
await this.contentDataProvider.connect(endpoint);
} else {
Expand All @@ -412,10 +417,14 @@ class ContentNavigator implements SubscriptionProvider {
];
}

private collapseAllContent() {
commands.executeCommand(
`workbench.actions.treeView.${this.treeIdentifier}.collapseAll`,
private async collapseAllContent() {
const collapeAllCmd = `workbench.actions.treeView.${this.treeIdentifier}.collapseAll`;
const commandExists = (await commands.getCommands()).find(
(c) => c === collapeAllCmd,
);
if (commandExists) {
commands.executeCommand(collapeAllCmd);
}
}

private async uploadResource(
Expand Down
13 changes: 9 additions & 4 deletions client/src/connection/rest/RestSASServerAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class RestSASServerAdapter implements ContentAdapter {
apply: async function (target, _this, argList) {
try {
return await target(...argList);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
// If we get any error, lets reconnect and try again. If we fail a second time,
// then we can assume it's a "real" error
Expand Down Expand Up @@ -136,6 +137,7 @@ class RestSASServerAdapter implements ContentAdapter {
});

return this.filePropertiesToContentItem(response.data);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return;
}
Expand Down Expand Up @@ -167,6 +169,7 @@ class RestSASServerAdapter implements ContentAdapter {
}

return contentItem;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return;
}
Expand All @@ -182,7 +185,8 @@ class RestSASServerAdapter implements ContentAdapter {
});
delete this.fileMetadataMap[filePath];
return true;
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return false;
}
}
Expand Down Expand Up @@ -253,7 +257,6 @@ class RestSASServerAdapter implements ContentAdapter {
}

private async getContentOfItemAtPath(path: string) {
await this.setup();
const response = await this.fileSystemApi.getFileContentFromSystem(
{
sessionId: this.sessionId,
Expand Down Expand Up @@ -488,7 +491,8 @@ class RestSASServerAdapter implements ContentAdapter {
);
try {
return decodeURIComponent(uriWithoutPrefix);
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return uriWithoutPrefix;
}
}
Expand All @@ -513,7 +517,8 @@ class RestSASServerAdapter implements ContentAdapter {
fileOrDirectoryPath: path,
});
return this.updateFileMetadata(path, response);
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
// Intentionally blank
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/Features/sasCodeEditing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 7
---

# SAS Code Editing Features
Expand Down
2 changes: 1 addition & 1 deletion website/docs/Features/sasNotebook.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 8
---

# SAS Notebook
Expand Down

0 comments on commit 4e5c4d8

Please sign in to comment.