Merge branch 'main' into fix-authenticate-read

This commit is contained in:
Susmitha Girumala authored and GitHub committed 2021-04-14 16:08:27 -04:00
commit 55e3284e3f
5 files changed
+33 -21

No files matched your search

@@ -1,5 +1,5 @@
create-success: Created succesfully.
save-success: Saved succesfully.
create-success: Created successfully.
save-success: Saved successfully.
delete-success: Deleted successfully.
add-success: Added successfully.
remove-success: Removed successfully.
+2 -1
View File
@@ -63,9 +63,10 @@ export default class OriginService extends Service {
typeof origin === 'string'
);
try {
// Silently drop trailing slashes if present.
// Trim whitespaces and silently drop trailing slashes if present.
// This is important since API paths that will be appended to the origin
// will include preceeding slashes already.
origin = origin.trim();
origin = origin.replace(/\/*$/, '');
this.adapter.host = origin;
this.rendererOrigin = origin;
+17 -17
View File
@@ -90,7 +90,7 @@ const downloadAndInstallUpdate = async (version) => {
* TODO: download progress in dialog
**/
module.exports = {
run: async ({ suppressNoUpdatePrompt }) => {
run: async ({ suppressNoUpdatePrompt } = {}) => {
let latestVersion;
if (debug) {
latestVersion = process.env.APP_UPDATER_LATEST_VERSION_TAG;
@@ -104,7 +104,8 @@ module.exports = {
}
// Update not available - do nothing
if (!suppressNoUpdatePrompt && semver.lte(latestVersion, currentVersion)) {
if (semver.lte(latestVersion, currentVersion)) {
if (suppressNoUpdatePrompt) return;
const dialogOpts = {
type: 'info',
icon: null,
@@ -112,21 +113,20 @@ module.exports = {
};
dialog.showMessageBox(dialogOpts);
return;
} else {
// Update is available - prompt for download
const dialogOpts = {
type: 'info',
buttons: ['Download', 'Later'],
icon: null,
detail: 'A new version is available for download',
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) {
downloadAndInstallUpdate(latestVersion);
}
});
}
// Update is available - prompt for download
const dialogOpts = {
type: 'info',
buttons: ['Download', 'Later'],
icon: null,
detail: 'A new version is available for download',
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) {
downloadAndInstallUpdate(latestVersion);
}
});
},
};
+1 -1
View File
@@ -53,7 +53,7 @@ module.exports = {
const jsonData = jsonify(errorStream);
if (jsonData) {
const error = jsonData.api_error || jsonData.error;
reject(new Error(error));
reject(new Error(error.message));
}
});
});
@@ -35,4 +35,15 @@ module('Unit | Service | origin', function (hooks) {
assert.equal(service.rendererOrigin, window.location.origin);
assert.equal(service.adapter.host, window.location.origin);
});
test('trim spaces from origin on setOrigin', async function (assert) {
assert.expect(4);
sinon.stub(ipcService, 'invoke');
await service.setOrigin(` ${window.location.origin}/ `);
assert.equal(service.rendererOrigin, window.location.origin);
assert.equal(service.adapter.host, window.location.origin);
await service.setOrigin(` ${window.location.origin} `);
assert.equal(service.rendererOrigin, window.location.origin);
assert.equal(service.adapter.host, window.location.origin);
});
});