/**
* ds-jira-issues.js
* Jira issue tracker integration
* View project-specific Jira issues for design system work
*/
import contextStore from '../../stores/context-store.js';
export default class JiraIssues extends HTMLElement {
constructor() {
super();
this.state = {
projectId: null,
issues: [],
filterStatus: 'All',
isLoading: false
};
// Mock data for demo
this.mockIssues = [
{ key: 'DSS-234', summary: 'Add Button component variants', status: 'In Progress', type: 'Task', priority: 'High', assignee: 'John Doe' },
{ key: 'DSS-235', summary: 'Update color token naming convention', status: 'To Do', type: 'Story', priority: 'Medium', assignee: 'Unassigned' },
{ key: 'DSS-236', summary: 'Fix Card component accessibility', status: 'In Review', type: 'Bug', priority: 'High', assignee: 'Jane Smith' },
{ key: 'DSS-237', summary: 'Document Typography system', status: 'Done', type: 'Task', priority: 'Low', assignee: 'Mike Johnson' },
{ key: 'DSS-238', summary: 'Create Icon font export', status: 'To Do', type: 'Task', priority: 'Medium', assignee: 'Sarah Wilson' },
{ key: 'DSS-239', summary: 'Implement Figma sync automation', status: 'In Progress', type: 'Epic', priority: 'High', assignee: 'John Doe' },
];
}
connectedCallback() {
this.render();
this.setupEventListeners();
// Subscribe to project context changes
this.unsubscribe = contextStore.subscribe(({ state }) => {
this.state.projectId = state.projectId;
this.loadIssues();
});
// Load initial issues
this.state.projectId = contextStore.get('projectId');
this.loadIssues();
}
disconnectedCallback() {
if (this.unsubscribe) this.unsubscribe();
}
async loadIssues() {
this.state.isLoading = true;
this.renderLoading();
// Simulate API call delay
await new Promise(resolve => setTimeout(resolve, 800));
// In real implementation, fetch from Jira API via backend
this.state.issues = this.mockIssues;
this.state.isLoading = false;
this.render();
this.setupEventListeners();
}
renderLoading() {
this.innerHTML = `
`;
}
render() {
this.innerHTML = `
Jira Issues
${this.state.projectId ? `Project: ${this.state.projectId}` : 'Select a project to view issues'}
${['All', 'To Do', 'In Progress', 'In Review', 'Done'].map(status => `
`).join('')}
${this.renderIssuesList()}
`;
}
renderIssuesList() {
const filtered = this.state.filterStatus === 'All'
? this.state.issues
: this.state.issues.filter(i => i.status === this.state.filterStatus);
if (filtered.length === 0) {
return `
No issues found in this status
`;
}
return filtered.map(issue => `
${issue.type}
${issue.key}
${issue.summary}
Assignee: ${issue.assignee}
Priority: ${issue.priority}
${issue.status}
`).join('');
}
getTypeColor(type) {
const colors = {
'Bug': '#f44336',
'Task': '#2196f3',
'Story': '#4caf50',
'Epic': '#9c27b0',
'Subtask': '#ff9800'
};
return colors[type] || '#999';
}
setupEventListeners() {
// Status filters
this.querySelectorAll('.status-filter').forEach(btn => {
btn.addEventListener('click', () => {
this.state.filterStatus = btn.dataset.status;
this.render();
this.setupEventListeners();
});
});
// Create issue button
const createBtn = this.querySelector('#create-issue-btn');
if (createBtn) {
createBtn.addEventListener('click', () => {
this.dispatchEvent(new CustomEvent('create-issue', {
detail: { projectId: this.state.projectId },
bubbles: true,
composed: true
}));
});
}
// Issue actions
this.querySelectorAll('.open-issue-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
const issueKey = e.target.closest('.jira-issue').dataset.issueKey;
window.open(`https://jira.atlassian.net/browse/${issueKey}`, '_blank');
});
});
this.querySelectorAll('.link-pr-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
const issueKey = e.target.closest('.jira-issue').dataset.issueKey;
this.dispatchEvent(new CustomEvent('link-pr', {
detail: { issueKey },
bubbles: true,
composed: true
}));
});
});
this.querySelectorAll('.assign-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
const issueKey = e.target.closest('.jira-issue').dataset.issueKey;
this.dispatchEvent(new CustomEvent('assign-issue', {
detail: { issueKey },
bubbles: true,
composed: true
}));
});
});
}
}
customElements.define('ds-jira-issues', JiraIssues);