From d17e66bf1408d7e3cf947ca5e2aa32e2eb975af4 Mon Sep 17 00:00:00 2001 From: vigorouscoding Date: Wed, 28 Feb 2024 16:06:35 +0100 Subject: [PATCH] UX: Show notification upon page load if currently a deployment import is active --- .../core/function/StructrEnvFunction.java | 2 ++ .../structr/web/maintenance/DeployCommand.java | 2 +- .../src/main/resources/structr/js/init.js | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/structr-base/src/main/java/org/structr/core/function/StructrEnvFunction.java b/structr-base/src/main/java/org/structr/core/function/StructrEnvFunction.java index ed0b0da432..f991be69e8 100644 --- a/structr-base/src/main/java/org/structr/core/function/StructrEnvFunction.java +++ b/structr-base/src/main/java/org/structr/core/function/StructrEnvFunction.java @@ -30,6 +30,7 @@ import org.structr.core.property.StringProperty; import org.structr.core.script.polyglot.context.ContextFactory; import org.structr.schema.action.ActionContext; +import org.structr.web.maintenance.DeployCommand; public class StructrEnvFunction extends AdvancedScriptingFunction { @@ -95,6 +96,7 @@ public static GraphObjectMap getStructrEnv() throws FrameworkException { info.setProperty(new StringProperty("maintenanceModeActive"), Settings.MaintenanceModeEnabled.getValue()); info.setProperty(new StringProperty("validUUIDv4Regex"), Settings.getValidUUIDRegexString()); info.setProperty(new StringProperty("legacyRequestParameters"), Settings.RequestParameterLegacyMode.getValue()); + info.setProperty(new StringProperty("isDeploymentActive"), DeployCommand.isDeploymentActive()); info.setProperty(new StringProperty("debuggerActive"), Settings.ScriptingDebugger.getValue()); diff --git a/structr-base/src/main/java/org/structr/web/maintenance/DeployCommand.java b/structr-base/src/main/java/org/structr/web/maintenance/DeployCommand.java index 367f06fe47..78308baefa 100644 --- a/structr-base/src/main/java/org/structr/web/maintenance/DeployCommand.java +++ b/structr-base/src/main/java/org/structr/web/maintenance/DeployCommand.java @@ -143,7 +143,7 @@ public void execute(final Map parameters) throws FrameworkExcept final String mode = (String) parameters.get("mode"); - if (Boolean.FALSE.equals(deploymentActive.get())) { + if (Boolean.FALSE.equals(isDeploymentActive())) { try { diff --git a/structr-base/src/main/resources/structr/js/init.js b/structr-base/src/main/resources/structr/js/init.js index 0ae0f97b83..dbcf3cae56 100644 --- a/structr-base/src/main/resources/structr/js/init.js +++ b/structr-base/src/main/resources/structr/js/init.js @@ -856,6 +856,14 @@ let Structr = { } } + let deploymentActive = (envInfo.isDeploymentActive ?? false); + if (deploymentActive === true) { + Structr.handleGenericMessage({ + type: 'DEPLOYMENT_IMPORT_STATUS', + subtype: 'ALREADY_RUNNING' + }); + } + $('#header .structr-instance-name').text(envInfo.instanceName); $('#header .structr-instance-stage').text(envInfo.instanceStage); @@ -1401,6 +1409,14 @@ let Structr = { new InfoMessage().title(`${type} Progress`).uniqueClass(messageCssClass).text(text).requiresConfirmation().updatesText().show(); + } else if (data.subtype === 'ALREADY_RUNNING') { + + let text = `${type} was already running before page was loaded

+ Please wait until the import process is finished. Any changes made during a deployment might get lost or conflict with the deployment! This message will be updated during the deployment process.
    + `; + + new InfoMessage().title(`${type} Progress`).uniqueClass(messageCssClass).text(text).requiresConfirmation().updatesText().show(); + } else if (data.subtype === 'PROGRESS') { new InfoMessage().title(`${type} Progress`).uniqueClass(messageCssClass).text(`
  1. ${data.message}
  2. `).requiresConfirmation().appendsText('.message-steps').show();