Skip to content

Commit f572523

Browse files
authored
Use nested layout by default (#1311)
1 parent 364b039 commit f572523

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export interface PositionedGraph {
175175
measuredHeight: number;
176176
}
177177

178-
export function isFlagEnabled(flag: string) {
178+
export function isFlagEnabled(flag: string, defaultValue: boolean = false) {
179179
const isEnabled = (v: string | null) =>
180180
["yes", "1", "true", "enabled"].includes(v?.toLowerCase() ?? "");
181181

@@ -185,11 +185,12 @@ export function isFlagEnabled(flag: string) {
185185
} catch {}
186186
try {
187187
// LocalStorage access can throw, gracefully access the key.
188-
return isEnabled(window.localStorage.getItem(flag));
188+
const v = window.localStorage.getItem(flag);
189+
if (v !== null) return isEnabled(v);
189190
} catch {}
190-
return false;
191+
return defaultValue;
191192
}
192193

193-
export const nestedLayout = () => isFlagEnabled("nestedLayout");
194+
export const nestedLayout = () => isFlagEnabled("nestedLayout", true);
194195
// Optionally turn on debugging for the graph. Once the nested layout is stable, we could use a constant to let tree-shaking remove debug code in production bundles.
195196
export const debugPipelineGraph = () => isFlagEnabled("debugPipelineGraph");

src/test/java/io/jenkins/plugins/pipelinegraphview/PipelineGraphViewNestedTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.jenkins.plugins.pipelinegraphview.utils.TestUtils;
1414
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
1515
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
16-
import org.junit.jupiter.api.BeforeEach;
1716
import org.junit.jupiter.api.Test;
1817
import org.jvnet.hudson.test.Issue;
1918

@@ -24,11 +23,6 @@ class PipelineGraphViewNestedTest {
2423
// mvn exec:java -e -D exec.mainClass="com.microsoft.playwright.CLI" -Dexec.classpathScope=test -Dexec.args="codegen
2524
// http://localhost:8080/jenkins
2625

27-
@BeforeEach
28-
void setUp(Page p) {
29-
p.context().addInitScript("window.localStorage.setItem('nestedLayout', 'true')");
30-
}
31-
3226
@Test
3327
void smokeTest(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
3428
String name = "Integration Tests";

src/test/java/io/jenkins/plugins/pipelinegraphview/PipelineGraphViewTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.jenkins.plugins.pipelinegraphview.utils.TestUtils;
1414
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
1515
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
16+
import org.junit.jupiter.api.BeforeEach;
1617
import org.junit.jupiter.api.Test;
1718
import org.jvnet.hudson.test.Issue;
1819

@@ -23,6 +24,11 @@ class PipelineGraphViewTest {
2324
// mvn exec:java -e -D exec.mainClass="com.microsoft.playwright.CLI" -Dexec.classpathScope=test -Dexec.args="codegen
2425
// http://localhost:8080/jenkins
2526

27+
@BeforeEach
28+
void setUp(Page p) {
29+
p.context().addInitScript("window.localStorage.setItem('nestedLayout', 'false')");
30+
}
31+
2632
@Test
2733
void smokeTest(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
2834
String name = "Integration Tests";

0 commit comments

Comments
 (0)