Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add live theme switching support #11

Merged
merged 4 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
work/
*.iml
.idea/
light-theme.css
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.3</version>
</extension>
</extensions>
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
26 changes: 14 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.2</version>
<version>4.37</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
<artifactId>material-theme</artifactId>
<version>0.4.2-SNAPSHOT</version>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
<properties>
<revision>0.5.0</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/material-theme-plugin</gitHubRepo>
<revision>0.4.1</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.289.1</jenkins.version>
<jenkins.version>2.336</jenkins.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this plugin replaces most of the older Jenkins icons This needs to be pinned for a family of releases.
0.3.x - Supports pre 2.289.1 (specifically before Add modern icons: build status and weather. ([pull 5065](https://github.com/jenkinsci/jenkins/pull/5065), [pull 5392](https://github.com/jenkinsci/jenkins/pull/5392)))
0.4.x - supports 2.289.1+ (unless there are significant Jenkins Icon changes).
0.5.x - will support the next big UI change (possible jenkinsci/jenkins#6307).

My hope is that by doing this I can fix critical issues for users stuck on older Jenkins versions, whilst also not breaking any new icon changes (although it sounds like it's a bit broken on recent Jenkins releases?).
As such, can you leave this as 2.289.1, so it's the minimum supported version?

That said, if this version update is required to support dependencies (e.g. Theme manager) then can you change the version to 0.5.0 (and then 0.6.x will need to support the next UI change).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's required https://github.com/jenkinsci/theme-manager-plugin/blob/795dd3b2c8d2a7a89a7e86f47c231bd271fc4141/pom.xml#L17

Checkbox structure changed in 2.335 and there was an improvement in 2.336 required for theme manager.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just checking if this version change will cause issues for #13 (just to know the order of merging).
The likelihood is that someone will need to update their PR. I will prefer yours you were first (unless #13 is stuck on an older version).

<java.level>8</java.level>
<tagNameFormat>@{project.version}</tagNameFormat>
<useBeta>true</useBeta>
Expand All @@ -25,8 +28,8 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.222.x</artifactId>
<version>10</version>
<artifactId>bom-2.332.x</artifactId>
<version>1155.v77b_fd92a_26fc</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -37,7 +40,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>theme-manager</artifactId>
<version>0.1</version>
<version>1.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -67,9 +70,9 @@
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

Expand Down Expand Up @@ -98,8 +101,7 @@
<wroFile>${basedir}/src/main/config/wro.xml</wroFile>
<extraConfigFile>${basedir}/src/main/config/wro.properties</extraConfigFile>
<targetGroups>light-theme</targetGroups>
<cssDestinationFolder>${project.build.directory}/../src/main/resources/io/jenkins/plugins/materialtheme/style/</cssDestinationFolder>
<jsDestinationFolder>${project.build.directory}/../src/main/resources/io/jenkins/plugins/materialtheme/script/</jsDestinationFolder>
<cssDestinationFolder>${project.build.directory}/../src/main/webapp/</cssDestinationFolder>
<contextFolder>${basedir}/src/main/webapp/</contextFolder>
<ignoreMissingResources>true</ignoreMissingResources>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.jenkins.plugins.materialtheme;

import io.jenkins.plugins.thememanager.Theme;
import io.jenkins.plugins.thememanager.ThemeManagerFactory;
import java.util.Arrays;

public class AbstractMaterialTheme extends ThemeManagerFactory {

public static final String BASE_CSS = "light-theme.css";
public static final String CUSTOMISED_CSS = "material-theme.css";

@Override
public Theme getTheme() {
return Theme.builder().withCssUrls(
Arrays.asList(toAssetUrl(BASE_CSS), getCssUrl(), toAssetUrl(CUSTOMISED_CSS)))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.jenkins.plugins.materialtheme;

import io.jenkins.plugins.thememanager.ThemeManagerFactoryDescriptor;

public abstract class AbstractMaterialThemeDescriptor extends ThemeManagerFactoryDescriptor {
public static final String ID = "material";

@Override
public String getThemeId() {
return ID;
}

@Override
public boolean isNamespaced() {
return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,19 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

public class MaterialIndigoThemeManagerFactory extends ThemeManagerFactory {
public class MaterialIndigoThemeManagerFactory extends AbstractMaterialTheme {

public static final String MATERIAL_INDIGO_CSS = "theme-indigo.css";
public static final String MATERIAL_INDIGO_SYMBOL = "material-indigo";
// Seems like this needs to be 'theme-<descriptor_symbol>'
public static final String MATERIAL_INDIGO_URL_NAME = "theme-material-indigo";

@DataBoundConstructor
public MaterialIndigoThemeManagerFactory() {
}

@Override
public Theme getTheme() {
return Theme.builder()
.withCssUrl(getCssUrl())
.build();
}


@Extension
@Symbol(MATERIAL_INDIGO_SYMBOL)
public static class MaterialIndigoThemeManagerFactoryDescriptor extends ThemeManagerFactoryDescriptor {
public static class MaterialIndigoThemeManagerFactoryDescriptor extends AbstractMaterialThemeDescriptor {

@NonNull
@Override
Expand All @@ -46,10 +38,9 @@ public String getThemeCssSuffix() {
return MATERIAL_INDIGO_CSS;
}

@NonNull
@Override
public String getThemeId() {
return MATERIAL_INDIGO_SYMBOL;
public String getThemeKey() {
return ID + "-indigo";
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,18 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

public class MaterialRedThemeManagerFactory extends ThemeManagerFactory {
public class MaterialRedThemeManagerFactory extends AbstractMaterialTheme {

public static final String MATERIAL_RED_CSS = "theme-red.css";
public static final String MATERIAL_RED_SYMBOL = "material-red";
// Seems like this needs to be 'theme-<descriptor_symbol/theme_id>'
public static final String MATERIAL_RED_URL_NAME = "theme-material-red";

@DataBoundConstructor
public MaterialRedThemeManagerFactory() {
}

@Override
public Theme getTheme() {
return Theme.builder()
.withCssUrl(getCssUrl())
.build();
}

@Extension
@Symbol(MATERIAL_RED_SYMBOL)
public static class MaterialRedThemeManagerFactoryDescriptor extends ThemeManagerFactoryDescriptor {
public static class MaterialRedThemeManagerFactoryDescriptor extends AbstractMaterialThemeDescriptor {

@NonNull
@Override
Expand All @@ -46,10 +37,14 @@ public String getThemeCssSuffix() {
return MATERIAL_RED_CSS;
}

@NonNull
@Override
public String getThemeId() {
return MATERIAL_RED_SYMBOL;
public String getThemeKey() {
return ID + "-red";
}

@Override
public boolean isNamespaced() {
return true;
}
}
}

This file was deleted.

Loading