@@ -365,7 +494,13 @@ function generateTemplate(templateType, data, showComments) {
Components
- ${Array.isArray(data.components) ? data.components.map(comp => `
+ ${showSmartValues ? `
+ {{#issue.components}}
+
+ {{.}}
+
+ {{/issue.components}}
+ ` : Array.isArray(data.components) ? data.components.map(comp => `
${comp}
@@ -376,7 +511,13 @@ function generateTemplate(templateType, data, showComments) {
Labels
- ${Array.isArray(data.labels) ? data.labels.map(label => `
+ ${showSmartValues ? `
+ {{#issue.labels}}
+
+ {{.}}
+
+ {{/issue.labels}}
+ ` : Array.isArray(data.labels) ? data.labels.map(label => `
${label}
@@ -384,11 +525,6 @@ function generateTemplate(templateType, data, showComments) {
` : ''}
-
-
-
Created
-
${data.created}
-
`;
@@ -397,7 +533,7 @@ function generateTemplate(templateType, data, showComments) {
template += `
Comments
@@ -410,39 +546,23 @@ function generateTemplate(templateType, data, showComments) {
oninput="assignHeaderColor('comments', this.value)">
- ${Array.isArray(data.comments) ? comments.map(comment => `
-
-
-
-
-
${showSmartValues ? '{{comment.author}}' : comment.author}
-
-
- Created: ${showSmartValues ? '{{comment.created}}' : comment.created}
-
-
-
-
- ${showSmartValues ? '{{comment.body.html}}' : comment.content}
-
-
- `).join('') : showSmartValues ? `
+ ${Array.isArray(data.comments) ? getFilteredComments(data.comments).map(comment => `
-
{{comment.author}}
+
${comment.author}
- Created: {{comment.created}}
+ Created: ${comment.created}
- {{comment.body.html}}
+ ${comment.content}
- ` : ''}
+ `).join('') : ''}
`;
@@ -455,11 +575,11 @@ function generateTemplate(templateType, data, showComments) {
style="background-color: ${issueHeaderColor};"
onclick="triggerColorPicker('issue')">
-
${data.issueKey}
+
${showSmartValues ? '{{issue.key}}' : data.issueKey}
- ${data.type}
+ ${showSmartValues ? '{{issue.type}}' : data.type}
- ${data.status}
+ ${showSmartValues ? '{{issue.status}}' : data.status}
@@ -473,17 +593,17 @@ function generateTemplate(templateType, data, showComments) {
-
${data.summary}
+ ${showSmartValues ? '{{issue.summary}}' : data.summary}
Assignee
-
${data.assignee}
+
${showSmartValues ? '{{issue.assignee}}' : data.assignee}
Priority
-
${data.priority}
+
${showSmartValues ? '{{issue.priority}}' : data.priority}
@@ -500,8 +620,7 @@ function generateTemplate(templateType, data, showComments) {
${showComments && data.comments ? `
Comments
- ${Array.isArray(data.comments) ? comments.map(comment => `
+ ${Array.isArray(data.comments) ? getFilteredComments(data.comments).map(comment => `
-
${showSmartValues ? '{{comment.author}}' : comment.author}
+
${comment.author}
- Created: ${showSmartValues ? '{{comment.created}}' : comment.created}
+ Created: ${comment.created}
-
- ${showSmartValues ? '{{comment.body.html}}' : comment.content}
-
+
${comment.content}
- `).join('') : showSmartValues ? `
-
-
-
-
-
- Created: {{comment.created}}
-
-
-
-
- {{comment.body.html}}
-
-
- ` : ''}
+ `).join('') : ''}
` : ''}
@@ -557,6 +658,399 @@ function generateTemplate(templateType, data, showComments) {
return template;
}
+// Function to generate email template HTML
+function generateEmailTemplate(templateType, data, showComments) {
+ const issueTemplate = `
+
+
+ ${data.summary}
+
+
+ ${templateType === 'full' ? `
+
+ Description: ${data.description}
+
+ ` : ''}
+
+ Key: ${data.issueKey}
+
+
+ Status: ${data.status}
+
+
+ Priority: ${data.priority}
+
+
+ Assignee: ${data.assignee}
+
+ ${templateType === 'full' ? `
+
+ Reporter: ${data.reporter}
+
+
+ Created: ${data.created}
+
+
+ Updated: ${data.updated}
+
+ ${data.components && data.components.length > 0 ? `
+
+ Components: ${Array.isArray(data.components) ? data.components.join(', ') : data.components}
+
+ ` : ''}
+ ${data.labels && data.labels.length > 0 ? `
+
+ Labels: ${Array.isArray(data.labels) ? data.labels.join(', ') : data.labels}
+
+ ` : ''}
+ ` : ''}
+
+
+ `;
+
+ const commentsTemplate = showComments && data.comments && data.comments.length > 0 ? `
+
+
+ Comments
+
+
+ ${Array.isArray(data.comments) ? getFilteredComments(data.comments).map(comment => `
+
+
Author: ${comment.author}
+
Comment:
+
${comment.content}
+
Posted: ${comment.created}
+
+ `).join('') : ''}
+
+
+ ` : '';
+
+ const signature = `
+
Thank you,
+
Your Jira Automation
+ `;
+
+ return `${issueTemplate}${commentsTemplate}${signature}`;
+}
+
+// Function to generate minified HTML
+function generateHTML() {
+ // Always use smart values for the minified output
+ const data = templateData[currentProduct].smart;
+
+ // Generate fields based on product type
+ const generateFields = () => {
+ let fields = '';
+
+ // Common fields
+ fields += `
+
+
Status
+
{{issue.status}}
+
+
+
Priority
+
{{issue.priority}}
+
+
+
Assignee
+
{{issue.assignee}}
+
+
+
Reporter
+
{{issue.reporter}}
+
+
+
Created
+
{{issue.created}}
+
+
+
Updated
+
{{issue.updated}}
+
+ `;
+
+ // Product specific fields
+ if (currentProduct === 'software') {
+ fields += `
+
+
Sprint
+
{{issue.sprint}}
+
+
+
Story Points
+
{{issue.storyPoints}}
+
+ `;
+ } else if (currentProduct === 'servicedesk') {
+ fields += `
+
+
Request Type
+
{{issue.requestType}}
+
+
+
Impact
+
{{issue.impact}}
+
+
+ `;
+ } else if (currentProduct === 'core') {
+ fields += `
+
+
Due Date
+
{{issue.dueDate}}
+
+
+
Category
+
{{issue.category}}
+
+ `;
+ }
+
+ return fields;
+ };
+
+ // Function to generate the comments section for preview
+ function generatePreviewComments() {
+ if (!showComments) return '';
+
+ const commentContent = Array.isArray(data.comments) ? getFilteredComments(data.comments).map(comment => `
+
+
+ {{author.displayName}}
+ {{created.format("yyyy-MM-dd HH:mm")}}
+
+
{{body.html}}
+
+ `).join('') : (showSmartValues ? `
+
+
+ {{author.displayName}}
+ {{created.format("yyyy-MM-dd HH:mm")}}
+
+
{{body.html}}
+
+ ` : '');
+
+ return `
+
+
+ Comments
+
+
+ {{#issue.comments}}
+ ${commentContent}
+ {{/issue.comments}}
+
+
+ `;
+ }
+
+ // Function to generate the comments section for minified output
+ function generateMinifiedComments() {
+ if (!showComments) return '';
+
+ return `
+
+
+ Comments
+
+
+ {{#issue.comments}}
+
+
+ {{author.displayName}}
+ {{created.format("yyyy-MM-dd HH:mm")}}
+
+
{{body.html}}
+
+ {{/issue.comments}}
+
+
+ `;
+ }
+
+ const template = `
+
+
+ {{issue.key}}
+ {{issue.type}}
+
+
+
+
+
{{issue.summary}}
+
{{issue.description}}
+
+
+
+ ${generateFields()}
+
+
+ ${currentProduct === 'software' ? `
+
+
Components
+
+ {{#issue.components}}
+
+ {{.}}
+
+ {{/issue.components}}
+
+
+
+
+
Labels
+
+ {{#issue.labels}}
+
+ {{.}}
+
+ {{/issue.labels}}
+
+
+ ` : ''}
+
+
+ ${generatePreviewComments()}
+`;
+
+ const minifiedTemplate = `
+
+
+ {{issue.key}}
+ {{issue.type}}
+
+
+
+
+
{{issue.summary}}
+
{{issue.description}}
+
+
+
+ ${generateFields()}
+
+
+ ${currentProduct === 'software' ? `
+
+
Components
+
+ {{#issue.components}}
+
+ {{.}}
+
+ {{/issue.components}}
+
+
+
+
+
Labels
+
+ {{#issue.labels}}
+
+ {{.}}
+
+ {{/issue.labels}}
+
+
+ ` : ''}
+
+
+ ${generateMinifiedComments()}
+`;
+
+ const fullHTML = `
+
+
+
+
+
+
Jira Notification
+
+
+
+
+ ${minifiedTemplate}
+
+`;
+
+ // Get the minified HTML
+ const minifiedHTML = fullHTML
+ .replace(/\s+/g, ' ') // Replace multiple whitespace with single space
+ .replace(/>\s+<') // Remove whitespace between tags
+ .replace(//g, '') // Remove comments
+ .trim(); // Remove leading/trailing whitespace
+
+ // Update the output
+ document.getElementById("htmlOutput").textContent = minifiedHTML;
+}
+
// Function to change template type
function changeTemplate(template) {
currentTemplate = template;
@@ -668,21 +1162,6 @@ function assignHeaderColor(section, color) {
updatePreview();
}
-// Function to generate minified HTML
-function generateHTML() {
- const data = showSmartValues ? templateData[currentProduct].smart : templateData[currentProduct].mock;
- const template = `
-
-
-
-
-
-
- `;
-
- document.getElementById("htmlOutput").textContent = template.replace(/\s+/g, ' ').trim();
-}
-
// Initialize the page
document.addEventListener("DOMContentLoaded", () => {
// Set initial active states for buttons
@@ -706,6 +1185,37 @@ document.addEventListener("DOMContentLoaded", () => {
generateHtmlBtn.addEventListener("click", generateHTML);
}
+ const copyHtmlBtn = document.getElementById("copyHTML");
+ if (copyHtmlBtn) {
+ copyHtmlBtn.addEventListener("click", async () => {
+ const htmlOutput = document.getElementById("htmlOutput");
+ if (htmlOutput && htmlOutput.value) {
+ try {
+ await navigator.clipboard.writeText(htmlOutput.value);
+
+ // Visual feedback
+ const originalText = copyHtmlBtn.innerHTML;
+ copyHtmlBtn.innerHTML = `
+
+
+
+ `;
+ copyHtmlBtn.classList.remove('bg-gray-100', 'text-gray-700', 'hover:bg-gray-200');
+ copyHtmlBtn.classList.add('bg-green-50', 'text-green-600');
+
+ // Reset after 2 seconds
+ setTimeout(() => {
+ copyHtmlBtn.innerHTML = originalText;
+ copyHtmlBtn.classList.remove('bg-green-50', 'text-green-600');
+ copyHtmlBtn.classList.add('bg-gray-100', 'text-gray-700', 'hover:bg-gray-200');
+ }, 2000);
+ } catch (err) {
+ console.error('Failed to copy text: ', err);
+ }
+ }
+ });
+ }
+
const smartValuesToggle = document.getElementById("toggleView");
if (smartValuesToggle) {
smartValuesToggle.addEventListener("click", toggleSmartValues);
From 4d37e5788353ed162e64aa7bcec7f7e2fadd10d3 Mon Sep 17 00:00:00 2001
From: Codevalve <6092+codevalve@users.noreply.github.com>
Date: Mon, 18 Nov 2024 23:13:41 -0600
Subject: [PATCH 3/3] ci: update GitHub Actions to Node.js 20
- Update actions/checkout to v4
- Update actions/setup-node to v4
- Change Node.js version from 18 to 20
---
.github/workflows/deploy.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 7e59b7d..32457f2 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -11,12 +11,12 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup Node.js
- uses: actions/setup-node@v3
+ uses: actions/setup-node@v4
with:
- node-version: '18'
+ node-version: '20'
cache: 'npm'
- name: Install dependencies