Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/helpers/requestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class RequestHelper {
}
} catch (err) {
console.log(err);
throw err;
}
}

Expand Down Expand Up @@ -133,6 +134,7 @@ export class RequestHelper {
}
} catch (err) {
console.log(err);
throw err;
}
}
}
Expand Down
74 changes: 40 additions & 34 deletions src/helpers/webResourceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,43 +417,49 @@ export class WebResourceHelper {
title: `Uploading ${fileName}`,
},
async (progress, token) => {
let id: string = "";
let wrReturn: IWebResource | undefined;
token.onCancellationRequested(() => {
console.log("User canceled the long running operation");
return;
});
progress.report({ increment: 0, message: "Uploading..." });
if (resc && resc["@_Id"]) {
const wr: IWebResource = {
content: encodeToBase64(readFileSync(fullPath)),
};
await this.dvHelper.updateWebResourceContent(resc["@_Id"], wr);
id = resc["@_Id"];
wrReturn = wr;
wrReturn.name = resc["@_dvFilePath"];
wrReturn.displayname = resc["@_dvDisplayName"];
wrReturn.webresourceid = resc["@_Id"];
} else {
const wr = await this.webResourceCreateWizard(fullPath);
if (wr) {
const solutionUniqueName = wr.description!;
wr.description = null;
let wrId = await this.dvHelper.createWebResource(wr);
if (wrId) {
wrId = extractGuid(wrId)!;
this.dvHelper.addWRToSolution(solutionUniqueName, wrId);
wr.webresourceid = wrId;
id = wrId;
wrReturn = wr;
try {
let id: string = "";
let wrReturn: IWebResource | undefined;
token.onCancellationRequested(() => {
console.log("User canceled the long running operation");
return;
});
progress.report({ increment: 0, message: "Uploading..." });
if (resc && resc["@_Id"]) {
const wr: IWebResource = {
content: encodeToBase64(readFileSync(fullPath)),
};
await this.dvHelper.updateWebResourceContent(resc["@_Id"], wr);
id = resc["@_Id"];
wrReturn = wr;
wrReturn.name = resc["@_dvFilePath"];
wrReturn.displayname = resc["@_dvDisplayName"];
wrReturn.webresourceid = resc["@_Id"];
} else {
const wr = await this.webResourceCreateWizard(fullPath);
if (wr) {
const solutionUniqueName = wr.description!;
wr.description = null;
let wrId = await this.dvHelper.createWebResource(wr);
if (wrId) {
wrId = extractGuid(wrId)!;
this.dvHelper.addWRToSolution(solutionUniqueName, wrId);
wr.webresourceid = wrId;
id = wrId;
wrReturn = wr;
}
}
}
progress.report({ increment: 50, message: "Publishing..." });
await this.dvHelper.publishWebResource(id);
progress.report({ increment: 100 });
vscode.window.showInformationMessage(`${fileName} uploaded.`);
return wrReturn;
} catch (error) {
vscode.window.showErrorMessage(ErrorMessages.wrUploadError);
console.error("Error uploading web resource:", error);
throw error;
}
progress.report({ increment: 50, message: "Publishing..." });
await this.dvHelper.publishWebResource(id);
progress.report({ increment: 100 });
vscode.window.showInformationMessage(`${fileName} uploaded.`);
return wrReturn;
},
);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/ErrorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class ErrorMessages {
public static jsFileNameRequired: string = "JavaScript filename is required.";
public static webpackNamespaceRequired: string = "Namespace for Webpack is required.";
public static wrCompareError: string = "The selected file is either not linked to a web resources or it does not exists in Dataverse.";
public static wrUploadError: string = "Failed to upload web resource. Please check your connection and try again.";
public static drbConnectionError: string = "Connect to an environment before trying to load Dataverse REST Builder.";
public static invalidLoginType: string = "Invalid Login Type.";
}