diff --git a/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerBluePageDecorator/header.jelly b/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerBluePageDecorator/header.jelly
index 9c7f12d..0c77283 100644
--- a/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerBluePageDecorator/header.jelly
+++ b/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerBluePageDecorator/header.jelly
@@ -1,6 +1,6 @@
-
-
+
${it.getHeaderHtml()}
+
diff --git a/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerSimplePageDecorator/simple-head.jelly b/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerSimplePageDecorator/simple-head.jelly
index de8fbd4..c078fba 100644
--- a/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerSimplePageDecorator/simple-head.jelly
+++ b/src/main/resources/io/jenkins/plugins/thememanager/ThemeManagerSimplePageDecorator/simple-head.jelly
@@ -1,11 +1,12 @@
-
-
-
+
+
+
${it.getHeaderHtml()}
diff --git a/src/main/resources/io/jenkins/plugins/thememanager/header/main.js b/src/main/resources/io/jenkins/plugins/thememanager/header/main.js
index 828ce81..5fc2eee 100644
--- a/src/main/resources/io/jenkins/plugins/thememanager/header/main.js
+++ b/src/main/resources/io/jenkins/plugins/thememanager/header/main.js
@@ -7,17 +7,19 @@
}
window.isSystemRespectingTheme = theme.respect_system_appearance
- const propertiesJson = document.getElementById('theme-manager-properties').text
- const parsedProperties = JSON.parse(propertiesJson);
+ const propertiesJson = document.getElementById('theme-manager-properties')
+ // may not be present, e.g. on BlueOcean where the theme is not marked as BlueOcean compatible
+ if (propertiesJson) {
+ const parsedProperties = JSON.parse(propertiesJson.text);
+ window.getThemeManagerProperty = function (plugin, propertyName) {
+ const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
- window.getThemeManagerProperty = function (plugin, propertyName) {
- const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
-
- let propertyNameNormalised = propertyName
- if (isSystemRespectingTheme) {
- propertyNameNormalised = isDark ? `${propertyName}-dark` : `${propertyName}-light`
+ let propertyNameNormalised = propertyName
+ if (isSystemRespectingTheme) {
+ propertyNameNormalised = isDark ? `${propertyName}-dark` : `${propertyName}-light`
+ }
+ return parsedProperties[`${plugin}:${propertyNameNormalised}`]
}
- return parsedProperties[`${plugin}:${propertyNameNormalised}`]
}
})()
diff --git a/src/test/java/io/jenkins/plugins/thememanager/PageDecoratorTest.java b/src/test/java/io/jenkins/plugins/thememanager/PageDecoratorTest.java
new file mode 100644
index 0000000..6583f1d
--- /dev/null
+++ b/src/test/java/io/jenkins/plugins/thememanager/PageDecoratorTest.java
@@ -0,0 +1,26 @@
+package io.jenkins.plugins.thememanager;
+
+import jenkins.model.Jenkins;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.MockAuthorizationStrategy;
+
+public class PageDecoratorTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
+ @Test
+ public void testJavaScriptLoadsOnSimpleAndRegularPages() throws Exception {
+ j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
+ MockAuthorizationStrategy auth =
+ new MockAuthorizationStrategy().grant(Jenkins.READ).everywhere().to("alice");
+ j.jenkins.setAuthorizationStrategy(auth);
+
+ JenkinsRule.WebClient wc = j.createWebClient();
+
+ wc.login("alice");
+ wc.goTo("");
+ }
+}