From b907365e5aa44d0eaaade083fce4d65ac8c945f2 Mon Sep 17 00:00:00 2001 From: Jiri Date: Sat, 22 Jan 2022 21:46:41 +0100 Subject: [PATCH] NestedViewsSearch made optional enabeled by default, can be disabled by existence of ~/.nestedViewsSearch --- .../nested_view/NestedViewsSearchFactory.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/hudson/plugins/nested_view/NestedViewsSearchFactory.java b/src/main/java/hudson/plugins/nested_view/NestedViewsSearchFactory.java index 4f97511..1e3d320 100644 --- a/src/main/java/hudson/plugins/nested_view/NestedViewsSearchFactory.java +++ b/src/main/java/hudson/plugins/nested_view/NestedViewsSearchFactory.java @@ -4,16 +4,24 @@ import hudson.search.Search; import hudson.search.SearchFactory; import hudson.search.SearchableModelObject; -import jenkins.model.Jenkins; - -import javax.inject.Inject; +import java.io.File; @Extension public class NestedViewsSearchFactory extends SearchFactory { @Override public Search createFor(final SearchableModelObject owner) { - return new NestedViewsSearch(); + String userHomeDir = System.getProperty("user.home"); + if (userHomeDir == null) { + return new NestedViewsSearch(); + } else { + File nestedViewsFile = new File(userHomeDir, ".nestedViewsSearch"); + if (nestedViewsFile.exists()) { + return new Search(); + } else { + return new NestedViewsSearch(); + } + } } } \ No newline at end of file