diff --git a/src/main/resources/io/jenkins/plugins/designlibrary/Dialogs/index.jelly b/src/main/resources/io/jenkins/plugins/designlibrary/Dialogs/index.jelly index 0941afb8..08408f7d 100644 --- a/src/main/resources/io/jenkins/plugins/designlibrary/Dialogs/index.jelly +++ b/src/main/resources/io/jenkins/plugins/designlibrary/Dialogs/index.jelly @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@ - +

${%alerts}

@@ -35,7 +35,7 @@ - +

${%prompts}

@@ -52,7 +52,7 @@ - +

${%confirmations}

@@ -87,7 +87,7 @@ - + @@ -123,7 +123,7 @@ - + diff --git a/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/adjunct.js b/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/adjunct.js new file mode 100644 index 00000000..5187c8dd --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/adjunct.js @@ -0,0 +1,19 @@ +function showDefault() { + notificationBar.show("Default"); +} + +function showSuccess() { + notificationBar.show("Success", notificationBar.SUCCESS); +} + +function showWarning() { + notificationBar.show("Warning", notificationBar.WARNING); +} + +function showError() { + notificationBar.show("Error", notificationBar.ERROR); +} + +function hideNotification() { + notificationBar.hide(); +} diff --git a/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/index.jelly b/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/index.jelly index 27d722b4..af63da80 100644 --- a/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/index.jelly +++ b/src/main/resources/io/jenkins/plugins/designlibrary/Notifications/index.jelly @@ -1,5 +1,5 @@ - + @@ -17,6 +17,7 @@ @@ -37,6 +38,7 @@ @@ -57,6 +59,7 @@ @@ -77,6 +80,7 @@ @@ -84,7 +88,9 @@ + diff --git a/src/main/resources/io/jenkins/plugins/designlibrary/sample.js b/src/main/resources/io/jenkins/plugins/designlibrary/sample.js index 193391a9..e49baefe 100644 --- a/src/main/resources/io/jenkins/plugins/designlibrary/sample.js +++ b/src/main/resources/io/jenkins/plugins/designlibrary/sample.js @@ -1,6 +1,21 @@ document.addEventListener("DOMContentLoaded", () => { const url = document.querySelector("head").dataset.rooturl; + document.querySelectorAll(".callback-button").forEach((element) => { + let callback = element.dataset.callback; + element.onclick = () => { + if ( + callback && + window[callback] && + typeof window[callback] === "function" + ) { + window[callback](); + } else { + console.warn(`Callback function ${callback} is not defined`); + } + }; + }); + document.querySelectorAll(".sample-remote").forEach((element) => { const uiComponentName = element.dataset.componentName; const fileName = element.dataset.sample; diff --git a/src/main/resources/lib/samples/code.jelly b/src/main/resources/lib/samples/code.jelly index 1c58cb15..416ab641 100644 --- a/src/main/resources/lib/samples/code.jelly +++ b/src/main/resources/lib/samples/code.jelly @@ -3,18 +3,26 @@ Displays a copyable code snippet. - - + + Code snippet to be displayed if and only if "file" is not set. + + + JavaScript function to be called when the "Execute code" button is clicked. + If "code" attribute is set, these two attributes should be in sync ("code" cannot be inline JS anymore due to CSP). + + + File containing the code snippet to be displayed. + If the "callback" attribute is set, the file will be referenced in a script tag, so that it can be invoked. + Defaults to 'xml'. -
-      
+      
         ${code}
       
     
@@ -22,9 +30,9 @@
- + -