Skip to content

Commit

Permalink
[fixup] disable hot-reload if development mode disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nxmatic committed Jul 24, 2024
1 parent 7b64089 commit ac401c5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/popup/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ a.reindex-page {
font-size: 0.75em;
}

#hot-reload-message {
display: none;
text-align: center;
font-size: 0.75em;
text-decoration: underline;
}

#log-into-studio {
cursor: pointer;
}
Expand Down
3 changes: 3 additions & 0 deletions src/popup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<a class="button main-page" id="hot-reload-button">Hot Reload</a>
</div>
</div>
<div class="nxrow" id="hot-reload-message">
<a id="enable-development-mode" target="_blank">Development Mode Disabled</a>
</div>
<div class="nxrow" id="designer-livepreview">
<div class="designer-livepreview">
<a class="button main-page" id="designer-live-preview-button">Designer Live Preview</a>
Expand Down
25 changes: 23 additions & 2 deletions src/popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) {
resolve();
});

const studioPackageFound = (connectUrl, packageName) => {
const studioPackageFound = (developmentMode, connectUrl, packageName) => {
$('div.studio-package-name').text(packageName);
worker.desktopNotifier.cancel('no_studio_project');
const toogleDesignerLivePreviewButton = (isEnabled) => {
Expand Down Expand Up @@ -209,13 +209,30 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) {
$('#studio').click(() => {
worker.tabNavigationHandler.loadNewExtensionTab(packageLocation);
});
if (!developmentMode) {
$('#hot-reload-button').css('filter', 'invert(1)');
$('#hot-reload-message').css('display', 'block');
} else {
$('#hot-reload-message').css('display', 'none');
$('#hot-reload-message a').text('');
}
$('#hot-reload-button').click(() => {
startLoadingHR()
.then(() => worker.studioHotReloader.reload())
.then(() => stopLoading())
.then(() => worker.tabNavigationHandler.reloadServerTab())
.catch((cause) => stopLoading(cause));
});
$('#hot-reload-message a').click(() => {
Swal.fire({
title: 'Info!',
html: `You are not in development mode,<br/>
you can't hot-reload studio package.<br/><br/>
Please add the following parameters to your <code>nuxeo.conf</code> file:<br/>
<code>org.nuxeo.dev=true</code><br/>
<code>org.nuxeo.runtime.reload_strategy=standby</code>`
});
});

$('#force-hot-reload-button').click(() => {
hideDependencyError()
Expand Down Expand Up @@ -557,7 +574,11 @@ function loadPage(worker, options = { forceForbiddenDomains: false }) {
});
}
if (registeredPackage) {
studioPackageFound(new URL(connectLocation), registeredPackage);
studioPackageFound(
developmentMode,
new URL(connectLocation),
registeredPackage
);
} else {
noStudioPackageFound();
}
Expand Down

0 comments on commit ac401c5

Please sign in to comment.