diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c5b943be --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true + +[*.jelly] +indent_style = tab diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/catalog.jelly b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/catalog.jelly index abd69f96..3e7dcdeb 100644 --- a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/catalog.jelly +++ b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/catalog.jelly @@ -44,10 +44,11 @@
- +
+ - - + - - - - - +
+
@@ -56,10 +57,10 @@
+ ${t.name} (details) + by: ${a.name} @@ -67,10 +68,10 @@
+ required core: ${t.core} + Parameters:
${p}
@@ -78,11 +79,12 @@
+
diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/edit.jelly b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/edit.jelly index 2d3f2dd4..338bddd8 100644 --- a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/edit.jelly +++ b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/edit.jelly @@ -27,12 +27,15 @@ THE SOFTWARE. - + + + +

${%title}

- + @@ -49,13 +52,16 @@ THE SOFTWARE. -
+
+
- +
@@ -67,7 +73,7 @@ THE SOFTWARE.
- + + + + diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript.properties b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript.properties index 1a15df6c..a94c3889 100644 --- a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript.properties +++ b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript.properties @@ -32,6 +32,7 @@ ParameterName=Name: ParameterValue=Value: Run=Run Result=Result +Script=Script ScriptNotFound=// Script source file was not found NotApprovedYet=Script not yet approved, consider asking your administrator to approve it. NotApprovedYetButHasRightWarn=Script not yet approved diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_ja.properties b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_ja.properties index ce4f83f7..ac500148 100644 --- a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_ja.properties +++ b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_ja.properties @@ -30,3 +30,4 @@ ParameterName=名前: ParameterValue=値: Run=実行 Result=結果 +Script=スクリプト diff --git a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_zh_CN.properties b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_zh_CN.properties index cfa33406..0707143f 100644 --- a/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_zh_CN.properties +++ b/src/main/resources/org/jenkinsci/plugins/scriptler/ScriptlerManagement/runScript_zh_CN.properties @@ -10,6 +10,7 @@ ParameterName=名称: ParameterValue=值: Run=运行 Result=结果 +Script=脚本 ScriptNotFound=// 未找到脚本源文件 NotApprovedYet=脚本尚未批准,建议要求管理员批准。 NotApprovedYetButHasRightWarn=脚本尚未批准 diff --git a/src/main/webapp/scriptler.css b/src/main/webapp/scriptler.css index 4039e3fa..7cc694e9 100644 --- a/src/main/webapp/scriptler.css +++ b/src/main/webapp/scriptler.css @@ -26,6 +26,7 @@ .scriptler-toolbar { white-space: nowrap; + width: 1%; } .scriptler-toolbar .scriptler-icon-slot { @@ -37,3 +38,233 @@ .scriptler-icon-slot:visited { color: inherit; } + +.scriptler-list-table, +.scriptler-catalog-table { + margin-top: 0.5rem; +} + +.scriptler-list-table .scriptler-toolbar { + padding-left: 0.5rem; + padding-right: 0.5rem; +} + +.scriptler-script-name, +.scriptler-catalog-name { + font-weight: var(--font-bold-weight); +} + +.scriptler-script-comment { + margin-top: 0.3rem; +} + +.scriptler-script-comment, +.scriptler-origin-cell, +.scriptler-catalog-authors, +.scriptler-catalog-meta, +.scriptler-catalog-params, +.scriptler-catalog-comment { + color: var(--text-color-secondary); +} + +.scriptler-script-comment, +.scriptler-origin-cell, +.scriptler-catalog-comment { + white-space: normal; +} + +.scriptler-catalog-params { + vertical-align: top; +} + +.scriptler-catalog-import { + text-align: center; + white-space: nowrap; + width: 20px; +} + +.scriptler-run-form, +.scriptler-edit-form { + --scriptler-name-input-width: clamp(14rem, 22vw, 16.5rem); + --scriptler-param-row-min-height: 38px; + --scriptler-delete-btn-size: 1.875rem; +} + +.scriptler-run-form { + margin-bottom: 1rem; +} + +.scriptler-runscript-hint { + margin: 0.5rem 0 0.8rem; +} + +.scriptler-run-form .jenkins-form-item { + margin: 0 0 0.65rem; + max-width: var(--form-item-max-width); +} + +.scriptler-run-form .optionalBlock-container { + margin-bottom: 0.9rem; +} + +.scriptler-node-select { + max-width: 26rem; +} + +.scriptler-param-row { + display: grid; + gap: 0.35rem 0.65rem; + grid-template-columns: auto var(--scriptler-name-input-width) auto minmax(18rem, 1fr); +} + +.scriptler-param-list, +.scriptler-param-list .repeated-container { + display: flex; + flex-direction: column; + gap: 0.4rem; +} + +.scriptler-param-list { + max-width: var(--form-item-max-width); + width: 100%; +} + +.scriptler-param-list .repeated-chunk { + border-radius: 0.5rem; + background: color-mix(in srgb, var(--text-color) 4%, transparent); + margin: 0; +} + +.scriptler-param-list .repeated-chunk > .repeated-chunk__header, +.scriptler-edit-form .scriptler-edit-params .repeated-chunk > .repeated-chunk__header { + display: none; + min-height: 0; +} + +.scriptler-param-list .jenkins-repeated-chunk__content { + padding: 0.25rem 0.55rem; +} + +.scriptler-param-label { + color: var(--text-color); + font-weight: var(--font-bold-weight); + white-space: nowrap; +} + +.scriptler-edit-form .jenkins-form-description { + margin-top: 0.2rem; +} + +.scriptler-edit-form .jenkins-form-item { + margin-bottom: 0.65rem; +} + +.scriptler-edit-form .scriptler-edit-params .repeated-chunk { + gap: 0.2rem; + margin-bottom: 0.5rem; +} + +.scriptler-edit-form .scriptler-edit-params .form-container.tr { + margin-top: 0.25rem; + padding-left: 1.75rem; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content { + display: grid; + gap: 0.35rem 0.75rem; + grid-template-columns: max-content minmax(18rem, 1fr); + padding: 0.25rem 2.75rem 0.25rem 0.4rem; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .show-if-not-only { + display: contents; + margin: 0; +} + +.scriptler-edit-form .scriptler-edit-params .repeated-chunk.only .jenkins-repeated-chunk__content > .show-if-not-only .repeatable-delete { + display: none; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content .repeatable-delete { + align-items: center; + display: inline-flex; + height: var(--scriptler-delete-btn-size); + justify-content: center; + max-width: var(--scriptler-delete-btn-size); + min-width: var(--scriptler-delete-btn-size); + padding: 0; + transition: none; + width: var(--scriptler-delete-btn-size); +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content .repeatable-delete svg { + opacity: 1; +} + +.scriptler-param-row, +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item, +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .jenkins-form-label { + align-items: center; + min-height: var(--scriptler-param-row-min-height); +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item { + display: flex; + gap: 0.45rem; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .jenkins-form-label { + display: inline-flex; + flex: 0 0 auto; + white-space: nowrap; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .setting-main { + flex: 1 1 auto; + min-width: 0; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .setting-main .jenkins-input[name="name"] { + max-width: var(--scriptler-name-input-width); + width: var(--scriptler-name-input-width); +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item, +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .jenkins-form-label, +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .setting-main { + margin: 0; +} + +.scriptler-param-input { + margin: 0; + width: 100%; +} + +.scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .setting-main .jenkins-input { + box-sizing: border-box; + margin: 0; + width: 100%; +} + +.scriptler-edit-form .scriptler-edit-params .repeatable-add { + margin-top: 0.2rem; +} + +@media (max-width: 900px) { + .scriptler-param-row { + grid-template-columns: auto minmax(0, 1fr); + } + + .scriptler-param-row .scriptler-param-input { + min-width: 0; + } + + .scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content { + grid-template-columns: 1fr; + } + + .scriptler-edit-form .scriptler-edit-params .jenkins-repeated-chunk__content > .jenkins-form-item .setting-main .jenkins-input[name="name"] { + max-width: 100%; + width: 100%; + } +} diff --git a/src/test/java/org/jenkinsci/plugins/scriptler/restapi/ScriptlerRestApiTest.java b/src/test/java/org/jenkinsci/plugins/scriptler/restapi/ScriptlerRestApiTest.java index 057616d4..2e0078da 100644 --- a/src/test/java/org/jenkinsci/plugins/scriptler/restapi/ScriptlerRestApiTest.java +++ b/src/test/java/org/jenkinsci/plugins/scriptler/restapi/ScriptlerRestApiTest.java @@ -1,5 +1,6 @@ package org.jenkinsci.plugins.scriptler.restapi; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -96,6 +97,24 @@ void testSuccessWithChangedScript() throws Exception { } } + @Test + void testSuccessWithChangedParameters() throws Exception { + try (JenkinsRule.WebClient webClient = j.createWebClient()) { + HtmlPage runScriptPage = webClient.goTo("scriptler/runScript?id=dummy.groovy"); + HtmlForm triggerscript = runScriptPage.getFormByName("triggerscript"); + List valueInputs = + runScriptPage.getByXPath("//div[contains(@class,'scriptler-param-row')]//input[@name='value']"); + assertEquals(2, valueInputs.size(), "Unexpected amount of parameter value inputs"); + valueInputs.get(0).setValueAttribute("jenkins"); + valueInputs.get(1).setValueAttribute("plugin"); + + HtmlPage page = j.submit(triggerscript); + + j.assertGoodStatus(page); + assertTrue(page.getWebResponse().getContentAsString().contains("hello jenkins, this is plugin.")); + } + } + @Test void testUnknownScript() { try (JenkinsRule.WebClient webClient = j.createWebClient()) {