diff --git a/src/main/server-connector.js b/src/main/server-connector.js index 0517ce3..65f1564 100644 --- a/src/main/server-connector.js +++ b/src/main/server-connector.js @@ -150,7 +150,7 @@ This extension is only compatible with Nuxeo Platform servers. this.runtimeInfo = undefined; this.serverUrl = undefined; const notification = this.notifyError(cause); - throw this.connectionErrorOf(`Cannot establish connection with ${serverUrl}`, notification); + return Promise.reject(this.connectionErrorOf(`Cannot establish connection with ${serverUrl}`, notification)); })); } @@ -257,7 +257,7 @@ This extension is only compatible with Nuxeo Platform servers. .asTabInfo() .then((tabInfo) => { const serverUrl = this.serverUrlOf(tabInfo.url); - const attemptReconnect = () => this.connect(serverUrl, tabInfo, connectionOptions).then(() => this.nuxeo); + const attemptConnection = () => this.connect(serverUrl, tabInfo, connectionOptions).then(() => this.nuxeo); const urlEquals = (url1, url2) => url1.protocol === url2.protocol && url1.hostname === url2.hostname && url1.port === url2.port && @@ -269,11 +269,11 @@ This extension is only compatible with Nuxeo Platform servers. .then(() => this.nuxeo) // Connection is valid .catch((error) => { console.error('Failed to refetch the user, connection might be lost.', error); - return attemptReconnect(); + return attemptConnection(); }); } // Not connected or different server, attempt to connect - return attemptReconnect(); + return attemptConnection(); }); } diff --git a/src/popup/index.js b/src/popup/index.js index 775977b..99e4bd1 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -300,12 +300,12 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { // process the page, should split this in multiple functions // eslint-disable-next-line no-unused-vars .then(({ connectUrl, connectCredentials, cookiesGranted }) => { - // bind the fields with the js worker + // bind the fields with the js worker const pendingPromises = []; pendingPromises.push( worker.developmentMode.isEnabled().then((isEnabled) => { - // Assuming isEnabled is already determined + // Assuming isEnabled is already determined const shouldBeReadOnly = !isEnabled; // Toggle class for read-only styling $('.server-main #options').toggleClass( @@ -415,8 +415,8 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { permissions, error ); - // Handle the error appropriately in your extension - // For example, you might want to inform the user that the permissions cannot be modified + // Handle the error appropriately in your extension + // For example, you might want to inform the user that the permissions cannot be modified }); }); }) @@ -565,7 +565,7 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { // eslint-disable-next-line no-shadow .then((registration) => { const { - // eslint-disable-next-line no-shadow, no-unused-vars + // eslint-disable-next-line no-shadow, no-unused-vars serverUrl: serverLocation, connectUrl: connectLocation, connectSubscription, @@ -835,7 +835,7 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { }; $('#restart-button').on('click', () => { - // Function to show confirmation dialog + // Function to show confirmation dialog const confirmRestart = () => Swal.fire({ title: 'Warning!', text: `You have administrator privileges but the server is not in development mode. @@ -878,7 +878,7 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { }) .then((html) => { $('body').html(html); - // If the loaded page has its own scripts, you might need to reinitialize them here + // If the loaded page has its own scripts, you might need to reinitialize them here }) .catch((error) => { console.error('Error loading page:', error); @@ -892,7 +892,7 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { // Handle click events for the radio buttons $(document).on('click', '#reindex-repo, #reindex-nxql', function () { - // Toggle 'active' class for the clicked button + // Toggle 'active' class for the clicked button $(this).toggleClass('active'); // If the other button is active, remove its 'active' class @@ -974,7 +974,7 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { $('#loading-gif').css({ display: 'inline' }); $('#search').css('text-indent', '23px'); if (event.keyCode === 13) { - // prevent submit on enter + // prevent submit on enter event.preventDefault(); } }); @@ -1090,7 +1090,8 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) { return Promise.all(pendingPromises) .then(() => worker) .finally(() => stopLoading()); - }))) + })) + .catch((cause) => stopLoading(cause))) .catch((cause) => stopLoading(cause)); }