From 017a5abb1126b68c43d94f7a84d0637d82bc0ac7 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Thu, 25 Nov 2021 16:54:17 +0100 Subject: [PATCH] Qute Dev UI - fix the preview page --- .../qute/deployment/QuteProcessor.java | 2 +- .../main/resources/dev-templates/preview.html | 24 ++++++++----------- .../devconsole/DevConsoleQuteSmokeTest.java | 3 +++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java index 35707ebab16e3..00873e95b7fda 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java @@ -1320,7 +1320,7 @@ TemplateVariantsBuildItem collectTemplateVariants(List te // ItemResource/item -> -> [ItemResource/item.html, ItemResource/item.xml] Map> baseToVariants = new HashMap<>(); for (String path : allPaths) { - int idx = path.lastIndexOf('.'); + int idx = path.indexOf('.'); if (idx != -1) { String base = path.substring(0, idx); List variants = baseToVariants.get(base); diff --git a/extensions/qute/deployment/src/main/resources/dev-templates/preview.html b/extensions/qute/deployment/src/main/resources/dev-templates/preview.html index 47c59d988aa04..b563f52692486 100644 --- a/extensions/qute/deployment/src/main/resources/dev-templates/preview.html +++ b/extensions/qute/deployment/src/main/resources/dev-templates/preview.html @@ -15,11 +15,9 @@ @@ -56,26 +54,24 @@ {! Init the template path -> initial data map !} {#for template in info:devQuteInfos.templates} - {#let dataCount=count} - var testData{dataCount}; + var testData{template_count}; {#if template.parameters} - testData{dataCount} = '{'; + testData{template_count} = '{'; {#each template.parameters} - testData{dataCount} += '\n // Template parameter {template_count}: {it.value.raw}\n'; - testData{dataCount} += ' "{it.key}" : null'; - {#if hasNext} - testData{dataCount} += ','; + testData{template_count} += '\n // Template parameter {it_count}: {it.value.raw}\n'; + testData{template_count} += ' "{it.key}" : null'; + {#if it_hasNext} + testData{template_count} += ','; {/if} {/each} - testData{dataCount} += '\n}'; + testData{template_count} += '\n}'; {#else} - testData{dataCount} = '{}'; + testData{template_count} = '{}'; {/if} {#each template.variants} - templateDataMap['{it.key}'] = testData{dataCount}; + templateDataMap['{it.key}'] = testData{template_count}; templateSourceMap['{it.key}'] = '{it.value}'; {/each} - {/let} {/for} const editor = CodeMirror.fromTextArea(document.querySelector('#template-data'), { diff --git a/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleQuteSmokeTest.java b/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleQuteSmokeTest.java index 95c43e38d21b5..359e4a67a28e6 100644 --- a/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleQuteSmokeTest.java +++ b/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleQuteSmokeTest.java @@ -25,6 +25,9 @@ public void testTemplates() { RestAssured.get("q/dev/io.quarkus.quarkus-qute/templates") .then() .statusCode(200).body(Matchers.containsString("hello.txt")); + RestAssured.get("q/dev/io.quarkus.quarkus-qute/preview") + .then() + .statusCode(200).body(Matchers.containsString("Test JSON data")); } }