Skip to content

Commit

Permalink
BDE-226 reviewed tab activation
Browse files Browse the repository at this point in the history
  • Loading branch information
nxmatic committed Mar 15, 2024
1 parent da8e1d7 commit ceb3f1c
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 266 deletions.
10 changes: 5 additions & 5 deletions src/about/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ limitations under the License.
import $ from 'jquery';
import ServiceWorkerBridge from '../service-worker-bridge';

const serverLocator = new ServiceWorkerBridge().serverLocatoor;
const tabActivator = new ServiceWorkerBridge().serverLocatoor;

$(() => {
const date = new Date().getFullYear();
$('#copyright').append(`${date} Nuxeo`);
$('#apache').click(() => {
serverLocator.loadNewExtensionTab(
tabActivator.loadNewExtensionTab(
'http://www.apache.org/licenses/LICENSE-2.0'
);
});
$('#feedback').click(() => {
serverLocator.loadNewExtensionTab(
tabActivator.loadNewExtensionTab(
'https://portal.prodpad.com/40c295d6-739d-11e7-9e52-06df22ffaf6f'
);
});
$('#apache').click(() => {
serverLocator.loadNewExtensionTab(
tabActivator.loadNewExtensionTab(
'http://www.apache.org/licenses/LICENSE-2.0'
);
});
$('#feedback').click(() => {
serverLocator.loadNewExtensionTab(
tabActivator.loadNewExtensionTab(
'https://portal.prodpad.com/40c295d6-739d-11e7-9e52-06df22ffaf6f'
);
});
Expand Down
1 change: 1 addition & 0 deletions src/main/declarative-net-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
function hashCode(s) {
let hash = 0;
if (s.length === 0) return hash;
// eslint-disable-next-line no-plusplus
for (let i = 0; i < s.length; i++) {
const char = s.charCodeAt(i);
// eslint-disable-next-line no-bitwise
Expand Down
2 changes: 1 addition & 1 deletion src/main/document-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DocumentBrowser {
}
return `nxdoc/default/${uid}/view_documents`;
}
this.serverLocator.loadNewExtensionTab(pathOf(doc.uid), true);
this.tabActivator.loadNewExtensionTab(pathOf(doc.uid), true);
})
.catch((error) => {
console.log(error);
Expand Down
6 changes: 3 additions & 3 deletions src/main/server-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class ServerConnector {
iconUrl: '../images/nuxeo-128.png',
requireInteraction: false,
})
.then(() => this.worker.serverLocator.reloadServerTab())
.then(() => this.worker.tabActivator.reloadServerTab())
.then(() => this.worker.desktopNotifier.cancel('reload'))
.then(() => resolve());
});
Expand All @@ -217,7 +217,7 @@ class ServerConnector {
});

const restartUrl = `${this.rootUrl}/site/connectClient/uninstall/restart`;
return this.worker.serverLocator.disableExtension()
return this.worker.tabActivator.disableExtension()
.then(this.withNuxeo)
.then((nuxeo) => nuxeo
._http({
Expand All @@ -238,7 +238,7 @@ class ServerConnector {
})
.then(() => {
setTimeout(() => {
this.worker.serverLocator.reloadTab();
this.worker.tabActivator.reloadTab();
}, 5000);
})
.catch((e) => {
Expand Down
248 changes: 0 additions & 248 deletions src/main/server-locator.js

This file was deleted.

9 changes: 5 additions & 4 deletions src/main/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import JSONHighlighter from './json-highlighter';
import RepositoryIndexer from './repository-indexer';
import RuntimeBuildComponent from './runtime-build-info';
import ServerConnector from './server-connector';
import ServerLocator from './server-locator';
import TabActivator from './tab-activator';
import StudioHotReloader from './studio-hot-reloader';

const DeclarativeNetEngine = DeclararactiveNetCompoments.DeclarativeNetEngine;
Expand Down Expand Up @@ -76,7 +76,8 @@ class ServiceWorkerMessageHandler {

withConnectedWorker(this.worker)
.then(handleRequest)
.then(sendResponse);
.then(sendResponse)
.catch((error) => console.error(`Caught error while handling ${JSON.stringify(request)}: ${error}`));

return true; // This is necessary to indicate that you will send a response asynchronously
}
Expand All @@ -97,7 +98,7 @@ class ServiceWorker {
this.desktopNotifier = new DesktopNotifier(this);
this.jsonHighlighter = new JSONHighlighter(this);
this.repositoryIndexer = new RepositoryIndexer(this);
this.serverLocator = new ServerLocator(this);
this.tabActivator = new TabActivator(this);
this.serverConnector = new ServerConnector(this);
this.studioHotReloader = new StudioHotReloader(this);
this.documentBrowser = new DocumentBrowser(this);
Expand All @@ -115,7 +116,7 @@ class ServiceWorker {
chrome.runtime.onMessage.addListener(messageHandle);
cleanupFunctions.push(() => chrome.runtime.onMessage.removeListener(messageHandle));

cleanupFunctions.push(this.serverLocator.listenToChromeEvents());
cleanupFunctions.push(this.tabActivator.listenToChromeEvents());
cleanupFunctions.push(this.documentBrowser.listenToChromeEvents());
cleanupFunctions.push(() => this.designerLivePreview.disable());

Expand Down
Loading

0 comments on commit ceb3f1c

Please sign in to comment.